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


Java Individual类代码示例

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


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

示例1: getNextRank

import com.rapidminer.operator.features.Individual; //导入依赖的package包/类
/** Returns a list of non-dominated individuals. */
private List<Individual> getNextRank(Population population) {
	List<Individual> rank = new ArrayList<Individual>();
	for (int i = 0; i < population.getNumberOfIndividuals(); i++) {
		Individual current = population.get(i);
		rank.add(current);
		boolean delete = false;
		for (int j = rank.size() - 2; j >= 0; j--) {
			Individual ranked = rank.get(j);
			if (isDominated(ranked, current)) {
				rank.remove(ranked);
			}
			if (isDominated(current, ranked)) {
				delete = true;
				// break;
			}
		}
		if (delete) {
			rank.remove(current);
		}
	}
	return rank;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:NonDominatedSortingSelection.java

示例2: isDominated

import com.rapidminer.operator.features.Individual; //导入依赖的package包/类
/**
 * Returns true if the second performance vector is better in all fitness criteria than the
 * first one (remember: the criteria should be maximized).
 */
public static boolean isDominated(Individual i1, Individual i2) {
	PerformanceVector pv1 = i1.getPerformance();
	PerformanceVector pv2 = i2.getPerformance();
	double[][] performances = new double[pv1.getSize()][2];
	for (int p = 0; p < performances.length; p++) {
		performances[p][0] = pv1.getCriterion(p).getFitness();
		performances[p][1] = pv2.getCriterion(p).getFitness();
	}
	boolean dominated = true;
	for (int p = 0; p < performances.length; p++) {
		dominated &= (performances[p][1] >= performances[p][0]);
	}
	boolean oneActuallyBetter = false;
	for (int p = 0; p < performances.length; p++) {
		oneActuallyBetter |= (performances[p][1] > performances[p][0]);
	}
	dominated &= oneActuallyBetter;
	return dominated;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:NonDominatedSortingSelection.java

示例3: operate

import com.rapidminer.operator.features.Individual; //导入依赖的package包/类
@Override
public void operate(Population population) {
	List<Individual> newGeneration = new LinkedList<Individual>();
	int tournamentSize = Math.max((int) Math.round(population.getNumberOfIndividuals() * tournamentFraction), 1);

	if (keepBest) {
		newGeneration.add(population.getBestIndividualEver());
	}

	while (newGeneration.size() < popSize) {
		Individual winner = null;
		for (int k = 0; k < tournamentSize; k++) {
			Individual current = population.get(random.nextInt(population.getNumberOfIndividuals()));
			if ((winner == null)
					|| (current.getPerformance().getMainCriterion().getFitness() > (winner.getPerformance()
							.getMainCriterion().getFitness()))) {
				winner = current;
			}
		}
		newGeneration.add(winner);
	}

	population.clear();
	population.addAllIndividuals(newGeneration);
	this.tournamentFraction += delta;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:TournamentSelection.java

示例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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:BackwardElimination.java

示例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);
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:18,代码来源:BruteForceSelection.java

示例6: 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() });
				}
			}
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:SaveIntermediateWeights.java

示例7: operate

