本文整理汇总了Java中it.uniroma2.sag.kelp.utils.evaluation.RegressorEvaluator类的典型用法代码示例。如果您正苦于以下问题:Java RegressorEvaluator类的具体用法?Java RegressorEvaluator怎么用?Java RegressorEvaluator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RegressorEvaluator类属于it.uniroma2.sag.kelp.utils.evaluation包,在下文中一共展示了RegressorEvaluator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMSEWithEvaluator
import it.uniroma2.sag.kelp.utils.evaluation.RegressorEvaluator; //导入依赖的package包/类
@Test
public void testMSEWithEvaluator() throws NoSuchPerformanceMeasureException {
RegressorEvaluator evaluator = new RegressorEvaluator(trainingSet.getRegressionProperties());
for (int i = 0; i < testSet.getExamples().size(); ++i) {
Example e = testSet.getExample(i);
Prediction score = p.predict(e);
evaluator.addCount(e, score);
}
float mse = evaluator.getMeanSquaredError(regressionLabel);
Assert.assertEquals(0.0212349f, mse, 0.0001);
}
示例2: testMSEWithEvaluatorAndReflection
import it.uniroma2.sag.kelp.utils.evaluation.RegressorEvaluator; //导入依赖的package包/类
@Test
public void testMSEWithEvaluatorAndReflection() throws NoSuchPerformanceMeasureException {
RegressorEvaluator evaluator = new RegressorEvaluator(trainingSet.getRegressionProperties());
for (int i = 0; i < testSet.getExamples().size(); ++i) {
Example e = testSet.getExample(i);
Prediction score = p.predict(e);
evaluator.addCount(e, score);
}
float mse1 = evaluator.getPerformanceMeasure("MeanSquaredErrors");
Assert.assertEquals(0.0212349f, mse1, 0.0001);
}
示例3: main
import it.uniroma2.sag.kelp.utils.evaluation.RegressorEvaluator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// The epsilon in loss function of the regressor
float pReg = 0.1f;
// The regularization parameter of the regressor
float c = 2f;
// The gamma parameter in the RBF kernel
float gamma = 1f;
// The label indicating the value considered by the regressor
Label label = new StringLabel("r");
// Load the dataset
SimpleDataset dataset = new SimpleDataset();
dataset.populate("src/main/resources/sv_regression_test/mg_scale.klp");
// Split the dataset in train and test datasets
dataset.shuffleExamples(new Random(0));
SimpleDataset[] split = dataset.split(0.7f);
SimpleDataset trainDataset = split[0];
SimpleDataset testDataset = split[1];
// Kernel for the first representation (0-index)
Kernel linear = new LinearKernel("0");
// Applying the RBF kernel
Kernel rbf = new RbfKernel(gamma, linear);
// Applying a cache
FixIndexKernelCache kernelCache = new FixIndexKernelCache(
trainDataset.getNumberOfExamples());
rbf.setKernelCache(kernelCache);
// instantiate the regressor
EpsilonSvmRegression regression = new EpsilonSvmRegression(rbf, label,
c, pReg);
// learn
regression.learn(trainDataset);
// get the prediction function
RegressionFunction regressor = regression.getPredictionFunction();
// initializing the performance evaluator
RegressorEvaluator evaluator = new RegressorEvaluator(
trainDataset.getRegressionProperties());
// For each example from the test set
for (Example e : testDataset.getExamples()) {
// Predict the value
Prediction prediction = regressor.predict(e);
// Print the original and the predicted values
System.out.println("real value: " + e.getRegressionValue(label)
+ "\t-\tpredicted value: " + prediction.getScore(label));
// Update the evaluator
evaluator.addCount(e, prediction);
}
// Get the Mean Squared Error for the targeted label
float measSquareError = evaluator.getMeanSquaredError(label);
System.out.println("\nMean Squared Error:\t" + measSquareError);
}