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


Java EM类代码示例

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


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

示例1: sortAndpPrintCluster

import weka.clusterers.EM; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private HashMap<Integer, Integer> sortAndpPrintCluster(EM clusterer) {
    List<double[]> vals = new ArrayList<double[]>(clusterer.getNumClusters());
    for (int c = 0; c < clusterer.getNumClusters(); c++) {
        vals.add(new double[]{clusterer.getClusterModelsNumericAtts()[c][0][0],   // mean
                clusterer.getClusterModelsNumericAtts()[c][0][1],  // var
                clusterer.getClusterModelsNumericAtts()[c][0][2], // prior
                clusterer.getClusterPriors()[c], // priors normalized
                c // cluster number
        });
    }
    Collections.sort(vals, new Comparator() {
        public int compare(Object o1, Object o2) {
            double[] d1 = (double[]) o1;
            double[] d2 = (double[]) o2;
            return (int) Math.signum(d1[0] - d2[0]);
        }
    });
    for (int c = 0; c < vals.size(); c++) {
        logger.trace("Cluster " + c + ":" + vals.get(c)[0] + " Var:" + vals.get(c)[1] + " Z:" + vals.get(c)[2] + " Prior:" + vals.get(c)[3] + " Cluster:" + vals.get(c)[4]);
    }
    return mergeClusters(vals);
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:24,代码来源:TMAPoints.java

示例2: guessNumClusters

import weka.clusterers.EM; //导入依赖的package包/类
private int guessNumClusters(EM clusterer, Instances instances, int start, int end) throws Exception {
    ClusterEvaluation eval = new ClusterEvaluation();
    int bestNum = start;
    double best = Double.POSITIVE_INFINITY;
    double bic;
    for (int c = start; c <= end; c++) {
        clusterer.setNumClusters(c);
        clusterer.buildClusterer(instances);
        eval.setClusterer(clusterer);
        eval.evaluateClusterer(instances);
        bic = bic(eval.getLogLikelihood(), c, instances.numInstances());
        logger.trace("numCluster " + c + " -> BIC: " + bic);
        if (bic < best) {
            best = bic;
            bestNum = c;
            logger.trace("bestNum: " + bestNum);
        }
    }
    return bestNum;
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:21,代码来源:TMAPoints.java

示例3: main

import weka.clusterers.EM; //导入依赖的package包/类
public static void main(String args[]) throws Exception{
	
	//load data
	Instances data = new Instances(new BufferedReader(new FileReader("data/bank-data.arff")));
	
	// new instance of clusterer
	EM model = new EM();
	// build the clusterer
	model.buildClusterer(data);
	System.out.println(model);
	
	double logLikelihood = ClusterEvaluation.crossValidateModel(model, data, 10, new Random(1));
	System.out.println(logLikelihood);


}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:17,代码来源:ClusteringTask.java

示例4: createClusterer

import weka.clusterers.EM; //导入依赖的package包/类
/**
     * 
     * @param trainingData
     * @param round
     * @throws Exception
     */
    protected AbstractClusterer createClusterer(MarkovAttributeSet aset, Instances trainingData) throws Exception {
        if (trace.val) LOG.trace(String.format("Clustering %d %s instances with %d attributes", trainingData.numInstances(), CatalogUtil.getDisplayName(catalog_proc), aset.size()));
        
        // Create the filter we need so that we only include the attributes in the given MarkovAttributeSet
        Filter filter = aset.createFilter(trainingData);
        
        // Using our training set to build the clusterer
        int seed = this.rand.nextInt(); 
//        SimpleKMeans inner_clusterer = new SimpleKMeans();
        EM inner_clusterer = new EM();
        String options[] = {
            "-N", Integer.toString(1000), // num_partitions),
            "-S", Integer.toString(seed),
            "-I", Integer.toString(100),
            
        };
        inner_clusterer.setOptions(options);
        
        FilteredClusterer filtered_clusterer = new FilteredClusterer();
        filtered_clusterer.setFilter(filter);
        filtered_clusterer.setClusterer(inner_clusterer);
        
        AbstractClusterer clusterer = filtered_clusterer;
        clusterer.buildClusterer(trainingData);
        
        return (clusterer);
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:34,代码来源:FeatureClusterer.java

示例5: generateClassToCluster

import weka.clusterers.EM; //导入依赖的package包/类
public void generateClassToCluster(){
	Remove filter = new Remove();
	filter.setAttributeIndices("" + (weather.classIndex() + 1));
	try {
		filter.setInputFormat(weather);
		Instances dataClusterer = Filter.useFilter(weather, filter);
		clusterer = new EM();
		clusterer.buildClusterer(dataClusterer);
		ClusterEvaluation eval = new ClusterEvaluation();
		eval.setClusterer(clusterer);
		eval.evaluateClusterer(weather);

		System.out.println(eval.clusterResultsToString());
	} catch (Exception e) {
	}
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:17,代码来源:WekaClassesToClusterTest.java

示例6: performClustering

import weka.clusterers.EM; //导入依赖的package包/类
@Override
   public ClusteringResult performClustering(Instances dataset,
    ParameterSet parameters) {

List<Integer> clusters = new ArrayList<Integer>();
String[] options = new String[2];
EM clusterer = new EM();

int numberOfIterations = parameters.getParameter(
	EMClustererParameters.numberOfIterations).getValue();
options[0] = "-I";
options[1] = String.valueOf(numberOfIterations);

try {
    clusterer.setOptions(options);
    clusterer.buildClusterer(dataset);
    Enumeration<?> e = dataset.enumerateInstances();
    while (e.hasMoreElements()) {
	clusters.add(clusterer.clusterInstance((Instance) e
		.nextElement()));
    }
    ClusteringResult result = new ClusteringResult(clusters, null,
	    clusterer.numberOfClusters(), parameters.getParameter(
		    EMClustererParameters.visualization).getValue());
    return result;

} catch (Exception ex) {
    logger.log(Level.SEVERE, null, ex);
    return null;
}
   }
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:32,代码来源:EMClusterer.java

示例7: getClusterer

import weka.clusterers.EM; //导入依赖的package包/类
/**
 * returns a configured cluster algorithm
 */
protected Clusterer getClusterer() {
  EM c = new EM();
  try {
    c.setOptions(new String[0]);
  }
  catch (Exception e) {
    e.printStackTrace();
  }
  return c;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:14,代码来源:AddClusterTest.java

示例8: clusterSubPopulations

import weka.clusterers.EM; //导入依赖的package包/类
/**
 * Clustering dispatcher
 * @requires the number of SNVs in a group to be bigger than 1
 * @param group - SNV group to cluster based on AAF data
 * @param alg - algorithm to use for clustering
 */
public Cluster[] clusterSubPopulations(SNVGroup group, ClusteringAlgorithms alg, int minNumClusters) {		
	switch(alg) {
	case FUZZYCMEANS:
		return fuzzyCMeans(group.getAlleleFreqBySample(), group.getNumSNVs(), 
				group.getNumSamples(), minNumClusters, 
				AAFClusterer.DEFAULT_FUZZIFIER, DistanceMetric.EUCLIDEAN);
	case KMEANS:
		return kmeans(group.getAlleleFreqBySample(), group.getNumSNVs(), group.getNumSamples(), minNumClusters);
	case EM:
		return em(group.getAlleleFreqBySample(), group.getNumSNVs(), group.getNumSamples());
	default:
		return null;	
	}
}
 
开发者ID:viq854,项目名称:lichee,代码行数:21,代码来源:AAFClusterer.java


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