public static void main(String argv[]) { modshogun.init_shogun_with_defaults(); double width = 2.1; double epsilon = 1e-5; double C = 1.0; int mkl_norm = 2; DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat"); DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat"); DoubleMatrix trainlab = Load.load_labels("../data/label_train_multiclass.dat"); CombinedKernel kernel = new CombinedKernel(); CombinedFeatures feats_train = new CombinedFeatures(); CombinedFeatures feats_test = new CombinedFeatures(); RealFeatures subkfeats1_train = new RealFeatures(traindata_real); RealFeatures subkfeats1_test = new RealFeatures(testdata_real); GaussianKernel subkernel = new GaussianKernel(10, width); feats_train.append_feature_obj(subkfeats1_train); feats_test.append_feature_obj(subkfeats1_test); kernel.append_kernel(subkernel); RealFeatures subkfeats2_train = new RealFeatures(traindata_real); RealFeatures subkfeats2_test = new RealFeatures(testdata_real); LinearKernel subkernel2 = new LinearKernel(); feats_train.append_feature_obj(subkfeats2_train); feats_test.append_feature_obj(subkfeats2_test); kernel.append_kernel(subkernel2); RealFeatures subkfeats3_train = new RealFeatures(traindata_real); RealFeatures subkfeats3_test = new RealFeatures(testdata_real); PolyKernel subkernel3 = new PolyKernel(10, 2); feats_train.append_feature_obj(subkfeats3_train); feats_test.append_feature_obj(subkfeats3_test); kernel.append_kernel(subkernel3); kernel.init(feats_train, feats_train); Labels labels = new Labels(trainlab); MKLMultiClass mkl = new MKLMultiClass(C, kernel, labels); mkl.set_epsilon(epsilon); mkl.set_mkl_epsilon(epsilon); mkl.set_mkl_norm(mkl_norm); mkl.train(); kernel.init(feats_train, feats_test); DoubleMatrix out = mkl.apply().get_labels(); modshogun.exit_shogun(); }
public static void main(String argv[]) { modshogun.init_shogun_with_defaults(); DoubleMatrix ground_truth = Load.load_labels("../data/label_train_twoclass.dat"); DoubleMatrix predicted = randn(1, ground_truth.getLength()); Labels ground_truth_labels = new Labels(ground_truth); Labels predicted_labels = new Labels(predicted); ROCEvaluation evaluator = new ROCEvaluation(); evaluator.evaluate(predicted_labels, ground_truth_labels); System.out.println(evaluator.get_ROC()); System.out.println(evaluator.get_auROC()); modshogun.exit_shogun(); }
public static void main(String argv[]) { modshogun.init_shogun_with_defaults(); DoubleMatrix ground_truth = Load.load_labels("../data/label_train_twoclass.dat"); DoubleMatrix predicted = randn(1, ground_truth.getLength()); Labels ground_truth_labels = new Labels(ground_truth); Labels predicted_labels = new Labels(predicted); ContingencyTableEvaluation base_evaluator = new ContingencyTableEvaluation(); base_evaluator.evaluate(predicted_labels, ground_truth_labels); AccuracyMeasure evaluator1 = new AccuracyMeasure(); double accuracy = evaluator1.evaluate(predicted_labels, ground_truth_labels); ErrorRateMeasure evaluator2 = new ErrorRateMeasure(); double errorrate = evaluator2.evaluate(predicted_labels, ground_truth_labels); BALMeasure evaluator3 = new BALMeasure(); double bal = evaluator3.evaluate(predicted_labels, ground_truth_labels); WRACCMeasure evaluator4 = new WRACCMeasure(); double wracc = evaluator4.evaluate(predicted_labels, ground_truth_labels); F1Measure evaluator5 = new F1Measure(); double f1 = evaluator5.evaluate(predicted_labels, ground_truth_labels); CrossCorrelationMeasure evaluator6 = new CrossCorrelationMeasure(); double crosscorrelation = evaluator6.evaluate(predicted_labels, ground_truth_labels); RecallMeasure evaluator7 = new RecallMeasure(); double recall = evaluator7.evaluate(predicted_labels, ground_truth_labels); PrecisionMeasure evaluator8 = new PrecisionMeasure(); double precision = evaluator8.evaluate(predicted_labels, ground_truth_labels); SpecificityMeasure evaluator9 = new SpecificityMeasure(); double specificity = evaluator9.evaluate(predicted_labels, ground_truth_labels); System.out.printf( "%f, %f, %f, %f, %f, %f, %f, %f, %f\n", accuracy, errorrate, bal, wracc, f1, crosscorrelation, recall, precision, specificity); modshogun.exit_shogun(); }