本文整理汇总了Java中com.rapidminer.operator.learner.lazy.DefaultLearner类的典型用法代码示例。如果您正苦于以下问题:Java DefaultLearner类的具体用法?Java DefaultLearner怎么用?Java DefaultLearner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultLearner类属于com.rapidminer.operator.learner.lazy包,在下文中一共展示了DefaultLearner类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: learn
import com.rapidminer.operator.learner.lazy.DefaultLearner; //导入依赖的package包/类
@Override
public Model learn(ExampleSet exampleSet) throws OperatorException {
// create temporary label attribute
ExampleSet workingExampleSet = (ExampleSet) exampleSet.clone();
Attribute originalLabel = workingExampleSet.getAttributes().getLabel();
Attribute workingLabel = AttributeFactory.createAttribute(originalLabel, "working_label");
workingExampleSet.getExampleTable().addAttribute(workingLabel);
workingExampleSet.getAttributes().addRegular(workingLabel);
for (Example example : workingExampleSet) {
example.setValue(workingLabel, example.getValue(originalLabel));
}
workingExampleSet.getAttributes().remove(workingLabel);
workingExampleSet.getAttributes().setLabel(workingLabel);
// apply default model and calculate residuals
DefaultLearner defaultLearner = null;
try {
defaultLearner = OperatorService.createOperator(DefaultLearner.class);
} catch (OperatorCreationException e) {
throw new OperatorException(getName() + ": not able to create default classifier!", e);
}
Model defaultModel = defaultLearner.doWork(workingExampleSet);
residualReplace(workingExampleSet, defaultModel, false);
// create residual models
Model[] residualModels = new Model[getParameterAsInt(PARAMETER_ITERATIONS)];
for (int iteration = 0; iteration < residualModels.length; iteration++) {
residualModels[iteration] = applyInnerLearner(workingExampleSet);
residualReplace(workingExampleSet, residualModels[iteration], true);
}
// clean up working label
workingExampleSet.getAttributes().remove(workingLabel);
workingExampleSet.getExampleTable().removeAttribute(workingLabel);
// create and return model
return new AdditiveRegressionModel(exampleSet, defaultModel, residualModels,
getParameterAsDouble(PARAMETER_SHRINKAGE));
}
示例2: learn
import com.rapidminer.operator.learner.lazy.DefaultLearner; //导入依赖的package包/类
public Model learn(ExampleSet exampleSet) throws OperatorException {
// create temporary label attribute
ExampleSet workingExampleSet = (ExampleSet) exampleSet.clone();
Attribute originalLabel = workingExampleSet.getAttributes().getLabel();
Attribute workingLabel = AttributeFactory.createAttribute(originalLabel, "working_label");
workingExampleSet.getExampleTable().addAttribute(workingLabel);
workingExampleSet.getAttributes().addRegular(workingLabel);
for (Example example : workingExampleSet) {
example.setValue(workingLabel, example.getValue(originalLabel));
}
workingExampleSet.getAttributes().remove(workingLabel);
workingExampleSet.getAttributes().setLabel(workingLabel);
// apply default model and calculate residuals
DefaultLearner defaultLearner = null;
try {
defaultLearner = OperatorService.createOperator(DefaultLearner.class);
} catch (OperatorCreationException e) {
throw new OperatorException(getName() + ": not able to create default classifier!", e);
}
Model defaultModel = defaultLearner.doWork(workingExampleSet);
residualReplace(workingExampleSet, defaultModel, false);
// create residual models
Model[] residualModels = new Model[getParameterAsInt(PARAMETER_ITERATIONS)];
for (int iteration = 0; iteration < residualModels.length; iteration++) {
residualModels[iteration] = applyInnerLearner(workingExampleSet);
residualReplace(workingExampleSet, residualModels[iteration], true);
}
// clean up working label
workingExampleSet.getAttributes().remove(workingLabel);
workingExampleSet.getExampleTable().removeAttribute(workingLabel);
// create and return model
return new AdditiveRegressionModel(exampleSet, defaultModel, residualModels, getParameterAsDouble(PARAMETER_SHRINKAGE));
}