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


Java KohonenNet类代码示例

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


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

示例1: doWork

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
@Override
public void doWork() throws OperatorException {
	ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);

	// Get and check parameter values
	int trainingRounds = getParameterAsInt(PARAMETER_TRAINING_ROUNDS);
	int netSize = getParameterAsInt(PARAMETER_NET_SIZE);
	int dimensions = getParameterAsInt(PARAMETER_NUMBER_OF_DIMENSIONS);
	double learningRateStart = getParameterAsDouble(PARAMETER_LEARNING_RATE_START);
	double learningRateEnd = getParameterAsDouble(PARAMETER_LEARNING_RATE_END);
	double adaptionRadiusStart = getParameterAsDouble(PARAMETER_ADAPTION_RADIUS_START);
	double adaptionRadiusEnd = getParameterAsDouble(PARAMETER_ADAPTION_RADIUS_END);

	// checking sanity of parameter values
	if (learningRateStart < learningRateEnd) {
		throw new UserError(this, 116, "learning_rate_start",
				"Learning rate at first round must be greater than in last round: (" + learningRateEnd + ")");
	}
	if (adaptionRadiusStart < adaptionRadiusEnd) {
		throw new UserError(this, 116, "adaption_radius_start",
				"Adaption radius at first round must be greater than in last round: (" + adaptionRadiusEnd + ")");
	}

	// train SOM
	KohonenNet net = prepareSOM(exampleSet, dimensions, netSize, trainingRounds, learningRateStart, learningRateEnd,
			adaptionRadiusStart, adaptionRadiusEnd);

	SOMDimensionalityReductionModel model = new SOMDimensionalityReductionModel(exampleSet, net, dimensions);

	if (exampleSetOutput.isConnected()) {
		exampleSetOutput.deliver(model.apply((ExampleSet) exampleSet.clone()));
	}
	originalOutput.deliver(exampleSet);
	modelOutput.deliver(model);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:36,代码来源:SOMDimensionalityReduction.java

