本文整理汇总了Java中weka.clusterers.Clusterer类的典型用法代码示例。如果您正苦于以下问题:Java Clusterer类的具体用法?Java Clusterer怎么用?Java Clusterer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Clusterer类属于weka.clusterers包,在下文中一共展示了Clusterer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getFinalizedClusterer
import weka.clusterers.Clusterer; //导入依赖的package包/类
public Clusterer getFinalizedClusterer() throws DistributedWekaException {
if (m_canopy == null) {
throw new DistributedWekaException(
"CanopyMapTask has not been initialized yet!");
}
if (!m_finalized) {
throw new DistributedWekaException(
"This map task has note been finalized yet!");
}
if (m_finalFullPreprocess == null) {
return m_canopy;
}
PreconstructedFilteredClusterer fc = new PreconstructedFilteredClusterer();
fc.setFilter((Filter) m_finalFullPreprocess);
fc.setClusterer(m_canopy);
return fc;
}
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:22,代码来源:CanopyMapTask.java
示例2: makeFinalClusterer
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Make the final PreconstructedKMeans clusterer to wrap the centroids and
* stats found during map-reduce.
*
* @param best the best result from the runs of k-means that were performed in
* parallel
* @param preprocess any pre-processing filters applied
* @param initialStartingPoints the initial starting centroids
* @param finalNumIterations the final number of iterations performed
* @return a final clusterer object
* @throws DistributedWekaException if a problem occurs
*/
protected Clusterer makeFinalClusterer(KMeansReduceTask best,
Filter preprocess, Instances initialStartingPoints, int finalNumIterations)
throws DistributedWekaException {
Clusterer finalClusterer = null;
PreconstructedKMeans finalKMeans = new PreconstructedKMeans();
// global priming data for the distance function (this will be in
// the transformed space if we're using preprocessing filters)
Instances globalPrimingData = best.getGlobalDistanceFunctionPrimingData();
NormalizableDistance dist = new EuclideanDistance();
dist.setInstances(globalPrimingData);
finalKMeans.setClusterCentroids(best.getCentroidsForRun());
finalKMeans.setFinalNumberOfIterations(finalNumIterations + 1);
if (initialStartingPoints != null) {
finalKMeans.setInitialStartingPoints(initialStartingPoints);
}
try {
finalKMeans.setDistanceFunction(dist);
finalKMeans.setClusterStats(best.getAggregatedCentroidSummaries());
} catch (Exception e) {
throw new DistributedWekaException(e);
}
if (!getInitWithRandomCentroids()) {
finalKMeans.setInitializationMethod(new SelectedTag(
SimpleKMeans.KMEANS_PLUS_PLUS, SimpleKMeans.TAGS_SELECTION));
}
finalKMeans.setDisplayStdDevs(getDisplayCentroidStdDevs());
finalClusterer = finalKMeans;
if (preprocess != null) {
PreconstructedFilteredClusterer fc =
new PreconstructedFilteredClusterer();
fc.setFilter(preprocess);
fc.setClusterer(finalKMeans);
finalClusterer = fc;
}
return finalClusterer;
}
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:55,代码来源:KMeansClustererHadoopJob.java
示例3: createScorer
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Static factory method to create an appropriate concrete ScoringModel
* given a particular base model
*
* @param model the model to wrap in a ScoringModel
* @return a concrete subclass of ScoringModel
* @throws Exception if a problem occurs
*/
public static ScoringModel createScorer(Object model) throws Exception {
if (model instanceof Classifier) {
return new ClassifierScoringModel(model);
} else if (model instanceof Clusterer) {
return new ClustererScoringModel(model);
}
return null;
}
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:17,代码来源:WekaScoringMapTask.java
示例4: BatchClustererEvent
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Creates a new <code>BatchClustererEvent</code> instance.
*
* @param source the source object
* @param scheme a Clusterer
* @param tstI the training/test instances
* @param setNum the set number of the training/testinstances
* @param maxSetNum the last set number in the series
* @param testOrTrain 0 if the set is a test set, >0 if it is a training set
*/
public BatchClustererEvent(Object source, Clusterer scheme, DataSetEvent tstI, int setNum, int maxSetNum, int testOrTrain) {
super(source);
// m_trainingSet = trnI;
m_clusterer = scheme;
m_testSet = tstI;
m_setNumber = setNum;
m_maxSetNumber = maxSetNum;
if(testOrTrain == 0)
m_testOrTrain = TEST;
else
m_testOrTrain = TRAINING;
}
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:23,代码来源:BatchClustererEvent.java
示例5: getClustererSpec
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Gets the clusterer specification string, which contains the class name of
* the clusterer and any options to the clusterer.
*
* @return the clusterer string.
*/
protected String getClustererSpec() {
Clusterer c = getClusterer();
if (c instanceof OptionHandler) {
return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler) c).getOptions());
}
return c.getClass().getName();
}
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:15,代码来源:AddCluster.java
示例6: getClustererSpec
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Gets the clusterer specification string, which contains the class name of
* the clusterer and any options to the clusterer.
*
* @return the clusterer string.
*/
protected String getClustererSpec() {
Clusterer c = getClusterer();
if (c instanceof OptionHandler) {
return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
}
return c.getClass().getName();
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:15,代码来源:AddCluster.java
示例7: getClusterer
import weka.clusterers.Clusterer; //导入依赖的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: getClustererSpec
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Gets the clusterer specification string, which contains the class name of
* the clusterer and any options to the clusterer.
*
* @return the clusterer string.
*/
protected String getClustererSpec() {
Clusterer c = getClusterer();
if (c instanceof OptionHandler) {
return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
}
return c.getClass().getName();
}
开发者ID:williamClanton,项目名称:jbossBA,代码行数:16,代码来源:AddCluster.java
示例9: createScorer
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Static factory method to create an instance of an appropriate subclass of
* WekaScoringModel given a Weka model.
*
* @param model a Weka model
* @return an appropriate WekaScoringModel for this type of Weka model
* @exception Exception if an error occurs
*/
public static WekaScoringModel createScorer(Object model) throws Exception {
if (model instanceof Classifier) {
return new WekaScoringClassifier(model);
} else if (model instanceof Clusterer) {
return new WekaScoringClusterer(model);
}
return null;
}
开发者ID:pentaho,项目名称:pdi-weka-scoring-plugin,代码行数:17,代码来源:WekaScoringModel.java
示例10: ClassifierWrapper
import weka.clusterers.Clusterer; //导入依赖的package包/类
public ClassifierWrapper(Clusterer clusterer) {
this.clusterer = clusterer;
this.wrapperType = WRAPPERTYPE_CLUSTERER;
}
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:5,代码来源:ClassifierWrapper.java
示例11: getClusterer
import weka.clusterers.Clusterer; //导入依赖的package包/类
public Clusterer getClusterer() {
return clusterer;
}
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:4,代码来源:ClassifierWrapper.java
示例12: setClusterer
import weka.clusterers.Clusterer; //导入依赖的package包/类
public void setClusterer(Clusterer clusterer) {
this.clusterer = clusterer;
this.wrapperType = WRAPPERTYPE_CLUSTERER;
}
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:5,代码来源:ClassifierWrapper.java
示例13: getClusterer
import weka.clusterers.Clusterer; //导入依赖的package包/类
@Override
public Clusterer getClusterer() {
return m_finalClusterer;
}
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:5,代码来源:KMeansClustererHadoopJob.java
示例14: setModel
import weka.clusterers.Clusterer; //导入依赖的package包/类
@Override
public void setModel(Object model) {
m_model = (Clusterer) model;
}
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:6,代码来源:WekaScoringMapTask.java
示例15: saveClusterer
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Saves the currently selected clusterer
*/
protected void saveClusterer(String name, Clusterer clusterer,
Instances trainHeader, int[] ignoredAtts) {
File sFile = null;
boolean saveOK = true;
int returnVal = m_FileChooser.showSaveDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
sFile = m_FileChooser.getSelectedFile();
if (!sFile.getName().toLowerCase().endsWith(MODEL_FILE_EXTENSION)) {
sFile = new File(sFile.getParent(), sFile.getName()
+ MODEL_FILE_EXTENSION);
}
m_Log.statusMessage("Saving model to file...");
try {
OutputStream os = new FileOutputStream(sFile);
if (sFile.getName().endsWith(".gz")) {
os = new GZIPOutputStream(os);
}
ObjectOutputStream objectOutputStream = new ObjectOutputStream(os);
objectOutputStream.writeObject(clusterer);
if (trainHeader != null) {
objectOutputStream.writeObject(trainHeader);
}
if (ignoredAtts != null) {
objectOutputStream.writeObject(ignoredAtts);
}
objectOutputStream.flush();
objectOutputStream.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Save Failed",
JOptionPane.ERROR_MESSAGE);
saveOK = false;
}
if (saveOK) {
m_Log.logMessage("Saved model (" + name + ") to file '"
+ sFile.getName() + "'");
}
m_Log.statusMessage("OK");
}
}
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:47,代码来源:ClustererPanel.java
示例16: batchFinished
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Signify that this batch of input to the filter is finished.
*
* @return true if there are instances pending output
* @throws IllegalStateException if no input structure has been defined
*/
@Override
public boolean batchFinished() throws Exception {
if (getInputFormat() == null) {
throw new IllegalStateException("No input instance format defined");
}
Instances toFilter = getInputFormat();
if (!isFirstBatchDone()) {
// filter out attributes if necessary
Instances toFilterIgnoringAttributes = removeIgnored(toFilter);
// serialized model or build clusterer from scratch?
File file = getSerializedClustererFile();
if (!file.isDirectory()) {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
m_ActualClusterer = (Clusterer) ois.readObject();
Instances header = null;
// let's see whether there's an Instances header stored as well
try {
header = (Instances) ois.readObject();
} catch (Exception e) {
// ignored
}
ois.close();
// same dataset format?
if ((header != null)
&& (!header.equalHeaders(toFilterIgnoringAttributes))) {
throw new WekaException(
"Training header of clusterer and filter dataset don't match:\n"
+ header.equalHeadersMsg(toFilterIgnoringAttributes));
}
} else {
m_ActualClusterer = AbstractClusterer.makeCopy(m_Clusterer);
m_ActualClusterer.buildClusterer(toFilterIgnoringAttributes);
}
// create output dataset with new attribute
Instances filtered = new Instances(toFilter, 0);
ArrayList<String> nominal_values = new ArrayList<String>(
m_ActualClusterer.numberOfClusters());
for (int i = 0; i < m_ActualClusterer.numberOfClusters(); i++) {
nominal_values.add("cluster" + (i + 1));
}
filtered.insertAttributeAt(new Attribute("cluster", nominal_values),
filtered.numAttributes());
setOutputFormat(filtered);
}
// build new dataset
for (int i = 0; i < toFilter.numInstances(); i++) {
convertInstance(toFilter.instance(i));
}
flushInput();
m_NewBatch = true;
m_FirstBatchDone = true;
return (numPendingOutput() != 0);
}
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:68,代码来源:AddCluster.java
示例17: saveClusterer
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Saves the currently selected clusterer
*/
protected void saveClusterer(String name, Clusterer clusterer,
Instances trainHeader, int[] ignoredAtts) {
File sFile = null;
boolean saveOK = true;
int returnVal = m_FileChooser.showSaveDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
sFile = m_FileChooser.getSelectedFile();
if (!sFile.getName().toLowerCase().endsWith(MODEL_FILE_EXTENSION)) {
sFile = new File(sFile.getParent(), sFile.getName()
+ MODEL_FILE_EXTENSION);
}
m_Log.statusMessage("Saving model to file...");
try {
OutputStream os = new FileOutputStream(sFile);
if (sFile.getName().endsWith(".gz")) {
os = new GZIPOutputStream(os);
}
ObjectOutputStream objectOutputStream = new ObjectOutputStream(os);
objectOutputStream.writeObject(clusterer);
if (trainHeader != null)
objectOutputStream.writeObject(trainHeader);
if (ignoredAtts != null)
objectOutputStream.writeObject(ignoredAtts);
objectOutputStream.flush();
objectOutputStream.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Save Failed",
JOptionPane.ERROR_MESSAGE);
saveOK = false;
}
if (saveOK)
m_Log.logMessage("Saved model (" + name + ") to file '"
+ sFile.getName() + "'");
m_Log.statusMessage("OK");
}
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:44,代码来源:ClustererPanel.java
示例18: updateCapabilitiesFilter
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* updates the capabilities filter of the GOE
*
* @param filter the new filter to use
*/
protected void updateCapabilitiesFilter(Capabilities filter) {
Instances tempInst;
Capabilities filterClass;
if (filter == null) {
m_ClustererEditor.setCapabilitiesFilter(new Capabilities(null));
return;
}
if (!ExplorerDefaults.getInitGenericObjectEditorFilter())
tempInst = new Instances(m_Instances, 0);
else
tempInst = new Instances(m_Instances);
tempInst.setClassIndex(-1);
if (!m_ignoreKeyList.isSelectionEmpty()) {
tempInst = removeIgnoreCols(tempInst);
}
try {
filterClass = Capabilities.forInstances(tempInst);
} catch (Exception e) {
filterClass = new Capabilities(null);
}
m_ClustererEditor.setCapabilitiesFilter(filterClass);
// check capabilities
m_StartBut.setEnabled(true);
Capabilities currentFilter = m_ClustererEditor.getCapabilitiesFilter();
Clusterer clusterer = (Clusterer) m_ClustererEditor.getValue();
Capabilities currentSchemeCapabilities = null;
if (clusterer != null && currentFilter != null
&& (clusterer instanceof CapabilitiesHandler)) {
currentSchemeCapabilities = ((CapabilitiesHandler) clusterer)
.getCapabilities();
if (!currentSchemeCapabilities.supportsMaybe(currentFilter)
&& !currentSchemeCapabilities.supports(currentFilter)) {
m_StartBut.setEnabled(false);
}
}
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:49,代码来源:ClustererPanel.java
示例19: batchFinished
import weka.clusterers.Clusterer; //导入依赖的package包/类
/**
* Signify that this batch of input to the filter is finished.
*
* @return true if there are instances pending output
* @throws IllegalStateException if no input structure has been defined
*/
public boolean batchFinished() throws Exception {
if (getInputFormat() == null)
throw new IllegalStateException("No input instance format defined");
Instances toFilter = getInputFormat();
if (!isFirstBatchDone()) {
// filter out attributes if necessary
Instances toFilterIgnoringAttributes = removeIgnored(toFilter);
// serialized model or build clusterer from scratch?
File file = getSerializedClustererFile();
if (!file.isDirectory()) {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
m_ActualClusterer = (Clusterer) ois.readObject();
Instances header = null;
// let's see whether there's an Instances header stored as well
try {
header = (Instances) ois.readObject();
}
catch (Exception e) {
// ignored
}
ois.close();
// same dataset format?
if ((header != null) && (!header.equalHeaders(toFilterIgnoringAttributes)))
throw new WekaException(
"Training header of clusterer and filter dataset don't match:\n"
+ header.equalHeadersMsg(toFilterIgnoringAttributes));
}
else {
m_ActualClusterer = AbstractClusterer.makeCopy(m_Clusterer);
m_ActualClusterer.buildClusterer(toFilterIgnoringAttributes);
}
// create output dataset with new attribute
Instances filtered = new Instances(toFilter, 0);
FastVector nominal_values = new FastVector(m_ActualClusterer.numberOfClusters());
for (int i = 0; i < m_ActualClusterer.numberOfClusters(); i++) {
nominal_values.addElement("cluster" + (i+1));
}
filtered.insertAttributeAt(new Attribute("cluster", nominal_values),
filtered.numAttributes());
setOutputFormat(filtered);
}
// build new dataset
for (int i=0; i<toFilter.numInstances(); i++) {
convertInstance(toFilter.instance(i));
}
flushInput();
m_NewBatch = true;
m_FirstBatchDone = true;
return (numPendingOutput() != 0);
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:65,代码来源:AddCluster.java
示例20: getClusterer
import weka.clusterers.Clusterer; //导入依赖的package包/类
/** Creates a default MakeDensityBasedClusterer */
public Clusterer getClusterer() {
return new MakeDensityBasedClusterer();
}
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:5,代码来源:MakeDensityBasedClustererTest.java
注:本文中的weka.clusterers.Clusterer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论