本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}