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


Java Tools类代码示例

本文整理汇总了Java中com.rapidminer.example.Tools的典型用法代码示例。如果您正苦于以下问题:Java Tools类的具体用法?Java Tools怎么用?Java Tools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: addGeneratedAttribute

import com.rapidminer.example.Tools; //导入依赖的package包/类
/** Adds a new attribute. Returns true, if generation was possible. */
private boolean addGeneratedAttribute(AttributeWeightedExampleSet exampleSet, double p) throws Exception {
	if (random.nextDouble() < p) {
		FeatureGenerator generator = FeatureGenerator.selectGenerator(exampleSet, generators, unusedFunctions, random);
		if (generator != null) {
			generator = generator.newInstance();
			Attribute[] args = Tools.getRandomCompatibleAttributes(exampleSet, generator, unusedFunctions, random);
			generator.setArguments(args);
			List<FeatureGenerator> generatorList = new LinkedList<FeatureGenerator>();
			generatorList.add(generator);
			List<Attribute> newAttributes = FeatureGenerator.generateAll(exampleSet.getExampleTable(), generatorList);
			for (Attribute newAttribute : newAttributes) {
				exampleSet.getAttributes().addRegular(newAttribute);
			}
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:GeneratingMutation.java

示例2: doWork

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
public void doWork() throws OperatorException {
	ExampleSet es = exampleSetInput.getData(ExampleSet.class);
	int dimensions = getParameterAsInt(PARAMETER_DIMENSIONS);

	Tools.onlyNumericalAttributes(es, "dimensionality reduction");
	Tools.isNonEmpty(es);
	Tools.checkAndCreateIds(es);

	double[][] p = dimensionalityReduction(es, dimensions);

	DimensionalityReducerModel model = new DimensionalityReducerModel(es, p, dimensions);

	if (exampleSetOutput.isConnected()) {
		exampleSetOutput.deliver(model.apply((ExampleSet) es.clone()));
	}
	originalOutput.deliver(es);
	modelOutput.deliver(model);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:DimensionalityReducer.java

示例3: checkCompatibility

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
protected void checkCompatibility(ExampleSet exampleSet) throws OperatorException {
	Tools.isLabelled(exampleSet);
	Tools.isNonEmpty(exampleSet);

	Attribute label = exampleSet.getAttributes().getLabel();
	if (!label.isNominal()) {
		throw new UserError(this, 101, "the calculation of performance criteria for binominal classification tasks",
				label.getName());
	}

	if (label.getMapping().size() != 2) {
		throw new UserError(this, 114, "the calculation of performance criteria for binominal classification tasks",
				label.getName());
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:17,代码来源:BinominalClassificationPerformanceEvaluator.java

示例4: prepareWeights

import com.rapidminer.example.Tools; //导入依赖的package包/类
/**
 * Creates a weight attribute if not yet done. It either backs up the old weights for restoring
 * them later, or it fills the newly created attribute with the initial value of 1.
 * 
 * @param exampleSet
 *            the example set to be prepared
 * @return the total weight
 */
protected double prepareWeights(ExampleSet exampleSet) {
	Attribute weightAttr = exampleSet.getAttributes().getWeight();
	double totalWeight = 0;
	if (weightAttr == null) {
		this.oldWeights = null;
		weightAttr = Tools.createWeightAttribute(exampleSet);
		Iterator<Example> exRead = exampleSet.iterator();
		while (exRead.hasNext()) {
			exRead.next().setValue(weightAttr, 1);
			totalWeight++;
		}
	} else { // Back up old weights:
		this.oldWeights = new double[exampleSet.size()];
		Iterator<Example> reader = exampleSet.iterator();

		for (int i = 0; (reader.hasNext() && i < oldWeights.length); i++) {
			this.oldWeights[i] = reader.next().getWeight();
			totalWeight += this.oldWeights[i];
		}
	}
	return totalWeight;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:31,代码来源:AdaBoost.java

示例5: learn

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
public Model learn(ExampleSet exampleSet) throws OperatorException {
	Tools.onlyNonMissingValues(exampleSet, getOperatorClassName(), this, new String[0]);

	ImprovedNeuralNetModel model = new ImprovedNeuralNetModel(exampleSet);

	List<String[]> hiddenLayers = getParameterList(PARAMETER_HIDDEN_LAYERS);
	int maxCycles = getParameterAsInt(PARAMETER_TRAINING_CYCLES);
	double maxError = getParameterAsDouble(PARAMETER_ERROR_EPSILON);
	double learningRate = getParameterAsDouble(PARAMETER_LEARNING_RATE);
	double momentum = getParameterAsDouble(PARAMETER_MOMENTUM);
	boolean decay = getParameterAsBoolean(PARAMETER_DECAY);
	boolean shuffle = getParameterAsBoolean(PARAMETER_SHUFFLE);
	boolean normalize = getParameterAsBoolean(PARAMETER_NORMALIZE);
	RandomGenerator randomGenerator = RandomGenerator.getRandomGenerator(this);

	model.train(exampleSet, hiddenLayers, maxCycles, maxError, learningRate, momentum, decay, shuffle, normalize,
			randomGenerator, this);
	return model;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:21,代码来源:ImprovedNeuralNetLearner.java

示例6: modifyMetaData

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
protected MetaData modifyMetaData(ExampleSetMetaData metaData) {
	// adding model's prediction attributes
	MetaData modelMetaData = modelInput.getMetaData();
	if (modelMetaData instanceof PredictionModelMetaData) {
		List<AttributeMetaData> predictionAttributes = ((PredictionModelMetaData) modelMetaData)
				.getPredictionAttributeMetaData();
		if (predictionAttributes != null) {
			metaData.addAllAttributes(predictionAttributes);
			metaData.mergeSetRelation(((PredictionModelMetaData) modelMetaData).getPredictionAttributeSetRelation());
		}
	}

	// adding weight attribute
	metaData.addAttribute(Tools.createWeightAttributeMetaData(metaData));

	// setting number of examples
	metaData.setNumberOfExamples(getSampledSize(metaData));

	return metaData;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:ModelBasedSampling.java

示例7: apply

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
public ExampleSet apply(ExampleSet eSet) throws OperatorException {
	// only warning, removing is done by createSpecialAttribute(...)
	Attribute idAttribute = eSet.getAttributes().getId();
	if (idAttribute != null) {
		getLogger().warning("Overwriting old id attribute!");
	}

	// create new id attribute
	boolean nominalIds = getParameterAsBoolean(PARAMETER_CREATE_NOMINAL_IDS);
	idAttribute = Tools.createSpecialAttribute(eSet, Attributes.ID_NAME, nominalIds ? Ontology.NOMINAL
			: Ontology.INTEGER);

	// set IDs
	int offset = getParameterAsInt(PARAMETER_OFFSET);
	int currentId = 1 + offset;
	Iterator<Example> r = eSet.iterator();
	while (r.hasNext()) {
		Example example = r.next();
		example.setValue(idAttribute, nominalIds ? idAttribute.getMapping().mapString("id_" + currentId) : currentId);
		currentId++;
		checkForStop();
	}

	return eSet;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:IdTagging.java

示例8: init

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
public void init(ExampleSet exampleSet) throws OperatorException {
	super.init(exampleSet);
	Tools.onlyNumericalAttributes(exampleSet, "value based similarities");
	Attributes attributes = exampleSet.getAttributes();
	if (attributes.size() != 1) {
		throw new OperatorException(
				"The bregman divergence you've choosen is not applicable for the dataset! Proceeding with the 'Squared Euclidean distance' bregman divergence.");
	}
	for (Example example : exampleSet) {
		for (Attribute attribute : attributes) {
			if (example.getValue(attribute) <= 0) {
				throw new OperatorException(
						"The bregman divergence you've choosen is not applicable for the dataset! Proceeding with the 'Squared Euclidean distance' bregman divergence.");
			}
			;
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:LogarithmicLoss.java

示例9: init

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
public void init(ExampleSet exampleSet) throws OperatorException {
	super.init(exampleSet);
	Tools.onlyNumericalAttributes(exampleSet, "value based similarities");
	Attributes attributes = exampleSet.getAttributes();
	if (attributes.size() != 1) {
		throw new OperatorException(
				"The bregman divergence you've choosen is not applicable for the dataset! Proceeding with the 'Squared Euclidean distance' bregman divergence.");
	}
	for (Example example : exampleSet) {
		for (Attribute attribute : attributes) {
			double value = example.getValue(attribute);
			if (value <= 0 || value >= 1) {
				throw new OperatorException(
						"The bregman divergence you've choosen is not applicable for the dataset! Proceeding with the 'Squared Euclidean distance' bregman divergence.");
			}
			;
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:21,代码来源:LogisticLoss.java

示例10: generateInternalClusterModel

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
protected ClusterModel generateInternalClusterModel(ExampleSet exampleSet) throws OperatorException {
	// get parameters
	int k = getParameterAsInt(PARAMETER_K);

	// perform checks
	Tools.isNonEmpty(exampleSet);
	Tools.onlyNonMissingValues(exampleSet, getOperatorClassName(), this, new String[0]);
	Tools.checkAndCreateIds(exampleSet);

	if (exampleSet.size() < k) {
		logWarning("number of clusters (k) = " + k + " > number of objects =" + exampleSet.size());
		throw new UserError(this, 142, k);
	}

	ClusterModel model = createClusterModel(exampleSet);

	return model;

}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:21,代码来源:EMClusterer.java

示例11: init

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
public void init(ExampleSet exampleSet) throws OperatorException {
	super.init(exampleSet);
	Tools.onlyNumericalAttributes(exampleSet, "value based similarities");
	Attributes attributes = exampleSet.getAttributes();
	if (attributes.size() != 1) {
		throw new OperatorException(
				"The bregman divergence you've choosen is not applicable for the dataset! Proceeding with the 'Squared Euclidean distance' bregman divergence.");
	}
	for (Attribute attribute : attributes) {
		for (Example example : exampleSet) {
			if (example.getValue(attribute) <= 0) {
				throw new OperatorException(
						"The bregman divergence you've choosen is not applicable for the dataset! Proceeding with the 'Squared Euclidean distance' bregman divergence.");
			}
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:19,代码来源:LogarithmicLoss.java

示例12: init

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
public void init(ExampleSet exampleSet) throws OperatorException {
	super.init(exampleSet);
	Tools.onlyNumericalAttributes(exampleSet, "value based similarities");
	Attributes attributes = exampleSet.getAttributes();
	if (attributes.size() != 1) {
		throw new OperatorException(
				"The bregman divergence you've choosen is not applicable for the dataset! Proceeding with the 'Squared Euclidean distance' bregman divergence.");
	}
	for (Attribute attribute : attributes) {
		for (Example example : exampleSet) {
			double value = example.getValue(attribute);
			if (value <= 0 || value >= 1) {
				throw new OperatorException(
						"The bregman divergence you've choosen is not applicable for the dataset! Proceeding with the 'Squared Euclidean distance' bregman divergence.");
			}
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:20,代码来源:LogisticLoss.java

示例13: doWork

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
public void doWork() throws OperatorException {
	ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);

	int batchSize = getParameterAsInt(PARAMETER_BATCH_SIZE);
	int size = exampleSet.size();
	int currentStart = 0;
	while (currentStart < size) {
		ExampleSet materializedSet = Tools.getLinearSubsetCopy(exampleSet, batchSize, currentStart);
		exampleSetInnerSource.deliver(materializedSet);

		getSubprocess(0).execute();

		currentStart += batchSize;
		inApplyLoop();
	}

	exampleSetOutput.deliver(exampleSet);
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:20,代码来源:BatchProcessing.java

示例14: addGeneratedAttribute

import com.rapidminer.example.Tools; //导入依赖的package包/类
/** Adds a new attribute. Returns true, if generation was possible. */
private boolean addGeneratedAttribute(AttributeWeightedExampleSet exampleSet, double p) throws Exception {
	if (random.nextDouble() < p) {
		FeatureGenerator generator = FeatureGenerator.selectGenerator(exampleSet, generators, unusedFunctions, random);
		if (generator != null) {
			generator = generator.newInstance();
			Attribute[] args = Tools.getRandomCompatibleAttributes(exampleSet, generator, unusedFunctions, random);
			generator.setArguments(args);
			List<FeatureGenerator> generatorList = new LinkedList<FeatureGenerator>();
			generatorList.add(generator);
			List<Attribute> newAttributes = FeatureGenerator.generateAll(exampleSet.getExampleTable(), generatorList);
			for (Attribute newAttribute : newAttributes)
				exampleSet.getAttributes().addRegular(newAttribute);
			return true;
		} else
			return false;
	} else
		return false;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:20,代码来源:GeneratingMutation.java

示例15: doWork

import com.rapidminer.example.Tools; //导入依赖的package包/类
@Override
public void doWork() throws OperatorException {
    ExampleSet es = exampleSetInput.getData(ExampleSet.class);
    int dimensions = getParameterAsInt(PARAMETER_DIMENSIONS);

    Tools.onlyNumericalAttributes(es, "dimensionality reduction");
    Tools.isNonEmpty(es);
    Tools.checkAndCreateIds(es);

    double[][] p = dimensionalityReduction(es, dimensions);

    DimensionalityReducerModel model = new DimensionalityReducerModel(es, p, dimensions);

    if (exampleSetOutput.isConnected())
        exampleSetOutput.deliver(model.apply((ExampleSet)es.clone()));
    originalOutput.deliver(es);
    modelOutput.deliver(model);
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:19,代码来源:DimensionalityReducer.java


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