Java源码示例:weka.classifiers.functions.Logistic
示例1
public void buildRegression(){
logReg = new Logistic();
try {
logReg.buildClassifier(iris);
} catch (Exception e) {
}
System.out.println(logReg);
}
示例2
/**
* Initializes the CAWPE ensemble model consisting of five classifiers (SMO,
* KNN, J48, Logistic and MLP) using a majority voting strategy. The ensemble
* uses Weka classifiers. It refers to "Heterogeneous ensemble of standard
* classification algorithms" (HESCA) as described in Lines, Jason & Taylor,
* Sarah & Bagnall, Anthony. (2018). Time Series Classification with HIVE-COTE:
* The Hierarchical Vote Collective of Transformation-Based Ensembles. ACM
* Transactions on Knowledge Discovery from Data. 12. 1-35. 10.1145/3182382.
*
* @param seed
* Seed used within the classifiers and the majority confidence
* voting scheme
* @param numFolds
* Number of folds used within the determination of the classifier
* weights for the {@link MajorityConfidenceVote}
* @return Returns an initialized (but untrained) ensemble model.
* @throws Exception
* Thrown when the initialization has failed
*/
public static Classifier provideCAWPEEnsembleModel(final int seed, final int numFolds) throws Exception {
Classifier[] classifiers = new Classifier[5];
Vote voter = new MajorityConfidenceVote(numFolds, seed);
SMO smo = new SMO();
smo.turnChecksOff();
smo.setBuildCalibrationModels(true);
PolyKernel kl = new PolyKernel();
kl.setExponent(1);
smo.setKernel(kl);
smo.setRandomSeed(seed);
classifiers[0] = smo;
IBk k = new IBk(100);
k.setCrossValidate(true);
EuclideanDistance ed = new EuclideanDistance();
ed.setDontNormalize(true);
k.getNearestNeighbourSearchAlgorithm().setDistanceFunction(ed);
classifiers[1] = k;
J48 c45 = new J48();
c45.setSeed(seed);
classifiers[2] = c45;
classifiers[3] = new Logistic();
classifiers[4] = new MultilayerPerceptron();
voter.setClassifiers(classifiers);
return voter;
}
示例3
public void testThreshold() {
BaggingML h = new BaggingML();
CC cc = new CC();
cc.setClassifier(new Logistic());
h.setClassifier(cc);
Result r = EvaluationTests.cvEvaluateClassifier(h,"0.5");
assertTrue("PCutL Thresholds OK?", r.info.get("Threshold").equals("[0.4, 0.4, 0.4, 0.4, 0.6, 0.6]") );
}
示例4
/**
* Uses the 'basic UCI' set up:
* Comps: SVML, MLP, NN, Logistic, C4.5
* Weight: TrainAcc(4) (train accuracies to the power 4)
* Vote: MajorityConfidence (summing probability distributions)
*/
@Override //Abstract Ensemble
public final void setupDefaultEnsembleSettings() {
this.ensembleName = "CAWPE";
this.weightingScheme = new TrainAcc(4);
this.votingScheme = new MajorityConfidence();
this.transform = null;
CrossValidationEvaluator cv = new CrossValidationEvaluator(seed, false, false, false, false);
cv.setNumFolds(10);
this.trainEstimator = cv;
Classifier[] classifiers = new Classifier[5];
String[] classifierNames = new String[5];
SMO smo = new SMO();
smo.turnChecksOff();
smo.setBuildLogisticModels(true);
PolyKernel kl = new PolyKernel();
kl.setExponent(1);
smo.setKernel(kl);
smo.setRandomSeed(seed);
classifiers[0] = smo;
classifierNames[0] = "SVML";
kNN k=new kNN(100);
k.setCrossValidate(true);
k.normalise(false);
k.setDistanceFunction(new EuclideanDistance());
classifiers[1] = k;
classifierNames[1] = "NN";
classifiers[2] = new J48();
classifierNames[2] = "C4.5";
classifiers[3] = new Logistic();
classifierNames[3] = "Logistic";
classifiers[4] = new MultilayerPerceptron();
classifierNames[4] = "MLP";
setClassifiers(classifiers, classifierNames, null);
}