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


Java PredictionModel.removePredictedLabel方法代码示例

本文整理汇总了Java中com.rapidminer.operator.learner.PredictionModel.removePredictedLabel方法的典型用法代码示例。如果您正苦于以下问题:Java PredictionModel.removePredictedLabel方法的具体用法?Java PredictionModel.removePredictedLabel怎么用?Java PredictionModel.removePredictedLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.rapidminer.operator.learner.PredictionModel的用法示例。


在下文中一共展示了PredictionModel.removePredictedLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evaluate

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
/**
 * Applies the applier and evaluator (= second subprocess). In order to reuse possibly created
 * predicted label attributes, we do the following: We compare the predicted label of
 * <code>testSet</code> before and after applying the inner operator. If it changed, the
 * predicted label is removed again. No outer operator could ever see it. The same applies for
 * the confidence attributes in case of classification learning.
 */
protected final void evaluate(ExampleSet testSet) throws OperatorException {
	Attribute predictedBefore = testSet.getAttributes().getPredictedLabel();

	applyProcessExampleSetOutput.deliver(testSet);
	applyProcessModelOutput.deliver(trainingProcessModelInput.getData(IOObject.class));
	throughExtender.passDataThrough();

	executeEvaluator();

	Tools.buildAverages(applyProcessPerformancePortExtender);

	Attribute predictedAfter = testSet.getAttributes().getPredictedLabel();
	// remove predicted label and confidence attributes if there is a new prediction which is
	// not equal to an old one
	if (predictedAfter != null
			&& (predictedBefore == null || predictedBefore.getTableIndex() != predictedAfter.getTableIndex())) {
		PredictionModel.removePredictedLabel(testSet);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:ValidationChain.java

示例2: residualReplace

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
/**
 * This methods replaces the labels of the given example set with the label residuals after
 * using the given model. Please note that the label column will be overwritten and the original
 * label should be stored!
 */
private void residualReplace(ExampleSet exampleSet, Model model, boolean shrinkage) throws OperatorException {
	ExampleSet resultSet = model.apply(exampleSet);
	Attribute label = exampleSet.getAttributes().getLabel();
	Iterator<Example> originalReader = exampleSet.iterator();
	Iterator<Example> predictionReader = resultSet.iterator();
	while ((originalReader.hasNext()) && (predictionReader.hasNext())) {
		Example originalExample = originalReader.next();
		Example predictionExample = predictionReader.next();
		double prediction = predictionExample.getPredictedLabel();
		if (shrinkage) {
			prediction *= getParameterAsDouble(PARAMETER_SHRINKAGE);
		}
		double residual = originalExample.getLabel() - prediction;
		originalExample.setValue(label, residual);
	}
	PredictionModel.removePredictedLabel(resultSet);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:AdditiveRegression.java

示例3: residualReplace

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
/**
 * This methods replaces the labels of the given example set with the label residuals after
 * using the given model. Please note that the label column will be overwritten and the original
 * label should be stored!
 */
private void residualReplace(ExampleSet exampleSet, Model model, boolean shrinkage) throws OperatorException {
	ExampleSet resultSet = model.apply(exampleSet);
	Attribute label = exampleSet.getAttributes().getLabel();
	Iterator<Example> originalReader = exampleSet.iterator();
	Iterator<Example> predictionReader = resultSet.iterator();
	double shrinkageValue = 0;
	if (shrinkage) {
		shrinkageValue = getParameterAsDouble(PARAMETER_SHRINKAGE);
	}
	while (originalReader.hasNext() && predictionReader.hasNext()) {
		Example originalExample = originalReader.next();
		Example predictionExample = predictionReader.next();
		double prediction = predictionExample.getPredictedLabel();
		if (shrinkage) {
			prediction *= shrinkageValue;
		}
		double residual = originalExample.getLabel() - prediction;
		originalExample.setValue(label, residual);
	}
	PredictionModel.removePredictedLabel(resultSet);
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:27,代码来源:AdditiveRegression.java

示例4: evaluate

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
/**
 * Applies the applier and evaluator (= second subprocess).
 * In order to reuse possibly created predicted label attributes, we do the
 * following: We compare the predicted label of <code>testSet</code>
 * before and after applying the inner operator. If it changed, the
 * predicted label is removed again. No outer operator could ever see it.
 * The same applies for the confidence attributes in case of classification
 * learning.
 */
protected final void evaluate(ExampleSet testSet) throws OperatorException {
    Attribute predictedBefore = testSet.getAttributes().getPredictedLabel();

    applyProcessExampleSetOutput.deliver(testSet);
    applyProcessModelOutput.deliver(trainingProcessModelInput.getData(IOObject.class));
    throughExtender.passDataThrough();

    executeEvaluator();

    Tools.buildAverages(applyProcessPerformancePortExtender);

    Attribute predictedAfter = testSet.getAttributes().getPredictedLabel();
    // remove predicted label and confidence attributes if there is a new prediction which is not equal to an old one
    if ((predictedAfter != null) && ((predictedBefore == null) ||
            (predictedBefore.getTableIndex() != predictedAfter.getTableIndex()))) {
        PredictionModel.removePredictedLabel(testSet);
    }
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:28,代码来源:ValidationChain.java

示例5: residualReplace

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
/**
 * This methods replaces the labels of the given example set with the label residuals after using the given model.
 * Please note that the label column will be overwritten and the original label should be stored!
 */
private void residualReplace(ExampleSet exampleSet, Model model, boolean shrinkage) throws OperatorException {
	ExampleSet resultSet = model.apply(exampleSet);
	Attribute label = exampleSet.getAttributes().getLabel();
	Iterator<Example> originalReader = exampleSet.iterator();
	Iterator<Example> predictionReader = resultSet.iterator();
	while ((originalReader.hasNext()) && (predictionReader.hasNext())) {
		Example originalExample = originalReader.next();
		Example predictionExample = predictionReader.next();
		double prediction = predictionExample.getPredictedLabel();
		if (shrinkage)
			prediction *= getParameterAsDouble(PARAMETER_SHRINKAGE);
		double residual = originalExample.getLabel() - prediction;
		originalExample.setValue(label, residual);
	}
	PredictionModel.removePredictedLabel(resultSet);
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:21,代码来源:AdditiveRegression.java

示例6: doWork

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
@Override
public void doWork() throws OperatorException {
	ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);
	Model model = modelInput.getData(Model.class);

	// some checks
	if (exampleSet.getAttributes().getLabel() == null) {
		throw new UserError(this, 105, new Object[0]);
	}
	if (exampleSet.getAttributes().size() == 0) {
		throw new UserError(this, 106, new Object[0]);
	}

	final Attribute label = this.extractLabel(model, exampleSet);

	PlattParameters plattParams;
	{
		ExampleSet calibrationSet = (ExampleSet) exampleSet.clone();
		calibrationSet = model.apply(calibrationSet);
		plattParams = computeParameters(calibrationSet, label);
		PredictionModel.removePredictedLabel(calibrationSet);
	}

	PlattScalingModel scalingModel = new PlattScalingModel(exampleSet, model, plattParams);

	exampleSetOutput.deliver(scalingModel.apply(exampleSet));
	modelOutput.deliver(scalingModel);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:PlattScaling.java

示例7: doWork

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
@Override
public void doWork() throws OperatorException {
	ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);
	if (exampleSet.getAttributes().getLabel() == null) {
		throw new UserError(this, 105);
	}
	if (!exampleSet.getAttributes().getLabel().isNominal()) {
		throw new UserError(this, 101, "ROC Charts", exampleSet.getAttributes().getLabel());
	}
	if (exampleSet.getAttributes().getLabel().getMapping().getValues().size() != 2) {
		throw new UserError(this, 114, "ROC Charts", exampleSet.getAttributes().getLabel());
	}

	if (exampleSet.getAttributes().getPredictedLabel() != null && getParameterAsBoolean(PARAMETER_USE_MODEL)) {
		getLogger().warning("Input example already has a predicted label which will be removed.");
		PredictionModel.removePredictedLabel(exampleSet);
	}
	if (exampleSet.getAttributes().getPredictedLabel() == null && !getParameterAsBoolean(PARAMETER_USE_MODEL)) {
		throw new UserError(this, 107);
	}
	Model model = null;
	if (getParameterAsBoolean(PARAMETER_USE_MODEL)) {
		model = modelInput.getData(Model.class);
		exampleSet = model.apply(exampleSet);
	}
	if (exampleSet.getAttributes().getPredictedLabel() == null) {
		throw new UserError(this, 107);
	}

	ROCDataGenerator rocDataGenerator = new ROCDataGenerator(1.0d, 1.0d);
	ROCData rocPoints = rocDataGenerator.createROCData(exampleSet, getParameterAsBoolean(PARAMETER_USE_EXAMPLE_WEIGHTS),
			ROCBias.getROCBiasParameter(this));
	rocDataGenerator.createROCPlotDialog(rocPoints);

	PredictionModel.removePredictedLabel(exampleSet);

	modelOutput.deliver(model);
	exampleSetOutput.deliver(exampleSet);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:40,代码来源:ROCChartGenerator.java

示例8: doWork

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
@Override
public void doWork() throws OperatorException {
	ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);
	Model model = modelInput.getData(Model.class);

	if (exampleSet.getAttributes().getLabel() == null) {
		throw new UserError(this, 105);
	}
	if (!exampleSet.getAttributes().getLabel().isNominal()) {
		throw new UserError(this, 101, "Lift Charts", exampleSet.getAttributes().getLabel());
	}
	if (exampleSet.getAttributes().getLabel().getMapping().getValues().size() != 2) {
		throw new UserError(this, 114, "Lift Charts", exampleSet.getAttributes().getLabel());
	}

	ExampleSet workingSet = (ExampleSet) exampleSet.clone();
	if (workingSet.getAttributes().getPredictedLabel() != null) {
		PredictionModel.removePredictedLabel(workingSet);
	}

	workingSet = model.apply(workingSet);
	if (workingSet.getAttributes().getPredictedLabel() == null) {
		throw new UserError(this, 107);
	}

	LiftDataGenerator liftDataGenerator = new LiftDataGenerator();
	List<double[]> liftPoints = liftDataGenerator.createLiftDataList(workingSet);
	liftDataGenerator.createLiftChartPlot(liftPoints);

	PredictionModel.removePredictedLabel(workingSet);

	exampleSetOutput.deliver(exampleSet);
	modelOutput.deliver(model);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:35,代码来源:LiftChartGenerator.java

示例9: applyPriorModel

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
/**
 * Helper method applying the start model and adding it to the modelInfo collection
 */
private void applyPriorModel(ExampleSet trainingSet, List<BayBoostBaseModelInfo> modelInfo) throws OperatorException {
	// If the input contains a model already, initialise the example weights.
	if (this.startModel != null) {

		ExampleSet resultSet = this.startModel.apply((ExampleSet) trainingSet.clone());

		// Initial values and the input model are stored in the output model.
		WeightedPerformanceMeasures wp = new WeightedPerformanceMeasures(resultSet);

		this.reweightExamples(wp, resultSet);
		modelInfo.add(new BayBoostBaseModelInfo(this.startModel, wp.getContingencyMatrix()));
		PredictionModel.removePredictedLabel(resultSet);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:18,代码来源:BayesianBoosting.java

示例10: performPrediction

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
@Override
public ExampleSet performPrediction(ExampleSet exampleSet, Attribute predictedLabel) throws OperatorException {
	// apply default model
	exampleSet = defaultModel.apply(exampleSet);
	double[] predictions = new double[exampleSet.size()];
	Iterator<Example> e = exampleSet.iterator();
	int counter = 0;
	while (e.hasNext()) {
		predictions[counter++] = e.next().getPredictedLabel();
	}
	PredictionModel.removePredictedLabel(exampleSet);

	// apply all models to the example set sum up the predictions
	for (int i = 0; i < residualModels.length; i++) {
		exampleSet = residualModels[i].apply(exampleSet);
		e = exampleSet.iterator();
		counter = 0;
		while (e.hasNext()) {
			predictions[counter++] += shrinkage * e.next().getPredictedLabel();
		}
		PredictionModel.removePredictedLabel(exampleSet);
	}

	// set final predictions
	e = exampleSet.iterator();
	counter = 0;
	Attribute newPredictedLabel = createPredictedLabel(exampleSet, getLabel());
	while (e.hasNext()) {
		e.next().setValue(newPredictedLabel, predictions[counter++]);
	}

	return exampleSet;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:34,代码来源:AdditiveRegressionModel.java

示例11: performPredictionRecursivly

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
/**
 * This method will apply all the nodes recursively. For each node it will be called when
 * descending the learner hierarchy. The outcomes array stores the information to which node
 * each example of the applySet has been assigned. Each node's model will be applied to the
 * subset of a partitioned example set according to the node's partition id. After the
 * classification has been performed, the examples will be assigned the partion id's of the
 * child nodes, to whose class the examples where classified.
 *
 * It is very important that after each application the predicted label and the confidences are
 * removed explicitly to avoid a memory leak in the memory table!
 *
 * Confidences are multiplied with the outcome every application.
 */
private void performPredictionRecursivly(ExampleSet applySet, Node node, double[] confidences, int[] outcomes,
		int[] depths, int depth, int numberOfPartitions) throws OperatorException {
	if (!node.isLeaf()) {
		// creating partitioned example set
		SplittedExampleSet splittedSet = new SplittedExampleSet(applySet, new Partition(outcomes, numberOfPartitions));
		splittedSet.selectSingleSubset(node.getPartitionId());

		// applying
		ExampleSet currentResultSet = node.getModel().apply(splittedSet);

		// assign each example a child node regarding to the classification outcome
		int resultIndex = 0;
		Attribute predictionAttribute = currentResultSet.getAttributes().getPredictedLabel();
		for (Example example : currentResultSet) {
			int parentIndex = splittedSet.getActualParentIndex(resultIndex);

			// extracting data
			String label = example.getValueAsString(predictionAttribute);
			confidences[parentIndex] *= example.getConfidence(label);

			// setting outcome index according to referenced child node: if child is leaf, this
			// is equivalent to class index
			outcomes[parentIndex] = node.getChild(label).getPartitionId();
			depths[parentIndex] = depth;

			resultIndex++;
		}
		// deleting new columns from example table
		PredictionModel.removePredictedLabel(currentResultSet);

		// now go through children and apply their subset
		for (Node child : node.getChildren()) {
			performPredictionRecursivly(applySet, child, confidences, outcomes, depths, depth + 1, numberOfPartitions);
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:50,代码来源:HierarchicalMultiClassModel.java

示例12: learn

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
@Override
public Model learn(ExampleSet exampleSet) throws OperatorException {
	// learn base models
	baseInputExtender.deliverToAll(exampleSet, false);
	getBaseModelLearnerProcess().execute();
	List<Model> baseModels = baseModelExtender.getData(Model.class, true);

	// create temporary example set for stacking
	ExampleSet stackingLearningSet = (ExampleSet) exampleSet.clone();
	if (!keepOldAttributes()) {
		stackingLearningSet.getAttributes().clearRegular();
	}

	List<Attribute> tempPredictions = new LinkedList<Attribute>();
	int i = 0;
	for (Model baseModel : baseModels) {
		exampleSet = baseModel.apply(exampleSet);
		Attribute predictedLabel = exampleSet.getAttributes().getPredictedLabel();
		// renaming attribute
		predictedLabel.setName("base_prediction" + i);
		// confidences already removed, predicted label is kept in table
		PredictionModel.removePredictedLabel(exampleSet, false, true);
		stackingLearningSet.getAttributes().addRegular(predictedLabel);
		tempPredictions.add(predictedLabel);
		i++;
	}

	// learn stacked model
	Model stackingModel = getStackingModel(stackingLearningSet);

	// remove temporary predictions from table (confidences were already removed)
	PredictionModel.removePredictedLabel(stackingLearningSet);
	for (Attribute tempPrediction : tempPredictions) {
		stackingLearningSet.getAttributes().remove(tempPrediction);
		stackingLearningSet.getExampleTable().removeAttribute(tempPrediction);
	}

	// create and return model
	return new StackingModel(exampleSet, getModelName(), baseModels, stackingModel, keepOldAttributes());
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:41,代码来源:AbstractStacking.java

示例13: performPrediction

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
@Override
public ExampleSet performPrediction(ExampleSet exampleSet, Attribute predictedLabel) throws OperatorException {
	// init
	PredictionModel.removePredictedLabel(exampleSet, true, true);
	ExampleSet stackingExampleSet = (ExampleSet) exampleSet.clone();
	if (!useAllAttributes) {
		stackingExampleSet.getAttributes().clearRegular();
	}

	// create predictions from base models
	List<Attribute> tempPredictions = new LinkedList<Attribute>();
	int i = 0;
	for (Model baseModel : baseModels) {
		exampleSet = baseModel.apply(exampleSet);
		Attribute basePrediction = exampleSet.getAttributes().getPredictedLabel();
		// renaming attribute
		basePrediction.setName("base_prediction" + i);

		PredictionModel.removePredictedLabel(exampleSet, false, true);
		stackingExampleSet.getAttributes().addRegular(basePrediction);
		tempPredictions.add(basePrediction);
		i++;
	}

	// apply stacking model and copy prediction to original example set
	stackingExampleSet = stackingModel.apply(stackingExampleSet);
	PredictionModel.copyPredictedLabel(stackingExampleSet, exampleSet);

	// remove temporary predictions from table
	for (Attribute tempPrediction : tempPredictions) {
		stackingExampleSet.getAttributes().remove(tempPrediction);
		stackingExampleSet.getExampleTable().removeAttribute(tempPrediction);
	}

	return exampleSet;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:37,代码来源:StackingModel.java

示例14: performPrediction

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
/**
 * Iterates over all models and returns the class with maximum likelihood.
 *
 * @param exampleSet
 *            the set of examples to be classified
 * @param predictedLabel
 *            the label that finally holds the predictions
 */
@Override
public ExampleSet performPrediction(ExampleSet exampleSet, Attribute predictedLabel) throws OperatorException {
	// Prepare special attributes for storing intermediate results:
	final Attribute[] specialAttributes = this.createSpecialAttributes(exampleSet);
	this.initIntermediateResultAttributes(exampleSet, specialAttributes);

	// Apply all models to the example set, each time updating the
	// intermediate results:
	for (int i = 0; i < this.getNumberOfModels(); i++) {
		Model model = this.getModel(i);
		ExampleSet clonedExampleSet = (ExampleSet) exampleSet.clone();
		clonedExampleSet = model.apply(clonedExampleSet);
		this.updateEstimates(clonedExampleSet, this.getContingencyMatrix(i), specialAttributes);
		PredictionModel.removePredictedLabel(clonedExampleSet);
	}

	// Compute and store probability estimates from the intermediate
	// results:
	Iterator<Example> reader = exampleSet.iterator();
	while (reader.hasNext()) {
		Example example = reader.next();
		this.translateOddsIntoPredictions(example, specialAttributes, getTrainingHeader().getAttributes().getLabel());
	}

	// Remove the special attributes used for storing intermediate
	// estimates:
	this.cleanUpSpecialAttributes(exampleSet, specialAttributes);

	return exampleSet;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:39,代码来源:BayBoostModel.java

示例15: doWork

import com.rapidminer.operator.learner.PredictionModel; //导入方法依赖的package包/类
@Override
public void doWork() throws OperatorException {
	ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);
	Tools.hasNominalLabels(exampleSet, getOperatorClassName());
	Attribute label = exampleSet.getAttributes().getLabel();
	if (label.getMapping().size() != 2) {
		throw new UserError(this, 114, "ROC Charts", label);
	}

	if (exampleSet.getAttributes().getPredictedLabel() != null && getParameterAsBoolean(PARAMETER_USE_MODEL)) {
		getLogger().warning("Input example already has a predicted label which will be removed.");
		PredictionModel.removePredictedLabel(exampleSet);
	}
	if (exampleSet.getAttributes().getPredictedLabel() == null && !getParameterAsBoolean(PARAMETER_USE_MODEL)) {
		throw new UserError(this, 107);
	}
	Model model = null;
	if (getParameterAsBoolean(PARAMETER_USE_MODEL)) {
		model = modelInput.getData(Model.class);
		exampleSet = model.apply(exampleSet);
	}
	if (exampleSet.getAttributes().getPredictedLabel() == null) {
		throw new UserError(this, 107);
	}

	ROCDataGenerator rocDataGenerator = new ROCDataGenerator(1.0d, 1.0d);
	ROCData rocPoints = rocDataGenerator.createROCData(exampleSet, getParameterAsBoolean(PARAMETER_USE_EXAMPLE_WEIGHTS),
			ROCBias.getROCBiasParameter(this));
	rocDataGenerator.createROCPlotDialog(rocPoints);

	PredictionModel.removePredictedLabel(exampleSet);

	modelOutput.deliver(model);
	exampleSetOutput.deliver(exampleSet);
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:36,代码来源:ROCChartGenerator.java


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