示例2: prepareSOM

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
private KohonenNet prepareSOM(ExampleSet exampleSet, int netDimensions, int netSize, int trainingRounds,
		double learningRateStart, double learningRateEnd, double adaptionRadiusStart, double adaptionRadiusEnd)
		throws ProcessStoppedException {
	// generating data for SOM
	int dataDimension;
	RandomDataContainer data = new RandomDataContainer();
	synchronized (exampleSet) {
		Iterator<Example> iterator = exampleSet.iterator();
		dataDimension = exampleSet.getAttributes().size();
		while (iterator.hasNext()) {
			data.addData(getDoubleArrayFromExample(iterator.next()));
			this.checkForStop();
		}
	}
	// generating SOM
	KohonenNet net = new KohonenNet(data);
	RitterAdaptation adaptionFunction = new RitterAdaptation();
	adaptionFunction.setAdaptationRadiusStart(adaptionRadiusStart);
	adaptionFunction.setAdaptationRadiusEnd(adaptionRadiusEnd);
	adaptionFunction.setLearnRateStart(learningRateStart);
	adaptionFunction.setLearnRateEnd(learningRateEnd);
	net.setAdaptationFunction(adaptionFunction);
	int[] dimensions = new int[netDimensions];
	for (int i = 0; i < netDimensions; i++) {
		dimensions[i] = netSize;
	}
	net.init(dataDimension, dimensions, false);
	// train SOM
	net.setTrainingRounds(trainingRounds);
	this.checkForStop();
	net.train(this);
	return net;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:34,代码来源:SOMDimensionalityReduction.java

示例3: getUMatrix

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
private double[][] getUMatrix(KohonenNet net, int[] dimensions) {
	double[][] uMatrix = new double[dimensions[0]][dimensions[1]];
	// getting distances between nodes
	for (int i = 0; i < dimensions[0]; i++) {
		for (int j = 0; j < dimensions[1]; j++) {
			uMatrix[i][j] = net.getNodeDistance(net.getIndexOfCoordinates(new int[] { i, j }));
		}
	}
	return uMatrix;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:11,代码来源:SOMPlotter.java

示例4: doWork

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
@Override
public void doWork() throws OperatorException {
	ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);

	// Get and check parameter values
	int trainingRounds = getParameterAsInt(PARAMETER_TRAINING_ROUNDS);
	int netSize = getParameterAsInt(PARAMETER_NET_SIZE);
	int dimensions = getParameterAsInt(PARAMETER_NUMBER_OF_DIMENSIONS);
	double learningRateStart = getParameterAsDouble(PARAMETER_LEARNING_RATE_START);
	double learningRateEnd = getParameterAsDouble(PARAMETER_LEARNING_RATE_END);
	double adaptionRadiusStart = getParameterAsDouble(PARAMETER_ADAPTION_RADIUS_START);
	double adaptionRadiusEnd = getParameterAsDouble(PARAMETER_ADAPTION_RADIUS_END);

	// checking sanity of parameter values
	if (learningRateStart < learningRateEnd) {
		throw new UserError(this, 116, "learning_rate_start", "Learning rate at first round must be greater than in last round: (" + learningRateEnd + ")");
	}
	if (adaptionRadiusStart < adaptionRadiusEnd) {
		throw new UserError(this, 116, "adaption_radius_start", "Adaption radius at first round must be greater than in last round: (" + adaptionRadiusEnd + ")");
	}

	// train SOM
	KohonenNet net = prepareSOM(exampleSet, dimensions, netSize, trainingRounds, learningRateStart, learningRateEnd, adaptionRadiusStart, adaptionRadiusEnd);

	SOMDimensionalityReductionModel model = new SOMDimensionalityReductionModel(exampleSet, net, dimensions);

	if (exampleSetOutput.isConnected())
		exampleSetOutput.deliver(model.apply((ExampleSet)exampleSet.clone()));
	originalOutput.deliver(exampleSet);
	modelOutput.deliver(model);
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:32,代码来源:SOMDimensionalityReduction.java

示例5: prepareSOM

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
private KohonenNet prepareSOM(ExampleSet exampleSet, int netDimensions, int netSize, int trainingRounds, double learningRateStart, double learningRateEnd, double adaptionRadiusStart, double adaptionRadiusEnd) {
	// generating data for SOM
	int dataDimension;
	RandomDataContainer data = new RandomDataContainer();
	synchronized (exampleSet) {
		Iterator<Example> iterator = exampleSet.iterator();
		dataDimension = exampleSet.getAttributes().size();
		while (iterator.hasNext()) {
			data.addData(getDoubleArrayFromExample(iterator.next()));
		}
	}

	// generating SOM
	KohonenNet net = new KohonenNet(data);
	RitterAdaptation adaptionFunction = new RitterAdaptation();
	adaptionFunction.setAdaptationRadiusStart(adaptionRadiusStart);
	adaptionFunction.setAdaptationRadiusEnd(adaptionRadiusEnd);
	adaptionFunction.setLearnRateStart(learningRateStart);
	adaptionFunction.setLearnRateEnd(learningRateEnd);
	net.setAdaptationFunction(adaptionFunction);
	int[] dimensions = new int[netDimensions];
	for (int i = 0; i < netDimensions; i++)
		dimensions[i] = netSize;
	net.init(dataDimension, dimensions, false);
	// train SOM
	net.setTrainingRounds(trainingRounds);
	net.train();
	return net;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:30,代码来源:SOMDimensionalityReduction.java

示例6: SOMDimensionalityReductionModel

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
protected SOMDimensionalityReductionModel(ExampleSet exampleSet, KohonenNet net, int dimensions) {
	super(exampleSet);
	this.net = net;
	this.dimensions = dimensions;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:6,代码来源:SOMDimensionalityReductionModel.java

示例7: getPMatrix

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
private double[][] getPMatrix(KohonenNet net, RandomDataContainer data, int[] dimensions) {
	// calculating real paretoradius
	int n = data.countData();
	double optimalMedian = 0.2013 * n;
	double estimatedRadius = 0;
	// calculating distances between every example
	double[] distances = new double[n * n];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			distances[i * n + j] = net.getDistance(data.get(i), data.get(j));
		}
	}
	Arrays.sort(distances);
	double percentilSetDifference = Double.POSITIVE_INFINITY;
	// finding percentil, closest to paretoradius
	double radius;
	for (int percentil = 0; percentil < 100; percentil++) {
		int[] nn = new int[n];
		radius = distances[(int) Math.round((double) (percentil * n * n) / 100)];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (net.getDistance(data.get(i), data.get(j)) <= radius) {
					nn[i]++;
				}
			}
		}
		Arrays.sort(nn);
		int currentMedian = nn[n / 2] - 1; // point himself is no real neighbour, but always
		// nearest point
		if (Math.abs(currentMedian - optimalMedian) <= percentilSetDifference) {
			percentilSetDifference = Math.abs(currentMedian - optimalMedian);
		} else {
			estimatedRadius = radius;
			break;
		}
	}
	// generating P Matrix
	double[][] pMatrix = new double[dimensions[0]][dimensions[1]];
	for (int i = 0; i < dimensions[0]; i++) {
		for (int j = 0; j < dimensions[1]; j++) {
			double nodeWeight[] = net.getNodeWeights(new int[] { i, j });
			int neighbours = 0;
			for (int x = 0; x < n; x++) {
				if (net.getDistance(data.get(x), nodeWeight) < estimatedRadius) {
					neighbours++;
				}
			}
			pMatrix[i][j] = (double) neighbours / n;
		}
	}
	return pMatrix;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:53,代码来源:SOMPlotter.java

示例8: doWork

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
@Override
public void doWork() throws OperatorException {
	ExampleSet exampleSet = exampleSetInput.getData(ExampleSet.class);

	// Get and check parameter values
	int trainingRounds = getParameterAsInt(PARAMETER_TRAINING_ROUNDS);
	int netSize = getParameterAsInt(PARAMETER_NET_SIZE);
	int dimensions = getParameterAsInt(PARAMETER_NUMBER_OF_DIMENSIONS);
	double learningRateStart = getParameterAsDouble(PARAMETER_LEARNING_RATE_START);
	double learningRateEnd = getParameterAsDouble(PARAMETER_LEARNING_RATE_END);
	double adaptionRadiusStart = getParameterAsDouble(PARAMETER_ADAPTION_RADIUS_START);
	double adaptionRadiusEnd = getParameterAsDouble(PARAMETER_ADAPTION_RADIUS_END);

	// check for too big parameter values
	double numOfNodes = Math.pow(netSize, dimensions);
	if (numOfNodes > Integer.MAX_VALUE) {
		throw new UserError(this, USER_ERROR_TOO_HIGH_PARAMETER_VALUES);
	}

	// checking sanity of parameter values
	if (learningRateStart < learningRateEnd) {
		throw new UserError(this, 116, "learning_rate_start",
				"Learning rate at first round must be greater than in last round: (" + learningRateEnd + ")");
	}
	if (adaptionRadiusStart < adaptionRadiusEnd) {
		throw new UserError(this, 116, "adaption_radius_start",
				"Adaption radius at first round must be greater than in last round: (" + adaptionRadiusEnd + ")");
	}

	// train SOM
	KohonenNet net = prepareSOM(exampleSet, dimensions, netSize, trainingRounds, learningRateStart, learningRateEnd,
			adaptionRadiusStart, adaptionRadiusEnd);

	SOMDimensionalityReductionModel model = new SOMDimensionalityReductionModel(exampleSet, net, dimensions);

	if (exampleSetOutput.isConnected()) {
		exampleSetOutput.deliver(model.apply((ExampleSet) exampleSet.clone()));
	}
	originalOutput.deliver(exampleSet);
	modelOutput.deliver(model);
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:42,代码来源:SOMDimensionalityReduction.java

示例9: prepareSOM

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
public void prepareSOM(DataTable dataTable, double adaptationRadius, int trainRounds, boolean threadMode) {
	// reseting Data already applied flag
	examplesApplied = false;
	// generating data for SOM
	int dataDimension = 0;
	synchronized (dataTable) {
		Iterator iterator = dataTable.iterator();
		dataDimension = dataTable.getNumberOfColumns() - dataTable.getNumberOfSpecialColumns();

		iterator = dataTable.iterator();
		while (iterator.hasNext()) {
			data.addData(getDoubleArrayFromRow((DataTableRow) iterator.next(), dataTable));
		}
	}
	// generating SOM
	net = new KohonenNet(data);
	RitterAdaptation adaptationFunction = new RitterAdaptation();
	adaptationFunction.setAdaptationRadiusStart(adaptationRadius);
	adaptationFunction.setLearnRateStart(0.8);
	net.setAdaptationFunction(adaptationFunction);
	net.init(dataDimension, dimensions, false);

	net.setTrainingRounds(trainRounds);

	// train SOM
	if (threadMode) {
		// registering this as ProgressListener
		net.addProgressListener(this);
		Thread trainThread = new Thread() {
			@Override
			public void run() {
				net.train();
			}
		};			
		trainThread.start();
	} else {
		net.train();
		createMatrices();
		try {
			// necessary for preventing graphical errors in reporting
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// do nothing
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:47,代码来源:SOMPlotter.java

示例10: getPMatrix

import com.rapidminer.tools.math.som.KohonenNet; //导入依赖的package包/类
private double[][] getPMatrix(KohonenNet net, RandomDataContainer data, int[] dimensions) {
	// calculating real paretoradius
	int n = data.countData();
	double optimalMedian = 0.2013 * n;
	double estimatedRadius = 0;
	// calculating distances between every example
	double[] distances = new double[n * n];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			distances[i * n + j] = net.getDistance(data.get(i), data.get(j));
		}
	}
	Arrays.sort(distances);
	double percentilSetDifference = Double.POSITIVE_INFINITY;
	// finding percentil, closest to paretoradius
	double radius;
	for (int percentil = 0; percentil < 100; percentil++) {
		int[] nn = new int[n];
		radius = distances[(int) Math.round(((double) (percentil * n * n)) / 100)];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (net.getDistance(data.get(i), data.get(j)) <= radius) {
					nn[i]++;
				}
			}
		}
		Arrays.sort(nn);
		int currentMedian = nn[n / 2] - 1; //point himself is no real neighbour, but always nearest point
		if (Math.abs(currentMedian - optimalMedian) <= percentilSetDifference) {
			percentilSetDifference = Math.abs(currentMedian - optimalMedian);
		} else {
			estimatedRadius = radius;
			break;
		}
	}
	// generating P Matrix
	double[][] pMatrix = new double[dimensions[0]][dimensions[1]];
	for (int i = 0; i < dimensions[0]; i++) {
		for (int j = 0; j < dimensions[1]; j++) {
			double nodeWeight[] = net.getNodeWeights(new int[] { i, j });
			int neighbours = 0;
			for (int x = 0; x < n; x++) {
				if (net.getDistance(data.get(x), nodeWeight) < estimatedRadius) {
					neighbours++;
				}
			}
			pMatrix[i][j] = ((double) neighbours) / n;
		}
	}
	return pMatrix;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:52,代码来源:SOMPlotter.java


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