Package weka.classifiers.lazy
Class AnalogicalModeling
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.lazy.AnalogicalModeling
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,weka.classifiers.Classifier
,weka.classifiers.UpdateableClassifier
,weka.core.BatchPredictor
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.CommandlineRunnable
,weka.core.OptionHandler
,weka.core.RevisionHandler
,weka.core.Summarizable
,weka.core.TechnicalInformationHandler
public class AnalogicalModeling extends weka.classifiers.AbstractClassifier implements weka.core.TechnicalInformationHandler, weka.classifiers.UpdateableClassifier, weka.core.Summarizable
Implements the Analogical Modeling algorithm, invented by Royal Skousen. Analogical modeling is an instance-based algorithm designed to model human behavior.For more information, see the following references:
Skousen, R. (1989). Analogical Modeling of Language. Kluwer Academic Publishers.
Theron Stanford (2002). Analogical modeling: an exemplar-based approach to language.BibTeX:
@book{skousen1989analogical, author = {Skousen, R.}, publisher = {Kluwer Academic Publishers}, title = {Analogical Modeling of Language}, year = {1989}, abstract = {Review: 'Skousen develops an analogical approach, which is claimed to handle not merely cases which are problematic for structuralist approaches, but to be applicable equally to the cases with which structuralism is at its best - in short, to be an Einstein to the common Newton.This is altogether a stimulating and richly suggestive book whose fundamental notions are presented with formal rigour. Other, more psychologically adequate, formal analogical theories may be devised, but Skousen has shown the way forward.' Artificial Intelligence and Stimulation of Behaviour Quarterly, 1990, No. 72}, ISBN-13 = {9780792305170} } @inbook{skousen2002analogical, author = {Theron Stanford}, editor = {Skousen, Royal and Lonsdale, Deryle and Parkinson, Dilworth}, pages = {385--409}, publisher = {John Benjamins Publishing Company}, title = {Analogical modeling: an exemplar-based approach to language}, year = {2002}, abstract = {Analogical Modeling (AM) is an exemplar-based general theory of description that uses both neighbors and non-neighbors (under certain well-defined conditions of homogeneity) to predict language behavior. This book provides a basic introduction to AM, compares the theory with nearest-neighbor approaches, and discusses the most recent advances in the theory, including psycholinguistic evidence, applications to specific languages, the problem of categorization, and how AM relates to alternative approaches of language description (such as instance families, neural nets, connectionism, and optimality theory). The book closes with a thorough examination of the problem of the exponential explosion, an inherent difficulty in AM (and in fact all theories of language description). Quantum computing (based on quantum mechanics with its inherent simultaneity and reversibility) provides a precise and natural solution to the exponential explosion in AM. Finally, an extensive appendix provides three tutorials for running the AM computer program (available online).}, ISBN-13 = {9789027223623} }
Skousen, R. (1989). Analogical Modeling of Language. Kluwer Academic Publishers.
Theron Stanford (2002). Analogical modeling: an exemplar-based approach to language. Valid options are:-D If set, classifier is run in debug mode and may output additional info to the console
-I Ignore attributes with unknown values in the test exemplar
-L Use linear instead of quadratic calculation of pointers (default off)
-R Remove test exemplar from training set
-M <method> Method of dealing with missing data. The options are variable, match or mismatch; 'variable' means to treat missing data as a all one variable, 'match' means that missing data will be considered the same as whatever it is compared with, and 'mismatch' means that missing data will always be unequal to whatever it is compared with. Default is 'variable'
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
cardinality
The number of attributes.static weka.core.Tag[]
TAGS_MISSING
Define possible missing value handling methods
-
Constructor Summary
Constructors Constructor Description AnalogicalModeling()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildClassifier(weka.core.Instances instances)
This is used to build the classifier; it specifies the capabilities of the classifier and loads in exemplars to be used for prediction.double[]
distributionForInstance(weka.core.Instance instance)
weka.core.Capabilities
getCapabilities()
Analogical Modeling can handle only nominal class attributes.boolean
getIgnoreUnknowns()
boolean
getLinearCount()
weka.core.SelectedTag
getMissingDataCompare()
java.lang.String[]
getOptions()
Returns the options currently set.boolean
getRemoveTestExemplar()
AMResults
getResults()
Note that this is not thread-safe; see the documentation forclassify
.weka.core.TechnicalInformation
getTechnicalInformation()
java.lang.String
globalInfo()
Returns basic human readable information about the classifier, including references.java.lang.String
ignoreUnknownsTipText()
java.lang.String
linearCountTipText()
java.util.Enumeration<weka.core.Option>
listOptions()
Lists the options available for this classifier.static void
main(java.lang.String[] argv)
Main method for testing this class.java.lang.String
missingDataCompareTipText()
java.lang.String
removeTestExemplarTipText()
static void
runClassifier(AnalogicalModeling classifier, java.lang.String[] options)
runs the classifier instance with the given options.void
setIgnoreUnknowns(boolean ignoreUnknowns)
void
setLinearCount(boolean lc)
void
setMissingDataCompare(weka.core.SelectedTag newMode)
void
setOptions(java.lang.String[] options)
* Parses a given list of options.void
setRandomProvider(java.util.function.Supplier<java.util.Random> randomProvider)
Provide the source of randomness for algorithms that require it (e.g.void
setRemoveTestExemplar(boolean removeTestExemplar)
java.lang.String
toString()
java.lang.String
toSummaryString()
void
updateClassifier(weka.core.Instance instance)
This is used to add more information to the classifier.-
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, getRevision, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
-
-
-
Method Detail
-
getLinearCount
public boolean getLinearCount()
- Returns:
- True if counting of pointers is linear; false if quadratic.
-
setLinearCount
public void setLinearCount(boolean lc)
- Parameters:
lc
- True if counting of pointers should be linear; false if quadratic.
-
linearCountTipText
public java.lang.String linearCountTipText()
- Returns:
- Tooltip text describing the linearCount option
-
getIgnoreUnknowns
public boolean getIgnoreUnknowns()
-
setIgnoreUnknowns
public void setIgnoreUnknowns(boolean ignoreUnknowns)
-
ignoreUnknownsTipText
public java.lang.String ignoreUnknownsTipText()
-
getRemoveTestExemplar
public boolean getRemoveTestExemplar()
- Returns:
- true if we remove a test instance from training before predicting its outcome
-
setRemoveTestExemplar
public void setRemoveTestExemplar(boolean removeTestExemplar)
- Parameters:
removeTestExemplar
- true if we should remove a test instance from training before predicting its outcome
-
removeTestExemplarTipText
public java.lang.String removeTestExemplarTipText()
- Returns:
- Tooltip text describing the removeTestExemplar option
-
getMissingDataCompare
public weka.core.SelectedTag getMissingDataCompare()
- Returns:
- Selected strategy used when comparing missing values with other data
-
setMissingDataCompare
public void setMissingDataCompare(weka.core.SelectedTag newMode)
- Parameters:
newMode
- representing choice for strategy to compare missing data- Throws:
java.lang.IllegalArgumentException
- if input is not a known missing data comparison strategy
-
setRandomProvider
public void setRandomProvider(java.util.function.Supplier<java.util.Random> randomProvider)
Provide the source of randomness for algorithms that require it (e.g.JohnsenJohanssonLattice
). This cannot be set from the Weka GUI and is markedtransient
, e.g. it cannot be serialized with the class. The provider must be thread-safe.
-
missingDataCompareTipText
public java.lang.String missingDataCompareTipText()
- Returns:
- Tooltip text describing the missingDataCompare option
-
globalInfo
public java.lang.String globalInfo()
Returns basic human readable information about the classifier, including references.- Returns:
- General information and references about the Analogical Modeling classifier
-
listOptions
public java.util.Enumeration<weka.core.Option> listOptions()
Lists the options available for this classifier.- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classweka.classifiers.AbstractClassifier
- Returns:
- See Also:
AbstractClassifier.listOptions()
-
getOptions
public java.lang.String[] getOptions()
Returns the options currently set.- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.classifiers.AbstractClassifier
- Returns:
- See Also:
AbstractClassifier.getOptions()
-
setOptions
public void setOptions(java.lang.String[] options)
* Parses a given list of options. Valid options are:* *
-D If set, classifier is run in debug mode and may output additional info to the console
-I Ignore attributes with unknown values in the test exemplar
-L Use linear instead of quadratic calculation of pointers (default off)
-R Remove test exemplar from training set
-M <method> Method of dealing with missing data. The options are variable, match or mismatch; 'variable' means to treat missing data as a all one variable, 'match' means that missing data will be considered the same as whatever it is compared with, and 'mismatch' means that missing data will always be unequal to whatever it is compared with. Default is 'variable'
- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.classifiers.AbstractClassifier
- Parameters:
options
-
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Analogical Modeling can handle only nominal class attributes. Missing classes are handled, too, although you must specify how to handle them (seesetOptions(java.lang.String[])
).- Specified by:
getCapabilities
in interfaceweka.core.CapabilitiesHandler
- Specified by:
getCapabilities
in interfaceweka.classifiers.Classifier
- Overrides:
getCapabilities
in classweka.classifiers.AbstractClassifier
- Returns:
-
getTechnicalInformation
public weka.core.TechnicalInformation getTechnicalInformation()
- Specified by:
getTechnicalInformation
in interfaceweka.core.TechnicalInformationHandler
- Returns:
- See Also:
TechnicalInformationHandler.getTechnicalInformation()
-
buildClassifier
public void buildClassifier(weka.core.Instances instances) throws java.lang.Exception
This is used to build the classifier; it specifies the capabilities of the classifier and loads in exemplars to be used for prediction. No actual analysis happens here because AM is a lazy classifier.- Specified by:
buildClassifier
in interfaceweka.classifiers.Classifier
- Throws:
java.lang.Exception
- See Also:
Classifier.buildClassifier(weka.core.Instances)
-
updateClassifier
public void updateClassifier(weka.core.Instance instance) throws java.lang.Exception
This is used to add more information to the classifier.- Specified by:
updateClassifier
in interfaceweka.classifiers.UpdateableClassifier
- Throws:
java.lang.Exception
- See Also:
UpdateableClassifier.updateClassifier(weka.core.Instance)
-
distributionForInstance
public double[] distributionForInstance(weka.core.Instance instance) throws java.lang.Exception
- Specified by:
distributionForInstance
in interfaceweka.classifiers.Classifier
- Overrides:
distributionForInstance
in classweka.classifiers.AbstractClassifier
- Returns:
- Throws:
java.lang.Exception
- if distribution can't be computed successfully- See Also:
AbstractClassifier.distributionForInstance(weka.core.Instance)
-
getResults
public AMResults getResults()
Note that this is not thread-safe; see the documentation forclassify
.- Returns:
- The classification results from the last call to distributionForInstance
- Throws:
java.lang.IllegalStateException
- if you've never called distributionForInstance from this object
-
toSummaryString
public java.lang.String toSummaryString()
- Specified by:
toSummaryString
in interfaceweka.core.Summarizable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- String containing name of the classifier and number of training instances.
-
runClassifier
public static void runClassifier(AnalogicalModeling classifier, java.lang.String[] options)
runs the classifier instance with the given options.- Parameters:
classifier
- the classifier to runoptions
- the commandline options
-
main
public static void main(java.lang.String[] argv)
Main method for testing this class.- Parameters:
argv
- should contain command line options (see setOptions)
-
-