/** Creates a default EM */ public Clusterer getClusterer() { return new EM(); }
System.out.println("Seed: " + getSeed()); m_rr = new Random(getSeed()); + "\nNumber of atts: " + m_num_attribs + "\n"); startExecutorPool(); CVClusters(); m_rr = new Random(getSeed()); for (int i = 0; i < 10; i++) { m_rr.nextDouble(); EM_Init(m_theInstances); double loglikely = iterate(m_theInstances, m_verbose); if (m_Debug) { System.err.println("Current log-likelihood: " + loglikely);
EM_Report(inst); int seed = getSeed(); int restartCount = 0; m_iterationsPerformed = -1; llkold = llk; llk = launchESteps(inst); launchMSteps(inst); restartCount = 0; EM_Init(m_theInstances); startExecutorPool(); EM_Report(inst);
/** * Main method for testing this class. * * @param argv should contain the following arguments: * <p> * -t training file [-T test file] [-N number of clusters] [-S random * seed] */ public static void main(String[] argv) { runClusterer(new EM(), argv); } }
EM clusterer = new EM(); clusterer.buildClusterer(dataClusterer);
resetOptions(); setDebug(Utils.getFlag('V', options)); String optionString = Utils.getOption('I', options); setMaxIterations(Integer.parseInt(optionString)); setNumFolds(Integer.parseInt(optionString)); setMinLogLikelihoodImprovementIterating(Double.parseDouble(optionString)); setMinLogLikelihoodImprovementCV(Double.parseDouble(optionString)); setNumClusters(Integer.parseInt(optionString)); setMaximumNumberOfClusters(Integer.parseInt(optionString)); setMinStdDev((new Double(optionString)).doubleValue()); setNumKMeansRuns((new Integer(optionString)).intValue()); setDisplayModelInOldFormat(Utils.getFlag('O', options)); setNumExecutionSlots(Integer.parseInt(slotsS));
EM clusterer = new EM(); try { clusterer.setNumClusters(clusters); System.out.println("clustering"); clusterer.buildClusterer(transposed); childrenLabels[clusterer.clusterInstance(transposed.instance(i))].add(labels.get(i));
/** * 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; }
M(inst); return; new_estimators(); estimate_priors(inst); M_reEstimate(inst);
int seed = getSeed(); int restartCount = 0; CLUSTER_SEARCH: while (CVincreased) { cvr = new Random(getSeed()); trainCopy = new Instances(m_theInstances); trainCopy.randomize(cvr); EM_Init(cvTrain); try { iterate(cvTrain, false); } catch (Exception ex) { tll = E(cvTest, false); } catch (Exception ex) { seed = getSeed(); templl /= numFolds;
/** * The M step of the EM algorithm. * * @param inst the training instances * @throws Exception if something goes wrong */ private void M(Instances inst) throws Exception { int i, j, l; new_estimators(); estimate_priors(inst); // sum for (l = 0; l < inst.numInstances(); l++) { Instance in = inst.instance(l); for (i = 0; i < m_num_clusters; i++) { for (j = 0; j < m_num_attribs; j++) { if (inst.attribute(j).isNominal()) { m_model[i][j] .addValue(in.value(j), in.weight() * m_weights[l][i]); } else { m_modelNormal[i][j][0] += (in.value(j) * in.weight() * m_weights[l][i]); m_modelNormal[i][j][2] += in.weight() * m_weights[l][i]; m_modelNormal[i][j][1] += (in.value(j) * in.value(j) * in.weight() * m_weights[l][i]); } } } } // re-estimate Gaussian parameters M_reEstimate(inst); }
return E(inst, true);
resetOptions(); setDebug(Utils.getFlag('V', options)); String optionString = Utils.getOption('I', options); setMaxIterations(Integer.parseInt(optionString)); setNumFolds(Integer.parseInt(optionString)); setMinLogLikelihoodImprovementIterating(Double.parseDouble(optionString)); setMinLogLikelihoodImprovementCV(Double.parseDouble(optionString)); setNumClusters(Integer.parseInt(optionString)); setMaximumNumberOfClusters(Integer.parseInt(optionString)); setMinStdDev((new Double(optionString)).doubleValue()); setNumKMeansRuns((new Integer(optionString)).intValue()); setDisplayModelInOldFormat(Utils.getFlag('O', options)); setNumExecutionSlots(Integer.parseInt(slotsS));
/** * Main method for testing this class. * * @param argv should contain the following arguments: * <p> * -t training file [-T test file] [-N number of clusters] [-S random * seed] */ public static void main(String[] argv) { runClusterer(new EM(), argv); } }
/** * 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; }
// generate data for clusterer (w/o class) Remove filter = new Remove(); filter.setAttributeIndices("" + (data.classIndex() + 1)); try { filter.setInputFormat(data); } catch (Exception e) { e.printStackTrace(); } Instances dataClusterer = Filter.useFilter(data, filter); // train clusterer EM clusterer = new EM(); // set further options for EM, if necessary... // clusterer.setNumClusters(maxNumofClusters); //-1 for n number of clusters clusterer.buildClusterer(dataClusterer);
M(inst); return; new_estimators(); estimate_priors(inst); M_reEstimate(inst);
int seed = getSeed(); int restartCount = 0; CLUSTER_SEARCH: while (CVincreased) { cvr = new Random(getSeed()); trainCopy = new Instances(m_theInstances); trainCopy.randomize(cvr); EM_Init(cvTrain); try { iterate(cvTrain, false); } catch (Exception ex) { tll = E(cvTest, false); } catch (Exception ex) { seed = getSeed(); templl /= numFolds;
/** * The M step of the EM algorithm. * * @param inst the training instances * @throws Exception if something goes wrong */ private void M(Instances inst) throws Exception { int i, j, l; new_estimators(); estimate_priors(inst); // sum for (l = 0; l < inst.numInstances(); l++) { Instance in = inst.instance(l); for (i = 0; i < m_num_clusters; i++) { for (j = 0; j < m_num_attribs; j++) { if (inst.attribute(j).isNominal()) { m_model[i][j] .addValue(in.value(j), in.weight() * m_weights[l][i]); } else { m_modelNormal[i][j][0] += (in.value(j) * in.weight() * m_weights[l][i]); m_modelNormal[i][j][2] += in.weight() * m_weights[l][i]; m_modelNormal[i][j][1] += (in.value(j) * in.value(j) * in.weight() * m_weights[l][i]); } } } } // re-estimate Gaussian parameters M_reEstimate(inst); }
return E(inst, true);