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


Java Cluster类代码示例

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


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

示例1: calcBIC

import com.rapidminer.operator.clustering.Cluster; //导入依赖的package包/类
/**
 * Calculate the BIC like in the paper by Dan Pelleg and Andrew Moore
 *
 * @param bestModel
 * @return BIC of the given modell
 */
private double calcBIC(CentroidClusterModel bestModel) {
	double loglike = 0;
	int numCenters = bestModel.getNumberOfClusters();
	int numDimensions = bestModel.getCentroidCoordinates(0).length;

	int numParameters = numCenters - 1 + // probabilities
			numCenters * numDimensions + // means
			numCenters; // variance params

	for (Cluster c : bestModel.getClusters()) {
		int current_id = c.getClusterId();
		loglike += logLikelihoodEstimate(c, bestModel.getCentroidCoordinates(current_id),
				bestModel.getClusterAssignments(exampleSet), numCenters);
	}

	loglike -= numParameters / 2.0 * Math.log(examplesize);
	return loglike;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:25,代码来源:XMeansCore.java

示例2: calcBIC

import com.rapidminer.operator.clustering.Cluster; //导入依赖的package包/类
/**
 * Calculate the BIC like in the paper by Dan Pelleg and Andrew Moore
 *
 * @param bestModel
 * @return BIC of the given modell
 * @throws ProcessStoppedException
 */
private double calcBIC(CentroidClusterModel bestModel) throws ProcessStoppedException {
	double loglike = 0;
	int numCenters = bestModel.getNumberOfClusters();
	int numDimensions = bestModel.getCentroidCoordinates(0).length;

	int numParameters = numCenters - 1 + // probabilities
			numCenters * numDimensions + // means
			numCenters; // variance params

	for (Cluster c : bestModel.getClusters()) {
		int current_id = c.getClusterId();
		loglike += logLikelihoodEstimate(c, bestModel.getCentroidCoordinates(current_id), numCenters);
	}

	loglike -= numParameters / 2.0 * Math.log(examplesize);
	return loglike;
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:25,代码来源:XMeansCore.java

示例3: calcBIC

import com.rapidminer.operator.clustering.Cluster; //导入依赖的package包/类
/**
 * Calculate the BIC like in the paper by Dan Pelleg and Andrew Moore
 * 
 * @param bestModel
 * @return BIC of the given modell
 */
private double calcBIC(CentroidClusterModel bestModel) {
	double loglike = 0;
	int numCenters = bestModel.getNumberOfClusters();
	int numDimensions = bestModel.getCentroidCoordinates(0).length;

	int numParameters = (numCenters - 1) + // probabilities
			numCenters * numDimensions + // means
			numCenters; // variance params

	for (Cluster c : bestModel.getClusters()) {
		int current_id = c.getClusterId();
		loglike += logLikelihoodEstimate(c,
				bestModel.getCentroidCoordinates(current_id),
				bestModel.getClusterAssignments(exampleSet), numCenters);
	}

	loglike -= (numParameters / 2.0) * Math.log(examplesize);
	return loglike;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:26,代码来源:XMeansCore.java

示例4: logLikelihoodEstimate

import com.rapidminer.operator.clustering.Cluster; //导入依赖的package包/类
private double logLikelihoodEstimate(Cluster c, double[] centroid, int[] as, int K) {
	double l = 0;
	double R = examplesize;
	double Rn = c.getNumberOfExamples();
	double M = dimension;
	double d = 0;
	double[] values = new double[attributes.size()];

	if (Rn > 1) {
		double sum = 0;

		final Attribute idAttribute = exampleSet.getAttributes().getId();
		boolean idIsNominal = idAttribute.isNominal();
		exampleSet.remapIds();
		for (Object ob : c.getExampleIds()) {
			Example example;
			if (idIsNominal) {
				example = exampleSet.getExampleFromId(idAttribute.getMapping().mapString((String) ob));
			} else {
				example = exampleSet.getExampleFromId(((Double) ob).intValue());
			}
			if (example == null) {
				throw new RuntimeException("Unknown id: " + ob);
			}
			sum += Math.pow(measure.calculateDistance(centroid, getAsDoubleArray(example, attributes, values)), 2);
		}

		d = 1.0 / (Rn - K) * sum;

		l = -(Rn / 2.0) * Math.log(2.0 * Math.PI) - Rn * M / 2.0 * Math.log(d) - (Rn - K) / 2.0 + Rn * Math.log(Rn) - Rn
				* Math.log(R);
	}
	return l;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:35,代码来源:XMeansCore.java

示例5: generateFlatModel

import com.rapidminer.operator.clustering.Cluster; //导入依赖的package包/类
private DefaultMutableTreeNode generateFlatModel(ClusterModel cm) {
	DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("root");
	rootNode.setAllowsChildren(true);
	for (int i = 0; i < cm.getNumberOfClusters(); i++) {
		Cluster cl = cm.getCluster(i);
		DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(cl);
		newNode.setAllowsChildren(true);
		rootNode.add(newNode);
		for (Object exampleId : cl.getExampleIds()) {
			newNode.add(createLeaf(exampleId));
		}
	}
	return rootNode;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:ClusterTreeVisualization.java

示例6: logLikelihoodEstimate

import com.rapidminer.operator.clustering.Cluster; //导入依赖的package包/类
private double logLikelihoodEstimate(Cluster c, double[] centroid, int K) {
	double l = 0;
	double R = examplesize;
	double Rn = c.getNumberOfExamples();
	double M = dimension;
	double d = 0;
	double[] values = new double[attributes.size()];

	if (Rn > 1) {
		double sum = 0;

		final Attribute idAttribute = exampleSet.getAttributes().getId();
		boolean idIsNominal = idAttribute.isNominal();
		exampleSet.remapIds();
		for (Object ob : c.getExampleIds()) {
			Example example;
			if (idIsNominal) {
				example = exampleSet.getExampleFromId(idAttribute.getMapping().mapString((String) ob));
			} else {
				example = exampleSet.getExampleFromId(((Double) ob).intValue());
			}
			if (example == null) {
				throw new RuntimeException("Unknown id: " + ob);
			}
			sum += Math.pow(measure.calculateDistance(centroid, getAsDoubleArray(example, attributes, values)), 2);
		}

		d = 1.0 / (Rn - K) * sum;

		l = -(Rn / 2.0) * Math.log(2.0 * Math.PI) - Rn * M / 2.0 * Math.log(d) - (Rn - K) / 2.0 + Rn * Math.log(Rn)
				- Rn * Math.log(R);
	}
	return l;
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:35,代码来源:XMeansCore.java

示例7: logLikelihoodEstimate

import com.rapidminer.operator.clustering.Cluster; //导入依赖的package包/类
private double logLikelihoodEstimate(Cluster c, double[] centroid,
		int[] as, int K) {
	double l = 0;
	double R = examplesize;
	double Rn = c.getNumberOfExamples();
	double M = dimension;
	double d = 0;
	double[] values = new double[attributes.size()];

	if (Rn > 1) {
		double sum = 0;

		final Attribute idAttribute = exampleSet.getAttributes().getId();
		boolean idIsNominal = idAttribute.isNominal();
		exampleSet.remapIds();
		for (Object ob : c.getExampleIds()) {
			Example example;
			if (idIsNominal) {					
				example = exampleSet.getExampleFromId(idAttribute.getMapping().mapString((String)ob));
			} else {
				example = exampleSet.getExampleFromId(((Double) ob).intValue());
			}
			if (example == null) {
				throw new RuntimeException("Unknown id: "+ob);
			}
			sum += Math.pow((measure.calculateDistance(
					centroid,
					getAsDoubleArray(example, attributes,
							values))), 2);
		}

		d = (1.0 / (Rn - K)) * sum;

		l = -(Rn / 2.0) * Math.log(2.0 * Math.PI) - ((Rn * M) / 2.0)
				* Math.log(d) - (Rn - K) / 2.0 + Rn * Math.log(Rn) - Rn
				* Math.log(R);
	}
	return l;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:40,代码来源:XMeansCore.java

示例8: generateFlatModel

import com.rapidminer.operator.clustering.Cluster; //导入依赖的package包/类
private DefaultMutableTreeNode generateFlatModel(ClusterModel cm) {
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("root");
    rootNode.setAllowsChildren(true);
    for (int i = 0; i < cm.getNumberOfClusters(); i++) {
        Cluster cl = cm.getCluster(i);
        DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(cl);
        newNode.setAllowsChildren(true);
        rootNode.add(newNode);
        for (Object exampleId: cl.getExampleIds()) {
            newNode.add(createLeaf(exampleId));
        }
    }
    return rootNode;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:15,代码来源:ClusterTreeVisualization.java


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