import com.rapidminer.operator.features.Individual; //导入依赖的package包/类
@Override
public void operate(Population population) {
	List<Individual> newGeneration = new LinkedList<Individual>();

	if (keepBest) {
		newGeneration.add(population.getBestIndividualEver());
	}

	int numberOfMarks = popSize - newGeneration.size();
	double distance = 1.0d / numberOfMarks;
	double r = random.nextDouble() / numberOfMarks;
	for (int i = 0; i < numberOfMarks; i++) {
		double f = 0;
		int j = 0;
		Individual individual = null;
		do {
			individual = population.get(j++);
			f += filterFitness(individual.getPerformance().getMainCriterion().getFitness());
		} while (f < r);
		newGeneration.add(individual);
		r += distance;
	}

	population.clear();
	population.addAllIndividuals(newGeneration);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:StochasticUniversalSampling.java

示例8: 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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:WeightingMutation.java

示例9: IndividualSelectorTableModel

import com.rapidminer.operator.features.Individual; //导入依赖的package包/类
public IndividualSelectorTableModel(String[] attributeNames, Population population) {
	this.attributeNames = attributeNames;
	this.population = population;
	if (population.getNumberOfIndividuals() > 0) {
		columnNames.add("Index");
		columnNames.add("Features");
		columnNames.add("Names");

		Individual individual = population.get(0);
		PerformanceVector performanceVector = individual.getPerformance();
		for (int i = 0; i < performanceVector.getSize(); i++) {
			PerformanceCriterion criterion = performanceVector.getCriterion(i);
			columnNames.add(criterion.getName());
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:17,代码来源:IndividualSelectorTableModel.java

示例10: getNextRank

import com.rapidminer.operator.features.Individual; //导入依赖的package包/类
/** Returns a list of non-dominated individuals. */
private List<Individual> getNextRank(Population population) {
	List<Individual> rank = new ArrayList<Individual>();
	for (int i = 0; i < population.getNumberOfIndividuals(); i++) {
		Individual current = population.get(i);
		rank.add(current);
		boolean delete = false;
		for (int j = rank.size() - 2; j >= 0; j--) {
			Individual ranked = rank.get(j);
			if (isDominated(ranked, current))
				rank.remove(ranked);
			if (isDominated(current, ranked)) {
				delete = true;
				// break;
			}
		}
		if (delete)
			rank.remove(current);
	}
	return rank;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:22,代码来源:NonDominatedSortingSelection.java

示例11: isDominated

import com.rapidminer.operator.features.Individual; //导入依赖的package包/类
/**
 * Returns true if the second performance vector is better in all fitness
 * criteria than the first one (remember: the criteria should be maximized).
 */
public static boolean isDominated(Individual i1, Individual i2) {
	PerformanceVector pv1 = i1.getPerformance();
	PerformanceVector pv2 = i2.getPerformance();
	double[][] performances = new double[pv1.getSize()][2];
	for (int p = 0; p < performances.length; p++) {
		performances[p][0] = pv1.getCriterion(p).getFitness();
		performances[p][1] = pv2.getCriterion(p).getFitness();
	}
	boolean dominated = true;
	for (int p = 0; p < performances.length; p++) {
		dominated &= (performances[p][1] >= performances[p][0]);
	}
	boolean oneActuallyBetter = false;
	for (int p = 0; p < performances.length; p++) {
		oneActuallyBetter |= (performances[p][1] > performances[p][0]);
	}
	dominated &= oneActuallyBetter;
	return dominated;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:24,代码来源:NonDominatedSortingSelection.java

示例12: operate

import com.rapidminer.operator.features.Individual; //导入依赖的package包/类
public void operate(Population population) {
	List<Individual> newGeneration = new LinkedList<Individual>();
	int tournamentSize = Math.max((int) Math.round(population.getNumberOfIndividuals() * tournamentFraction), 1);

	if (keepBest) {
		newGeneration.add(population.getBestIndividualEver());
	}

	while (newGeneration.size() < popSize) {
		Individual winner = null;
		for (int k = 0; k < tournamentSize; k++) {
			Individual current = population.get(random.nextInt(population.getNumberOfIndividuals()));
			if ((winner == null) || (current.getPerformance().getMainCriterion().getFitness() > (winner.getPerformance().getMainCriterion().getFitness())))
				winner = current;
		}
		newGeneration.add(winner);
	}

	population.clear();
	population.addAllIndividuals(newGeneration);
	this.tournamentFraction += delta;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:23,代码来源:TournamentSelection.java

示例13: 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;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:18,代码来源:BackwardElimination.java

示例14: 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);
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:17,代码来源:BruteForceSelection.java

示例15: 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); 
			}
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:20,代码来源:SaveIntermediateWeights.java


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