weka.classifiers.mi.TLC Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multiInstanceLearning Show documentation
Show all versions of multiInstanceLearning Show documentation
A collection of multi-instance learning classifiers. Includes the Citation KNN method, several variants of the diverse density method, support vector machines for multi-instance learning, simple wrappers for applying standard propositional learners to multi-instance data, decision tree and rule learners, and some other methods.
The newest version!
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/*
* TLC.java
* Copyright (C) 2012 University of Waikato, Hamilton, New Zealand
*/
package weka.classifiers.mi;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;
import weka.classifiers.SingleClassifierEnhancer;
import weka.classifiers.meta.LogitBoost;
import weka.classifiers.trees.J48;
import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.MultiInstanceCapabilitiesHandler;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.PartitionGenerator;
import weka.core.RevisionUtils;
import weka.core.TechnicalInformation;
import weka.core.TechnicalInformation.Field;
import weka.core.TechnicalInformation.Type;
import weka.core.TechnicalInformationHandler;
import weka.core.Utils;
import weka.filters.Filter;
import weka.filters.MultiFilter;
import weka.filters.supervised.attribute.PartitionMembership;
import weka.filters.unsupervised.attribute.MultiInstanceWrapper;
import weka.filters.unsupervised.attribute.Remove;
/**
* Implements basic two-level classification method
* for multi-instance data, without attribute selection.
*
* For more information see:
*
* Nils Weidmann, Eibe Frank, Bernhard Pfahringer: A two-level learning method
* for generalized multi-instance problems. In: Fourteenth European Conference
* on Machine Learning, 468-479, 2003.
*
* Eibe Frank and Bernhard Pfahringer: Propositionalisation of Multi-instance Data Using Random Forests.
* In: AI 2013: Advances in Artificial Intelligence, 362-373, 2013.
*
*
*
* BibTeX:
*
*
* @inproceedings{Weidmann2003,
* author = {Nils Weidmann and Eibe Frank and Bernhard Pfahringer},
* booktitle = {Fourteenth European Conference on Machine Learning},
* pages = {468-479},
* publisher = {Springer},
* title = {A two-level learning method for generalized multi-instance problems},
* year = {2003}
* }
*
*
* @inproceedings{FrankAndPfahringer203,
* author = {Eibe Frank and Bernhard Pfahringer},
* booktitle = {AI 2013: Advances in Artificial Intelligence},
* pages = {362-373},
* publisher = {Springer},
* title = {Propositionalisation of Multi-instance Data Using Random Forests},
* year = {2013}
* }
*
*
*
*
* Valid options are:
*
*
*
* -P "<name and options of partition generator>"
* Partition generator to use, including options.
* Quotes are needed when options are specified.
* (default: weka.classifiers.trees.J48)
*
*
*
* -D
* If set, classifier is run in debug mode and
* may output additional info to the console
*
*
*
* -W
* Full name of base classifier.
* (default: weka.classifiers.meta.LogitBoost)
*
*
*
* Options specific to classifier weka.classifiers.meta.LogitBoost:
*
*
*
* -Q
* Use resampling instead of reweighting for boosting.
*
*
*
* -P <percent>
* Percentage of weight mass to base training on.
* (default 100, reduce to around 90 speed up)
*
*
*
* -F <num>
* Number of folds for internal cross-validation.
* (default 0 -- no cross-validation)
*
*
*
* -R <num>
* Number of runs for internal cross-validation.
* (default 1)
*
*
*
* -L <num>
* Threshold on the improvement of the likelihood.
* (default -Double.MAX_VALUE)
*
*
*
* -H <num>
* Shrinkage parameter.
* (default 1)
*
*
*
* -S <num>
* Random number seed.
* (default 1)
*
*
*
* -I <num>
* Number of iterations.
* (default 10)
*
*
*
* -D
* If set, classifier is run in debug mode and
* may output additional info to the console
*
*
*
* -W
* Full name of base classifier.
* (default: weka.classifiers.trees.DecisionStump)
*
*
*
* Options specific to classifier weka.classifiers.trees.DecisionStump:
*
*
*
* -D
* If set, classifier is run in debug mode and
* may output additional info to the console
*
*
*
* Options specific to partition generator weka.classifiers.trees.J48:
*
*
*
* -U
* Use unpruned tree.
*
*
*
* -O
* Do not collapse tree.
*
*
*
* -C <pruning confidence>
* Set confidence threshold for pruning.
* (default 0.25)
*
*
*
* -M <minimum number of instances>
* Set minimum number of instances per leaf.
* (default 2)
*
*
*
* -R
* Use reduced error pruning.
*
*
*
* -N <number of folds>
* Set number of folds for reduced error
* pruning. One fold is used as pruning set.
* (default 3)
*
*
*
* -B
* Use binary splits only.
*
*
*
* -S
* Don't perform subtree raising.
*
*
*
* -L
* Do not clean up after the tree has been built.
*
*
*
* -A
* Laplace smoothing for predicted probabilities.
*
*
*
* -J
* Do not use MDL correction for info gain on numeric attributes.
*
*
*
* -Q <seed>
* Seed for random data shuffling (default 1).
*
*
*
*
* @author Eibe Frank ([email protected])
* @version $Revision: 14016 $
*/
public class TLC extends SingleClassifierEnhancer implements
TechnicalInformationHandler, MultiInstanceCapabilitiesHandler {
/** For serialization */
private static final long serialVersionUID = -4444591375578585231L;
/** The partition generator to use. */
protected PartitionGenerator m_partitionGenerator = new J48();
/** The filter to use in conjunction with the partition generator. */
protected MultiFilter m_Filter = null;
/**
* Returns a string describing this filter
*
* @return a description of the filter suitable for displaying in the
* explorer/experimenter gui
*/
public String globalInfo() {
return "Implements basic two-level classification method for multi-instance data"
+ ", without attribute selection.\n\n"
+ "For more information see:\n\n"
+ getTechnicalInformation().toString();
}
/**
* Returns an instance of a TechnicalInformation object, containing detailed
* information about the technical background of this class, e.g., paper
* reference or book this class is based on.
*
* @return the technical information about this class
*/
@Override
public TechnicalInformation getTechnicalInformation() {
TechnicalInformation result, additional;
result = new TechnicalInformation(Type.INPROCEEDINGS);
result.setValue(Field.AUTHOR,
"Nils Weidmann and Eibe Frank and Bernhard Pfahringer");
result.setValue(Field.TITLE,
"A two-level learning method for generalized multi-instance problems");
result.setValue(Field.BOOKTITLE,
"Fourteenth European Conference on Machine Learning");
result.setValue(Field.YEAR, "2003");
result.setValue(Field.PAGES, "468-479");
result.setValue(Field.PUBLISHER, "Springer");
additional = result.add(Type.INPROCEEDINGS);
additional.setValue(TechnicalInformation.Field.AUTHOR, "Eibe Frank and Bernhard Pfahringer");
additional.setValue(TechnicalInformation.Field.TITLE,
"Propositionalisation of Multi-instance Data Using Random Forests");
additional.setValue(TechnicalInformation.Field.BOOKTITLE, "AI 2013: Advances in Artificial Intelligence");
additional.setValue(TechnicalInformation.Field.YEAR, "2013");
additional.setValue(TechnicalInformation.Field.PUBLISHER, "Springer");
additional.setValue(TechnicalInformation.Field.PAGES, "362-373");
return result;
}
/**
* Constructor that sets default base learner.
*/
public TLC() {
m_Classifier = new LogitBoost();
}
/**
* String describing default classifier.
*/
@Override
protected String defaultClassifierString() {
return "weka.classifiers.meta.LogitBoost";
}
/**
* Returns a description of this option suitable for display as a tip text in
* the gui.
*
* @return description of this option
*/
public String partitionGeneratorTipText() {
return "The partition generator that will generate membership values for the instances.";
}
/**
* Set the generator for use in filtering
*
* @param newPartitionGenerator the generator to use
*/
public void setPartitionGenerator(PartitionGenerator newPartitionGenerator) {
m_partitionGenerator = newPartitionGenerator;
}
/**
* Get the generator used by this filter
*
* @return the generator used
*/
public PartitionGenerator getPartitionGenerator() {
return m_partitionGenerator;
}
/**
* Gets the partition generator specification string, which contains the class
* name of the partition generator and any options to the partition generator.
*
* @return the filter string.
*/
protected String getPartitionGeneratorSpec() {
PartitionGenerator c = getPartitionGenerator();
if (c instanceof OptionHandler) {
return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler) c).getOptions());
}
return c.getClass().getName();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration