本文整理汇总了Java中com.rapidminer.operator.features.Individual.getNumberOfUsedAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java Individual.getNumberOfUsedAttributes方法的具体用法?Java Individual.getNumberOfUsedAttributes怎么用?Java Individual.getNumberOfUsedAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.operator.features.Individual
的用法示例。
在下文中一共展示了Individual.getNumberOfUsedAttributes方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
@Override
public List<Individual> operate(Individual individual) {
double[] weights = individual.getWeights();
List<Individual> l = new LinkedList<Individual>();
for (int i = 0; i < weights.length; i++) {
if (weights[i] > 0) {
double[] newWeights = new double[weights.length];
System.arraycopy(weights, 0, newWeights, 0, weights.length);
newWeights[i] = 0;
Individual newIndividual = new Individual(newWeights);
if (newIndividual.getNumberOfUsedAttributes() > 0) {
l.add(newIndividual);
}
}
}
return l;
}
示例2: addAllWithExactNumber
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
/** Add all attribute combinations with a fixed size to the population. */
private void addAllWithExactNumber(Population pop, double[] weights, int startIndex, int exactNumberOfFeatures) {
Individual individual = new Individual(weights);
if (individual.getNumberOfUsedAttributes() > exactNumberOfFeatures) {
return;
}
for (int i = startIndex; i < weights.length; i++) {
double[] clone = individual.getWeightsClone();
clone[i] = 1.0d;
Individual newIndividual = new Individual(clone);
if (newIndividual.getNumberOfUsedAttributes() == exactNumberOfFeatures) {
pop.add(newIndividual);
} else {
addAllWithExactNumber(pop, clone, i + 1, exactNumberOfFeatures);
}
}
}
示例3: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
@Override
public List<Individual> operate(Individual individual) {
double[] weights = individual.getWeightsClone();
List<Individual> l = new LinkedList<Individual>();
for (int i = 0; i < weights.length; i++) {
if (!isNominal[i]) {
if (random.nextDouble() < nominalMutationProb) {
if (weights[i] > 0) {
weights[i] = 0;
} else {
weights[i] = 1;
}
}
} else {
double weight = weights[i] + random.nextGaussian() * variance;
if ((!bounded) || ((weight >= 0) && (weight <= 1))) {
weights[i] = weight;
}
}
}
Individual newIndividual = new Individual(weights);
if (newIndividual.getNumberOfUsedAttributes() > 0) {
l.add(newIndividual);
}
return l;
}
示例4: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
@Override
public List<Individual> operate(Individual individual) {
double[] weights = individual.getWeights();
List<Individual> l = new LinkedList<Individual>();
for (int i = 0; i < weights.length; i++) {
if (weights[i] > 0) {
double[] newWeights = new double[weights.length];
System.arraycopy(weights, 0, newWeights, 0, weights.length);
newWeights[i] = 0;
Individual newIndividual = new Individual(newWeights);
if (newIndividual.getNumberOfUsedAttributes() > 0)
l.add(newIndividual);
}
}
return l;
}
示例5: addAllWithExactNumber
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
/** Add all attribute combinations with a fixed size to the population. */
private void addAllWithExactNumber(Population pop, double[] weights, int startIndex, int exactNumberOfFeatures) {
Individual individual = new Individual(weights);
if (individual.getNumberOfUsedAttributes() > exactNumberOfFeatures)
return;
for (int i = startIndex; i < weights.length; i++) {
double[] clone = individual.getWeightsClone();
clone[i] = 1.0d;
Individual newIndividual = new Individual(clone);
if (newIndividual.getNumberOfUsedAttributes() == exactNumberOfFeatures) {
pop.add(newIndividual);
} else {
addAllWithExactNumber(pop, clone, i + 1, exactNumberOfFeatures);
}
}
}
示例6: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
@Override
public List<Individual> operate(Individual individual) {
double[] weights = individual.getWeightsClone();
List<Individual> l = new LinkedList<Individual>();
for (int i = 0; i < weights.length; i++) {
if (!isNominal[i]) {
if (random.nextDouble() < nominalMutationProb) {
if (weights[i] > 0)
weights[i] = 0;
else
weights[i] = 1;
}
} else {
double weight = weights[i] + random.nextGaussian() * variance;
if ((!bounded) || ((weight >= 0) && (weight <= 1)))
weights[i] = weight;
}
}
Individual newIndividual = new Individual(weights);
if (newIndividual.getNumberOfUsedAttributes() > 0)
l.add(newIndividual);
return l;
}
示例7: addAllInRange
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
/** Recursive method to add all attribute combinations to the population. */
private void addAllInRange(Population pop, double[] weights, int startIndex, int minNumberOfFeatures,
int maxNumberOfFeatures) {
if (startIndex >= weights.length) {
return;
}
Individual individual = new Individual(weights);
int numberOfFeatures = individual.getNumberOfUsedAttributes();
if (maxNumberOfFeatures > 0) {
if (numberOfFeatures > maxNumberOfFeatures) {
return;
}
}
// recursive call
double[] clone = individual.getWeightsClone();
clone[startIndex] = 0;
addAllInRange(pop, clone, startIndex + 1, minNumberOfFeatures, maxNumberOfFeatures);
double[] clone2 = individual.getWeightsClone();
clone2[startIndex] = 1.0d;
Individual newIndividual = new Individual(clone2);
numberOfFeatures = newIndividual.getNumberOfUsedAttributes();
if (numberOfFeatures > 0) {
if ((maxNumberOfFeatures < 1 || numberOfFeatures <= maxNumberOfFeatures)
&& numberOfFeatures >= minNumberOfFeatures) {
pop.add(newIndividual);
}
}
addAllInRange(pop, clone2, startIndex + 1, minNumberOfFeatures, maxNumberOfFeatures);
}
示例8: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
@Override
public List<Individual> operate(Individual individual) {
List<Individual> l = new LinkedList<Individual>();
double[] weights = individual.getWeightsClone();
double prob = probability < 0 ? 1.0d / weights.length : probability;
for (int i = 0; i < weights.length; i++) {
if (random.nextDouble() < prob) {
if (weights[i] > 0) {
weights[i] = 0;
} else {
weights[i] = 1;
}
}
}
Individual newIndividual = new Individual(weights);
int numberOfFeatures = newIndividual.getNumberOfUsedAttributes();
if (numberOfFeatures > 0) {
if (exactNumber > 0) {
if (numberOfFeatures == exactNumber) {
l.add(newIndividual);
}
} else {
if (((maxNumber < 1) || (numberOfFeatures <= maxNumber)) && (numberOfFeatures >= minNumber)) {
l.add(newIndividual);
}
}
}
// add also original ES
l.add(individual);
return l;
}
示例9: getValueAt
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
switch (columnIndex) {
case 0:
return (rowIndex + 1);
case 1:
Individual individual = population.get(rowIndex);
return individual.getNumberOfUsedAttributes();
case 2:
individual = population.get(rowIndex);
double[] weights = individual.getWeights();
StringBuffer names = new StringBuffer();
boolean first = true;
for (int w = 0; w < weights.length; w++) {
if (weights[w] > 0.0) {
if (!first) {
names.append(", ");
}
names.append(attributeNames[w]);
first = false;
}
}
return names.toString();
default:
int perfIndex = columnIndex - columnOffset;
individual = population.get(rowIndex);
PerformanceCriterion criterion = individual.getPerformance().getCriterion(perfIndex);
return criterion.getAverage();
}
}
示例10: addAllInRange
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
/** Recursive method to add all attribute combinations to the population. */
private void addAllInRange(Population pop, double[] weights, int startIndex,
int minNumberOfFeatures, int maxNumberOfFeatures) {
if (startIndex >= weights.length)
return;
Individual individual = new Individual(weights);
int numberOfFeatures = individual.getNumberOfUsedAttributes();
if (maxNumberOfFeatures > 0) {
if (numberOfFeatures > maxNumberOfFeatures) {
return;
}
}
// recursive call
double[] clone = individual.getWeightsClone();
clone[startIndex] = 0;
addAllInRange(pop, clone, startIndex + 1, minNumberOfFeatures, maxNumberOfFeatures);
double[] clone2 = individual.getWeightsClone();
clone2[startIndex] = 1.0d;
Individual newIndividual = new Individual(clone2);
numberOfFeatures = newIndividual.getNumberOfUsedAttributes();
if (numberOfFeatures > 0) {
if (((maxNumberOfFeatures < 1) || (numberOfFeatures <= maxNumberOfFeatures)) && (numberOfFeatures >= minNumberOfFeatures)) {
pop.add(newIndividual);
}
}
addAllInRange(pop, clone2, startIndex + 1, minNumberOfFeatures, maxNumberOfFeatures);
}
示例11: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
@Override
public List<Individual> operate(Individual individual) {
List<Individual> l = new LinkedList<Individual>();
double[] weights = individual.getWeightsClone();
double prob = probability < 0 ? 1.0d / weights.length : probability;
for (int i = 0; i < weights.length; i++) {
if (random.nextDouble() < prob) {
if (weights[i] > 0)
weights[i] = 0;
else
weights[i] = 1;
}
}
Individual newIndividual = new Individual(weights);
int numberOfFeatures = newIndividual.getNumberOfUsedAttributes();
if (numberOfFeatures > 0) {
if (exactNumber > 0) {
if (numberOfFeatures == exactNumber) {
l.add(newIndividual);
}
} else {
if (((maxNumber < 1) || (numberOfFeatures <= maxNumber)) && (numberOfFeatures >= minNumber)) {
l.add(newIndividual);
}
}
}
// add also original ES
l.add(individual);
return l;
}
示例12: getValueAt
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
public Object getValueAt(int rowIndex, int columnIndex) {
switch (columnIndex) {
case 0:
return (rowIndex + 1);
case 1:
Individual individual = population.get(rowIndex);
return individual.getNumberOfUsedAttributes();
case 2:
individual = population.get(rowIndex);
double[] weights = individual.getWeights();
StringBuffer names = new StringBuffer();
boolean first = true;
for (int w = 0; w < weights.length; w++) {
if (weights[w] > 0.0) {
if (!first) {
names.append(", ");
}
names.append(attributeNames[w]);
first = false;
}
}
return names.toString();
default:
int perfIndex = columnIndex - columnOffset;
individual = population.get(rowIndex);
PerformanceCriterion criterion = individual.getPerformance().getCriterion(perfIndex);
return criterion.getAverage();
}
}
示例13: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
@Override
public void operate(Population population) {
if (population.getNumberOfIndividuals() < 2) {
return;
}
LinkedList<double[]> matingPool = new LinkedList<double[]>();
for (int i = 0; i < population.getNumberOfIndividuals(); i++) {
matingPool.add(population.get(i).getWeightsClone());
}
List<Individual> l = new LinkedList<Individual>();
while (matingPool.size() > 1) {
double[] p1 = matingPool.remove(random.nextInt(matingPool.size()));
double[] p2 = matingPool.remove(random.nextInt(matingPool.size()));
if (random.nextDouble() < prob) {
crossover(p1, p2);
Individual newIndividual1 = new Individual(p1);
int numberOfFeatures = newIndividual1.getNumberOfUsedAttributes();
if (numberOfFeatures > 0) {
if (exactNumber > 0) {
if (numberOfFeatures == exactNumber) {
l.add(newIndividual1);
}
} else {
if (((maxNumber < 1) || (numberOfFeatures <= maxNumber)) && (numberOfFeatures >= minNumber)) {
l.add(newIndividual1);
}
}
}
Individual newIndividual2 = new Individual(p2);
numberOfFeatures = newIndividual2.getNumberOfUsedAttributes();
if (numberOfFeatures > 0) {
if (exactNumber > 0) {
if (numberOfFeatures == exactNumber) {
l.add(newIndividual2);
}
} else {
if (((maxNumber < 1) || (numberOfFeatures <= maxNumber)) && (numberOfFeatures >= minNumber)) {
l.add(newIndividual2);
}
}
}
}
}
population.addAllIndividuals(l);
}
示例14: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
public void operate(Population population) {
if (population.getNumberOfIndividuals() < 2)
return;
LinkedList<double[]> matingPool = new LinkedList<double[]>();
for (int i = 0; i < population.getNumberOfIndividuals(); i++)
matingPool.add(population.get(i).getWeightsClone());
List<Individual> l = new LinkedList<Individual>();
while (matingPool.size() > 1) {
double[] p1 = matingPool.remove(random.nextInt(matingPool.size()));
double[] p2 = matingPool.remove(random.nextInt(matingPool.size()));
if (random.nextDouble() < prob) {
crossover(p1, p2);
Individual newIndividual1 = new Individual(p1);
int numberOfFeatures = newIndividual1.getNumberOfUsedAttributes();
if (numberOfFeatures > 0) {
if (exactNumber > 0) {
if (numberOfFeatures == exactNumber) {
l.add(newIndividual1);
}
} else {
if (((maxNumber < 1) || (numberOfFeatures <= maxNumber)) && (numberOfFeatures >= minNumber)) {
l.add(newIndividual1);
}
}
}
Individual newIndividual2 = new Individual(p2);
numberOfFeatures = newIndividual2.getNumberOfUsedAttributes();
if (numberOfFeatures > 0) {
if (exactNumber > 0) {
if (numberOfFeatures == exactNumber) {
l.add(newIndividual2);
}
} else {
if (((maxNumber < 1) || (numberOfFeatures <= maxNumber)) && (numberOfFeatures >= minNumber)) {
l.add(newIndividual2);
}
}
}
}
}
population.addAllIndividuals(l);
}