本文整理汇总了Java中com.rapidminer.operator.features.Individual.getWeights方法的典型用法代码示例。如果您正苦于以下问题:Java Individual.getWeights方法的具体用法?Java Individual.getWeights怎么用?Java Individual.getWeights使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.operator.features.Individual
的用法示例。
在下文中一共展示了Individual.getWeights方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
@Override
public void operate(Population pop) throws Exception {
Individual bestIndividual = pop.getBestIndividualEver();
if (bestIndividual != null) {
File outputFile = operator.getParameterAsFile(AbstractGeneticAlgorithm.PARAMETER_INTERMEDIATE_WEIGHTS_FILE,
true);
if (outputFile != null) {
double[] weightValues = bestIndividual.getWeights();
if (weightValues.length == attributeNames.length) {
AttributeWeights weights = new AttributeWeights();
for (int i = 0; i < weightValues.length; i++) {
weights.setWeight(attributeNames[i], weightValues[i]);
}
try {
weights.writeAttributeWeights(outputFile, Encoding.getEncoding(operator.getRoot()));
} catch (IOException e) {
throw new UserError(operator, e, 303, new Object[] { outputFile, e.getMessage() });
}
}
}
}
}
示例3: 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;
}
示例4: operate
import com.rapidminer.operator.features.Individual; //导入方法依赖的package包/类
public void operate(Population pop) throws Exception {
Individual bestIndividual = pop.getBestIndividualEver();
if (bestIndividual != null) {
File outputFile = operator.getParameterAsFile(AbstractGeneticAlgorithm.PARAMETER_INTERMEDIATE_WEIGHTS_FILE, true);
if (outputFile != null) {
AttributeWeightsWriter writer = OperatorService.createOperator(AttributeWeightsWriter.class);
writer.setParameter(AttributeWeightsWriter.PARAMETER_ATTRIBUTE_WEIGHTS_FILE, outputFile.getAbsolutePath());
double[] weightValues = bestIndividual.getWeights();
if (weightValues.length == attributeNames.length) {
AttributeWeights weights = new AttributeWeights();
for (int i = 0; i < weightValues.length; i++) {
weights.setWeight(attributeNames[i], weightValues[i]);
}
writer.write(weights);
}
}
}
}
示例5: 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] = 1.0d;
l.add(new Individual(newWeights));
}
}
return l;
}
示例6: 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();
}
}
示例7: 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();
}
}