use of edu.neu.ccs.pyramid.classification.logistic_regression.RidgeLogisticOptimizer in project pyramid by cheng-li.
the class SparseCBMOptimzer method updateMultiClassLR.
public void updateMultiClassLR() {
// parallel
RidgeLogisticOptimizer ridgeLogisticOptimizer = new RidgeLogisticOptimizer((LogisticRegression) cbm.multiClassClassifier, dataSet, gammas, priorVarianceMultiClass, true);
//TODO maximum iterations
ridgeLogisticOptimizer.getOptimizer().getTerminator().setMaxIteration(numMulticlassUpdates);
ridgeLogisticOptimizer.optimize();
}
use of edu.neu.ccs.pyramid.classification.logistic_regression.RidgeLogisticOptimizer in project pyramid by cheng-li.
the class CBMNoiseOptimizerFixed method updateBinaryLogisticRegression.
private void updateBinaryLogisticRegression(int componentIndex, int labelIndex) {
RidgeLogisticOptimizer ridgeLogisticOptimizer;
// System.out.println("for component "+componentIndex+" label "+labelIndex);
// System.out.println("weights="+Arrays.toString(gammasT[componentIndex]));
// System.out.println("binary target distribution="+Arrays.deepToString(binaryTargetsDistributions[labelIndex]));
// double posProb = 0;
// double negProb = 0;
// for (int i=0;i<dataSet.getNumDataPoints();i++){
// posProb += gammasT[componentIndex][i] * binaryTargetsDistributions[labelIndex][i][1];
// negProb += gammasT[componentIndex][i] * binaryTargetsDistributions[labelIndex][i][0];
// }
// System.out.println("sum pos prob = "+posProb);
// System.out.println("sum neg prob = "+negProb);
// no parallelism
ridgeLogisticOptimizer = new RidgeLogisticOptimizer((LogisticRegression) cbm.binaryClassifiers[componentIndex][labelIndex], dataSet, gammasT[componentIndex], binaryTargetsDistributions[labelIndex], priorVarianceBinary, false);
//TODO maximum iterations
ridgeLogisticOptimizer.getOptimizer().getTerminator().setMaxIteration(10);
ridgeLogisticOptimizer.optimize();
// if (logger.isDebugEnabled()){
// logger.debug("for cluster "+clusterIndex+" label "+labelIndex+" history= "+ridgeLogisticOptimizer.getOptimizer().getTerminator().getHistory());
// }
}
use of edu.neu.ccs.pyramid.classification.logistic_regression.RidgeLogisticOptimizer in project pyramid by cheng-li.
the class NoiseOptimizerLR method updateAlpha.
private void updateAlpha(int classIndex) {
int numCombination = this.combinations.size();
// Generate weights for each expanded data point
double[] weights = new double[dataSet.getNumDataPoints() * numCombination];
for (int i = 0; i < dataSet.getNumDataPoints(); i++) {
for (int j = 0; j < numCombination; j++) {
weights[i * numCombination + j] = targets[i][j];
}
}
// Train weighted logistic regression with l2
RidgeLogisticOptimizer optimizer = new RidgeLogisticOptimizer(this.lrTransforms.get(classIndex), this.lrDataSet.get(classIndex), weights, this.lrTargets[classIndex], 1000.0, true);
optimizer.getOptimizer().getTerminator().setMaxIteration(10000).setMode(Terminator.Mode.STANDARD);
// System.out.println("after initialization");
// System.out.println("train acc = " + Accuracy.accuracy(this.lrTransforms.get(classIndex), this.lrDataSet.get(classIndex)));
optimizer.optimize();
// System.out.println("after training");
// System.out.println("train acc = " + Accuracy.accuracy(this.lrTransforms.get(classIndex), this.lrDataSet.get(classIndex)));
// System.out.println("classIndex: " + classIndex + ", weights:" + this.lrTransforms.get(classIndex));
}
use of edu.neu.ccs.pyramid.classification.logistic_regression.RidgeLogisticOptimizer in project pyramid by cheng-li.
the class CBMNoiseOptimizerFixed method updateMultiClassLR.
private void updateMultiClassLR() {
// parallel
RidgeLogisticOptimizer ridgeLogisticOptimizer = new RidgeLogisticOptimizer((LogisticRegression) cbm.multiClassClassifier, dataSet, gammas, priorVarianceMultiClass, true);
//TODO maximum iterations
ridgeLogisticOptimizer.getOptimizer().getTerminator().setMaxIteration(10);
ridgeLogisticOptimizer.optimize();
}
use of edu.neu.ccs.pyramid.classification.logistic_regression.RidgeLogisticOptimizer in project pyramid by cheng-li.
the class CBMUtilityOptimizer method updateBinaryLogisticRegression.
private void updateBinaryLogisticRegression(int componentIndex, int labelIndex) {
RidgeLogisticOptimizer ridgeLogisticOptimizer;
// System.out.println("for component "+componentIndex+" label "+labelIndex);
// System.out.println("weights="+Arrays.toString(gammasT[componentIndex]));
// System.out.println("binary target distribution="+Arrays.deepToString(binaryTargetsDistributions[labelIndex]));
// double posProb = 0;
// double negProb = 0;
// for (int i=0;i<dataSet.getNumDataPoints();i++){
// posProb += gammasT[componentIndex][i] * binaryTargetsDistributions[labelIndex][i][1];
// negProb += gammasT[componentIndex][i] * binaryTargetsDistributions[labelIndex][i][0];
// }
// System.out.println("sum pos prob = "+posProb);
// System.out.println("sum neg prob = "+negProb);
// no parallelism
ridgeLogisticOptimizer = new RidgeLogisticOptimizer((LogisticRegression) cbm.binaryClassifiers[componentIndex][labelIndex], dataSet, gammasT[componentIndex], binaryTargetsDistributions[labelIndex], priorVarianceBinary, false);
//TODO maximum iterations
ridgeLogisticOptimizer.getOptimizer().getTerminator().setMaxIteration(10);
ridgeLogisticOptimizer.optimize();
// if (logger.isDebugEnabled()){
// logger.debug("for cluster "+clusterIndex+" label "+labelIndex+" history= "+ridgeLogisticOptimizer.getOptimizer().getTerminator().getHistory());
// }
}
Aggregations