本文整理匯總了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);
}