当前位置: 首页>>代码示例>>Java>>正文


Java RegressorEvaluator类代码示例

本文整理汇总了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);
}
 
开发者ID:SAG-KeLP-Legacy,项目名称:kelp-full,代码行数:12,代码来源:EpsilonSVRTest.java

示例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);
}
 
开发者ID:SAG-KeLP-Legacy,项目名称:kelp-full,代码行数:13,代码来源:EpsilonSVRTest.java

示例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);
}
 
开发者ID:SAG-KeLP-Legacy,项目名称:kelp-examples,代码行数:59,代码来源:EpsilonSVRegressionExample.java


注:本文中的it.uniroma2.sag.kelp.utils.evaluation.RegressorEvaluator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。