本文整理了Java中weka.core.Instances.deleteWithMissingClass()
方法的一些代码示例,展示了Instances.deleteWithMissingClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instances.deleteWithMissingClass()
方法的具体详情如下:
包路径:weka.core.Instances
类名称:Instances
方法名:deleteWithMissingClass
[英]Removes all instances with a missing class value from the dataset.
[中]从数据集中删除缺少类值的所有实例。
代码示例来源:origin: com.googlecode.obvious/obviousx-weka
@Override
public void deleteWithMissingClass() {
super.deleteWithMissingClass();
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Method for building a classifier tree.
*
* @param data the data to build the tree from
* @throws Exception if something goes wrong
*/
public void buildClassifier(Instances data) throws Exception {
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
buildTree(data, false);
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Method for building a classifier tree.
*
* @param data the data to build the tree from
* @throws Exception if something goes wrong
*/
public void buildClassifier(Instances data) throws Exception {
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
buildTree(data, false);
}
代码示例来源:origin: com.github.fracpete/multisearch-weka-package
/**
* Loads test data, if required.
*
* @param data
* the current training data
* @throws Exception
* if test sets are not compatible with training data
*/
protected void loadTestData(Instances data) throws Exception {
String msg;
m_SearchSpaceTestInst = null;
if (m_SearchSpaceTestSet.exists()
&& !m_SearchSpaceTestSet.isDirectory()) {
m_SearchSpaceTestInst = DataSource.read(m_SearchSpaceTestSet
.getAbsolutePath());
m_SearchSpaceTestInst.setClassIndex(data.classIndex());
msg = data.equalHeadersMsg(m_SearchSpaceTestInst);
if (msg != null) {
throw new IllegalArgumentException(
"Test set for search space not compatible with training dta:\n"
+ msg);
}
m_SearchSpaceTestInst.deleteWithMissingClass();
log("Using test set for search space: " + m_SearchSpaceTestSet);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/simpleEducationalLearningSchemes
/**
* Builds Id3 decision tree classifier.
*
* @param data the training data
* @exception Exception if classifier can't be built successfully
*/
public void buildClassifier(Instances data) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(data);
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
makeTree(data);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Generates the classifier.
*
* @param instances set of instances serving as training data
* @throws Exception if the classifier has not been generated successfully
*/
public void buildClassifier(Instances instances) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(instances);
// remove instances with missing class
instances = new Instances(instances);
instances.deleteWithMissingClass();
m_Train = new Instances(instances, 0, instances.numInstances());
// initializes class attributes ** java-speaking! :-) **
init_m_Attributes();
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Generates the classifier.
*
* @param instances set of instances serving as training data
* @throws Exception if the classifier has not been generated successfully
*/
public void buildClassifier(Instances instances) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(instances);
// remove instances with missing class
instances = new Instances(instances);
instances.deleteWithMissingClass();
m_Train = new Instances(instances, 0, instances.numInstances());
// initializes class attributes ** java-speaking! :-) **
init_m_Attributes();
}
代码示例来源:origin: nz.ac.waikato.cms.weka/simpleEducationalLearningSchemes
/**
* Generates the classifier.
*
* @param instances set of instances serving as training data
* @throws Exception if the classifier has not been generated successfully
*/
public void buildClassifier(Instances instances) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(instances);
// remove instances with missing class
instances = new Instances(instances);
instances.deleteWithMissingClass();
m_Train = new Instances(instances, 0, instances.numInstances());
m_MinArray = new double [m_Train.numAttributes()];
m_MaxArray = new double [m_Train.numAttributes()];
for (int i = 0; i < m_Train.numAttributes(); i++) {
m_MinArray[i] = m_MaxArray[i] = Double.NaN;
}
Enumeration enu = m_Train.enumerateInstances();
while (enu.hasMoreElements()) {
updateMinMax((Instance) enu.nextElement());
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Method for building a pruneable classifier tree.
*
* @param data the data to build the tree from
* @throws Exception if tree can't be built successfully
*/
public void buildClassifier(Instances data)
throws Exception {
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
Random random = new Random(m_seed);
data.stratify(numSets);
buildTree(data.trainCV(numSets, numSets - 1, random),
data.testCV(numSets, numSets - 1), !m_cleanup);
if (pruneTheTree) {
prune();
}
if (m_cleanup) {
cleanup(new Instances(data, 0));
}
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Method for building a pruneable classifier tree.
*
* @param data the data to build the tree from
* @throws Exception if tree can't be built successfully
*/
public void buildClassifier(Instances data)
throws Exception {
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
Random random = new Random(m_seed);
data.stratify(numSets);
buildTree(data.trainCV(numSets, numSets - 1, random),
data.testCV(numSets, numSets - 1), !m_cleanup);
if (pruneTheTree) {
prune();
}
if (m_cleanup) {
cleanup(new Instances(data, 0));
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Method for building a pruneable classifier tree.
*
* @param data the data for building the tree
* @throws Exception if something goes wrong
*/
public void buildClassifier(Instances data) throws Exception {
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
buildTree(data, m_subtreeRaising || !m_cleanup);
if (m_collapseTheTree) {
collapse();
}
if (m_pruneTheTree) {
prune();
}
if (m_cleanup) {
cleanup(new Instances(data, 0));
}
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Method for building a pruneable classifier tree.
*
* @param data the data for building the tree
* @throws Exception if something goes wrong
*/
public void buildClassifier(Instances data) throws Exception {
// remove instances with missing class
data = new Instances(data);
data.deleteWithMissingClass();
buildTree(data, m_subtreeRaising || !m_cleanup);
if (m_collapseTheTree) {
collapse();
}
if (m_pruneTheTree) {
prune();
}
if (m_cleanup) {
cleanup(new Instances(data, 0));
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Build the clusterer on the filtered data.
*
* @param data the training data
* @throws Exception if the clusterer could not be built successfully
*/
@Override
public void buildClusterer(Instances data) throws Exception {
if (m_Clusterer == null) {
throw new Exception("No base clusterer has been set!");
}
// remove instances with missing class
if (data.classIndex() > -1) {
data = new Instances(data);
data.deleteWithMissingClass();
}
m_Filter.setInputFormat(data); // filter capabilities are checked here
data = Filter.useFilter(data, m_Filter);
// can clusterer handle the data?
getClusterer().getCapabilities().testWithFail(data);
m_FilteredInstances = data.stringFreeStructure();
m_Clusterer.buildClusterer(data);
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Build the clusterer on the filtered data.
*
* @param data the training data
* @throws Exception if the clusterer could not be built successfully
*/
@Override
public void buildClusterer(Instances data) throws Exception {
if (m_Clusterer == null) {
throw new Exception("No base clusterer has been set!");
}
// remove instances with missing class
if (data.classIndex() > -1) {
data = new Instances(data);
data.deleteWithMissingClass();
}
m_Filter.setInputFormat(data); // filter capabilities are checked here
data = Filter.useFilter(data, m_Filter);
// can clusterer handle the data?
getClusterer().getCapabilities().testWithFail(data);
m_FilteredInstances = data.stringFreeStructure();
m_Clusterer.buildClusterer(data);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/multiInstanceLearning
/**
* Builds the classifier
*
* @param data the training data to be used for generating the boosted
* classifier.
* @throws Exception if the classifier could not be built successfully
*/
@Override
public void buildClassifier(Instances data) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(data);
// remove instances with missing class
Instances train = new Instances(data);
train.deleteWithMissingClass();
if (m_Classifier == null) {
throw new Exception("A base classifier has not been specified!");
}
if (getDebug()) {
System.out.println("Start training ...");
}
m_NumClasses = train.numClasses();
// convert the training dataset into single-instance dataset
m_ConvertToProp.setWeightMethod(getWeightMethod());
m_ConvertToProp.setInputFormat(train);
train = Filter.useFilter(train, m_ConvertToProp);
train.deleteAttributeAt(0); // remove the bag index attribute
m_Classifier.buildClassifier(train);
}
代码示例来源:origin: nz.ac.waikato.cms.moa/moa
/**
* Generates a classifier.
*
* @param data set of instances serving as training data
* @throws Exception if the classifier has not been
* generated successfully
*/
public void buildClassifier(Instances data) throws Exception {
this.instanceConverter = new WekaToSamoaInstanceConverter();
getCapabilities().testWithFail(data);
data = new Instances(data);
data.deleteWithMissingClass();
m_ActualClassifier.resetLearning();
for (int i = 0; i < data.numInstances(); i++)
updateClassifier(data.instance(i));
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Builds the classifier.
*
* @param data the data to train with
* @throws Exception if classifier can't be built successfully
*/
@Override
public void buildClassifier(Instances data) throws Exception {
reset();
m_header = new Instances(data, 0);
if (m_selectedSplitMetric == GINI_SPLIT) {
m_splitMetric = new GiniSplitMetric();
} else {
m_splitMetric = new InfoGainSplitMetric(m_minFracWeightForTwoBranchesGain);
}
data = new Instances(data);
data.deleteWithMissingClass();
for (int i = 0; i < data.numInstances(); i++) {
updateClassifier(data.instance(i));
}
// can classifier handle the data?
getCapabilities().testWithFail(data);
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Builds the classifier.
*
* @param data the data to train with
* @throws Exception if classifier can't be built successfully
*/
@Override
public void buildClassifier(Instances data) throws Exception {
reset();
m_header = new Instances(data, 0);
if (m_selectedSplitMetric == GINI_SPLIT) {
m_splitMetric = new GiniSplitMetric();
} else {
m_splitMetric = new InfoGainSplitMetric(m_minFracWeightForTwoBranchesGain);
}
data = new Instances(data);
data.deleteWithMissingClass();
for (int i = 0; i < data.numInstances(); i++) {
updateClassifier(data.instance(i));
}
// can classifier handle the data?
getCapabilities().testWithFail(data);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Builds the classifiers.
*
* @param insts the training data.
* @throws Exception if a classifier can't be built
*/
public void buildClassifier(Instances insts) throws Exception {
Instances newInsts;
// can classifier handle the data?
getCapabilities().testWithFail(insts);
// remove instances with missing class
insts = new Instances(insts);
insts.deleteWithMissingClass();
m_Classifiers = AbstractClassifier.makeCopies(m_Classifier, insts.numClasses());
m_ClassFilters = new MakeIndicator[insts.numClasses()];
for (int i = 0; i < insts.numClasses(); i++) {
m_ClassFilters[i] = new MakeIndicator();
m_ClassFilters[i].setAttributeIndex("" + (insts.classIndex() + 1));
m_ClassFilters[i].setValueIndex(i);
m_ClassFilters[i].setNumeric(true);
m_ClassFilters[i].setInputFormat(insts);
newInsts = Filter.useFilter(insts, m_ClassFilters[i]);
m_Classifiers[i].buildClassifier(newInsts);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/multiInstanceLearning
/**
* Builds the classifier from the given training data.
*/
@Override
public void buildClassifier(Instances data) throws Exception {
data = new Instances(data);
data.deleteWithMissingClass();
getCapabilities().testWithFail(data);
m_Filter = new MultiFilter();
Filter[] twoFilters = new Filter[2];
PartitionMembership pm = new PartitionMembership();
pm.setPartitionGenerator(getPartitionGenerator());
MultiInstanceWrapper miw = new MultiInstanceWrapper();
miw.setFilter(pm);
twoFilters[0] = miw;
twoFilters[1] = new Remove();
((Remove) twoFilters[1]).setAttributeIndices("1");
m_Filter.setFilters(twoFilters);
m_Filter.setInputFormat(data);
Instances propositionalData = Filter.useFilter(data, m_Filter);
// can classifier handle the data?
getClassifier().getCapabilities().testWithFail(propositionalData);
m_Classifier.buildClassifier(propositionalData);
}
内容来源于网络,如有侵权,请联系作者删除!