本文整理汇总了Java中weka.core.SelectedTag类的典型用法代码示例。如果您正苦于以下问题:Java SelectedTag类的具体用法?Java SelectedTag怎么用?Java SelectedTag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SelectedTag类属于weka.core包,在下文中一共展示了SelectedTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterPropertiesSet
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Loads the training data as configured in {@link #dataConfig} and trains a
* 3-gram SVM classifier.
*/
@Override
public void afterPropertiesSet() throws Exception {
this.trainingData = svmTrainer.train();
StringToWordVector stwvFilter = createFilter(this.trainingData);
// Instances filterdInstances = Filter.useFilter(data, stwv);
LibSVM svm = new LibSVM();
svm.setKernelType(new SelectedTag(0, LibSVM.TAGS_KERNELTYPE));
svm.setSVMType(new SelectedTag(0, LibSVM.TAGS_SVMTYPE));
svm.setProbabilityEstimates(true);
// svm.buildClassifier(filterdInstances);
FilteredClassifier filteredClassifier = new FilteredClassifier();
filteredClassifier.setFilter(stwvFilter);
filteredClassifier.setClassifier(svm);
filteredClassifier.buildClassifier(this.trainingData);
this.classifier = filteredClassifier;
// predict("nice cool amazing awesome beautiful");
// predict("this movie is simply awesome");
// predict("its very bad");
// predict("Not that great");
}
示例2: setMetricType
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Set the metric type for ranking rules
*
* @param d the type of metric
*/
public void setMetricType(SelectedTag d) {
if (d.getTags() == TAGS_SELECTION) {
m_metricType = d.getSelectedTag().getID();
}
if (m_metricType == CONFIDENCE) {
setMinMetric(0.9);
}
if (m_metricType == LIFT || m_metricType == CONVICTION) {
setMinMetric(1.1);
}
if (m_metricType == LEVERAGE) {
setMinMetric(0.1);
}
}
示例3: setOptions
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Parses a given list of options.
* <p/>
*
* <!-- options-start --> Valid options are:
* <p/>
*
* <pre>
* -mbc
* Applies a Markov Blanket correction to the network structure,
* after a network structure is learned. This ensures that all
* nodes in the network are part of the Markov blanket of the
* classifier node.
* </pre>
*
* <pre>
* -S [BAYES|MDL|ENTROPY|AIC|CROSS_CLASSIC|CROSS_BAYES]
* Score type (BAYES, BDeu, MDL, ENTROPY and AIC)
* </pre>
*
* <!-- options-end -->
*
* @param options the list of options as an array of strings
* @throws Exception if an option is not supported
*/
@Override
public void setOptions(String[] options) throws Exception {
setMarkovBlanketClassifier(Utils.getFlag("mbc", options));
String sScore = Utils.getOption('S', options);
if (sScore.compareTo("BAYES") == 0) {
setScoreType(new SelectedTag(Scoreable.BAYES, TAGS_SCORE_TYPE));
}
if (sScore.compareTo("BDeu") == 0) {
setScoreType(new SelectedTag(Scoreable.BDeu, TAGS_SCORE_TYPE));
}
if (sScore.compareTo("MDL") == 0) {
setScoreType(new SelectedTag(Scoreable.MDL, TAGS_SCORE_TYPE));
}
if (sScore.compareTo("ENTROPY") == 0) {
setScoreType(new SelectedTag(Scoreable.ENTROPY, TAGS_SCORE_TYPE));
}
if (sScore.compareTo("AIC") == 0) {
setScoreType(new SelectedTag(Scoreable.AIC, TAGS_SCORE_TYPE));
}
super.setOptions(options);
}
示例4: initializeSVMProbs
import weka.core.SelectedTag; //导入依赖的package包/类
protected void initializeSVMProbs(Instances data) throws Exception {
m_svmProbs = new SGD();
m_svmProbs.setLossFunction(new SelectedTag(SGD.LOGLOSS, TAGS_SELECTION));
m_svmProbs.setLearningRate(m_learningRate);
m_svmProbs.setLambda(m_lambda);
m_svmProbs.setEpochs(m_epochs);
ArrayList<Attribute> atts = new ArrayList<Attribute>(2);
atts.add(new Attribute("pred"));
ArrayList<String> attVals = new ArrayList<String>(2);
attVals.add(data.classAttribute().value(0));
attVals.add(data.classAttribute().value(1));
atts.add(new Attribute("class", attVals));
m_fitLogisticStructure = new Instances("data", atts, 0);
m_fitLogisticStructure.setClassIndex(1);
m_svmProbs.buildClassifier(m_fitLogisticStructure);
}
示例5: getJavaInitializationString
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Returns a description of the property value as java source.
*
* @return a value of type 'String'
*/
public String getJavaInitializationString() {
SelectedTag s = (SelectedTag)getValue();
Tag [] tags = s.getTags();
String result = "new SelectedTag("
+ s.getSelectedTag().getID()
+ ", {\n";
for (int i = 0; i < tags.length; i++) {
result += "new Tag(" + tags[i].getID()
+ ",\"" + tags[i].getReadable()
+ "\")";
if (i < tags.length - 1) {
result += ',';
}
result += '\n';
}
return result + "})";
}
示例6: setAsText
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Sets the current property value as text.
*
* @param text the text of the selected tag.
* @exception java.lang.IllegalArgumentException if an error occurs
*/
public void setAsText(String text)
{
SelectedTag s = (SelectedTag)getValue();
Tag [] tags = s.getTags();
try {
for (int i = 0; i < tags.length; i++) {
if (text.equals(tags[i].getReadable())) {
setValue(new SelectedTag(tags[i].getID(), tags));
return;
}
}
} catch (Exception ex) {
throw new java.lang.IllegalArgumentException(text);
}
}
示例7: createLinearRegression
import weka.core.SelectedTag; //导入依赖的package包/类
public static LinearRegression createLinearRegression() {
LinearRegression linreg = new LinearRegression();
linreg.setAttributeSelectionMethod(new SelectedTag(LinearRegression.SELECTION_NONE, LinearRegression.TAGS_SELECTION));
linreg.setEliminateColinearAttributes(false);
// if wants debug info
//linreg.setDebug(true);
return linreg;
}
示例8: getFilterType
import weka.core.SelectedTag; //导入依赖的package包/类
@OptionMetadata(
description = "The type of normalization to perform.",
displayName = "attribute normalization",
commandLineParamName = "normalization",
commandLineParamSynopsis = "-normalization <int>",
displayOrder = 12
)
public SelectedTag getFilterType() {
return new SelectedTag(filterType, TAGS_FILTER);
}
示例9: setSVMType
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Sets the type of SVM (default SVMTYPE_L2)
*
* @param value The type of the SVM
*/
@Override
public void setSVMType(SelectedTag value) {
if (value.getTags() == TAGS_SVMTYPE) {
setSolverType(SolverType.getById(value.getSelectedTag().getID()));
}
}
示例10: makeFinalClusterer
import weka.core.SelectedTag; //导入依赖的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;
}
示例11: setMetricType
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Set the metric type to use.
*
* @param d the metric type
*/
public void setMetricType(SelectedTag d) {
int ordinal = d.getSelectedTag().getID();
for (DefaultAssociationRule.METRIC_TYPE m : DefaultAssociationRule.METRIC_TYPE
.values()) {
if (m.ordinal() == ordinal) {
m_metric = m;
break;
}
}
}
示例12: setDirection
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Set the search direction
*
* @param d the direction of the search
*/
public void setDirection(SelectedTag d) {
if (d.getTags() == TAGS_SELECTION) {
m_searchDirection = d.getSelectedTag().getID();
}
}
示例13: setMethod
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Sets the method used. Will be one of METHOD_1_AGAINST_ALL,
* METHOD_ERROR_RANDOM, METHOD_ERROR_EXHAUSTIVE, or METHOD_1_AGAINST_1.
*
* @param newMethod the new method.
*/
public void setMethod(SelectedTag newMethod) {
if (newMethod.getTags() == TAGS_METHOD) {
m_Method = newMethod.getSelectedTag().getID();
}
}
示例14: setCostMatrixSource
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Sets the source location of the cost matrix. Values other than
* MATRIX_ON_DEMAND or MATRIX_SUPPLIED will be ignored.
*
* @param newMethod the cost matrix location method.
*/
public void setCostMatrixSource(SelectedTag newMethod) {
if (newMethod.getTags() == TAGS_MATRIX_SOURCE) {
m_MatrixSource = newMethod.getSelectedTag().getID();
}
}
示例15: getEvaluationMetric
import weka.core.SelectedTag; //导入依赖的package包/类
/**
* Get the evaluation metric to use
*
* @return the evaluation metric to use
*/
public SelectedTag getEvaluationMetric() {
for (int i = 0; i < TAGS_EVAL.length; i++) {
if (TAGS_EVAL[i].getIDStr().equalsIgnoreCase(m_evalMetric)) {
return new SelectedTag(i, TAGS_EVAL);
}
}
// if we get here then it could be because a plugin
// metric is no longer available. Default to rmse
return new SelectedTag(12, TAGS_EVAL);
}