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


Java Tools.getRandomCompatibleAttributes方法代码示例

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


在下文中一共展示了Tools.getRandomCompatibleAttributes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: operate

import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/**
 * Determines the applicable generators and generates up to <tt>numberOfNewAttributes</tt> new
 * attributes.
 */
@Override
public List<ExampleSetBasedIndividual> operate(ExampleSetBasedIndividual individual) throws Exception {
	AttributeWeightedExampleSet exampleSet = individual.getExampleSet();
	ArrayList<FeatureGenerator> selectedGeneratorList = new ArrayList<FeatureGenerator>();

	if ((totalMaxNumberOfAttributes < 0) || (exampleSet.getAttributes().size() < totalMaxNumberOfAttributes)) {
		for (int h = 0; h < numberOfNewAttributes; h++) {
			if (random.nextDouble() < pGenerate) {
				// random selection of an applicable generator
				FeatureGenerator generator = FeatureGenerator.selectGenerator(exampleSet, generatorList, new String[0],
						random);
				if (generator != null) {
					generator = generator.newInstance();
					// search necessary features
					Attribute[] args = Tools.getRandomCompatibleAttributes(exampleSet, generator, new String[0], random);
					generator.setArguments(args);
					// add selected feature generator to list
					selectedGeneratorList.add(generator);
				}
			}
		}
		if (selectedGeneratorList.size() > 0) {
			// apply selected generators on the current example set
			List<Attribute> newAttributes = FeatureGenerator.generateAll(exampleSet.getExampleTable(),
					selectedGeneratorList);
			for (Attribute newAttribute : newAttributes) {
				exampleSet.getAttributes().addRegular(newAttribute);
			}
		}
	}

	List<ExampleSetBasedIndividual> result = new LinkedList<ExampleSetBasedIndividual>();
	result.add(new ExampleSetBasedIndividual(exampleSet));
	return result;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:40,代码来源:AttributeGenerator.java

示例4: operate

import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/**
 * Determines the applicable generators and generates up to
 * <tt>numberOfNewAttributes</tt> new attributes.
 */
@Override
public List<ExampleSetBasedIndividual> operate(ExampleSetBasedIndividual individual) throws Exception {
	AttributeWeightedExampleSet exampleSet = individual.getExampleSet();
	ArrayList<FeatureGenerator> selectedGeneratorList = new ArrayList<FeatureGenerator>();

	if ((totalMaxNumberOfAttributes < 0) || (exampleSet.getAttributes().size() < totalMaxNumberOfAttributes)) {
		for (int h = 0; h < numberOfNewAttributes; h++) {
			if (random.nextDouble() < pGenerate) {
				// random selection of an applicable generator
				FeatureGenerator generator = FeatureGenerator.selectGenerator(exampleSet, generatorList, new String[0], random);
				if (generator != null) {
					generator = generator.newInstance();
					// search necessary features
					Attribute[] args = Tools.getRandomCompatibleAttributes(exampleSet, generator, new String[0], random);
					generator.setArguments(args);
					// add selected feature generator to list
					selectedGeneratorList.add(generator);
				}
			}
		}
		if (selectedGeneratorList.size() > 0) {
			// apply selected generators on the current example set
			List<Attribute> newAttributes = FeatureGenerator.generateAll(exampleSet.getExampleTable(), selectedGeneratorList);
			for (Attribute newAttribute : newAttributes)
				exampleSet.getAttributes().addRegular(newAttribute);
		}
	}
	
	List<ExampleSetBasedIndividual> result = new LinkedList<ExampleSetBasedIndividual>();
	result.add(new ExampleSetBasedIndividual(exampleSet));
	return result;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:37,代码来源:AttributeGenerator.java

示例5: addGeneratedAttribute

import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/** Adds a new attribute. Returns true, if generation was possible. */
private int addGeneratedAttribute(AttributeWeightedExampleSet exampleSet) throws OperatorException {
	int counter = 0;
	for (int k = 0; k < numberOfConstructed; k++) {
		if (random.nextDouble() < p) {
			FeatureGenerator generator = FeatureGenerator.selectGenerator(exampleSet, generators, unusableFunctions, random);
			if (generator != null) {
				generator = generator.newInstance();
				Attribute[] args = Tools.getRandomCompatibleAttributes(exampleSet, generator, unusableFunctions, 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);
				counter += newAttributes.size();

				Iterator<Attribute> i = newAttributes.iterator();
				List<AttributePeak> sinAttributes = new LinkedList<AttributePeak>();
				Attribute label = exampleSet.getAttributes().getLabel();
				while (i.hasNext()) {
					Attribute current = i.next();
					if (current.isNumerical() && (current.getConstruction().indexOf("sin") == -1)) {
						List<AttributePeak> peaks = factory.getAttributePeaks(exampleSet, label, current);
						sinAttributes.addAll(peaks);
					}
				}

				if (sinAttributes.size() > 0)
					factory.generateSinusFunctions(exampleSet, sinAttributes, random);
				counter += sinAttributes.size();
			}
		}
	}
	return counter;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:38,代码来源:FourierGeneratingMutation.java

示例6: addGeneratedAttribute

import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/** Adds a new attribute. Returns true, if generation was possible. */
private int addGeneratedAttribute(AttributeWeightedExampleSet exampleSet) throws OperatorException {
	int counter = 0;
	for (int k = 0; k < numberOfConstructed; k++) {
		if (random.nextDouble() < p) {
			FeatureGenerator generator = FeatureGenerator.selectGenerator(exampleSet, generators, unusableFunctions,
					random);
			if (generator != null) {
				generator = generator.newInstance();
				Attribute[] args = Tools.getRandomCompatibleAttributes(exampleSet, generator, unusableFunctions, 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);
				}
				counter += newAttributes.size();

				Iterator<Attribute> i = newAttributes.iterator();
				List<AttributePeak> sinAttributes = new LinkedList<AttributePeak>();
				Attribute label = exampleSet.getAttributes().getLabel();
				while (i.hasNext()) {
					Attribute current = i.next();
					if (current.isNumerical() && (current.getConstruction().indexOf("sin") == -1)) {
						List<AttributePeak> peaks = factory.getAttributePeaks(exampleSet, label, current);
						sinAttributes.addAll(peaks);
					}
				}

				if (sinAttributes.size() > 0) {
					factory.generateSinusFunctions(exampleSet, sinAttributes, random);
				}
				counter += sinAttributes.size();
			}
		}
	}
	return counter;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:42,代码来源:FourierGeneratingMutation.java


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