Package weka.classifiers.lazy.AM.data
Class ClassifiedSupra
- java.lang.Object
-
- weka.classifiers.lazy.AM.data.ClassifiedSupra
-
- All Implemented Interfaces:
Supracontext
public class ClassifiedSupra extends java.lang.Object implements Supracontext
This supracontext is called "classified" because it keeps track of its outcome (or "class") at all times by inspecting the outcomes of the subcontexts added to it. It also provides special methods for determining it's heterogeneity, and for determining if the addition of a subcontext would lead to heterogeneity.
-
-
Constructor Summary
Constructors Constructor Description ClassifiedSupra()Creates a supracontext with no data.ClassifiedSupra(java.util.Set<Subcontext> data, java.math.BigInteger count)Creates a new supracontext with the given parameters as the contents.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Subcontext sub)Add a subcontext to this supracontext.ClassifiedSupracopy()Return an exact, deep copy of the supracontext.booleanequals(java.lang.Object other)Two Supracontexts are equal if they are of the same class and contain the same subcontexts.LabelgetContext()Retrieve the supracontextual context, represented with aLabelobject.java.math.BigIntegergetCount()java.util.Set<Subcontext>getData()doublegetOutcome()Get the outcome of this supracontext.inthashCode()The hashcode depends solely on the set of subcontexts contained in a supracontext.booleanisEmpty()booleanisHeterogeneous()Determine if the supracontext is heterogeneous, meaning thatgetOutcome()returnsAMUtils.HETEROGENEOUS.voidsetCount(java.math.BigInteger count)Set the count of the supracontext.java.lang.StringtoString()booleanwouldBeHetero(Subcontext sub)Test if adding a subcontext would cause this supracontext to become heterogeneous.
-
-
-
Constructor Detail
-
ClassifiedSupra
public ClassifiedSupra()
Creates a supracontext with no data. The outcome will beAMUtils.UNKNOWNuntil data is added.
-
ClassifiedSupra
public ClassifiedSupra(java.util.Set<Subcontext> data, java.math.BigInteger count)
Creates a new supracontext with the given parameters as the contents.- Parameters:
data- The subcontexts contained in the supracontextcount- The count of this supracontext- Throws:
java.lang.IllegalArgumentException- if data or count are null, or count is less thanBigInteger.ZERO
-
-
Method Detail
-
add
public void add(Subcontext sub)
Description copied from interface:SupracontextAdd a subcontext to this supracontext.- Specified by:
addin interfaceSupracontext- Parameters:
sub- Subcontext to add to the supracontext.
-
getOutcome
public double getOutcome()
Get the outcome of this supracontext. If all of the contained subcontexts have the same outcome, then this value is returned. If there are no subcontexts in this supracontext,AMUtils.UNKNOWNis returned. If there are multiple subs with an outcome ofAMUtils.NONDETERMINISTICor the subs with differing outcomes,AMUtils.HETEROGENEOUSis returned.- Returns:
- outcome of this supracontext
- See Also:
Subcontext.getOutcome()
-
isHeterogeneous
public boolean isHeterogeneous()
Determine if the supracontext is heterogeneous, meaning thatgetOutcome()returnsAMUtils.HETEROGENEOUS.- Returns:
- true if the supracontext is heterogeneous, false if it is homogeneous.
-
wouldBeHetero
public boolean wouldBeHetero(Subcontext sub)
Test if adding a subcontext would cause this supracontext to become heterogeneous.- Parameters:
sub- subcontext to hypothetically add- Returns:
- true if adding the given subcontext would cause this supracontext to become heterogeneous.
-
copy
public ClassifiedSupra copy()
Description copied from interface:SupracontextReturn an exact, deep copy of the supracontext. The new object should be an instance of the same class as the calling object.- Specified by:
copyin interfaceSupracontext- Returns:
- a deep copy of this supracontext.
-
getData
public java.util.Set<Subcontext> getData()
- Specified by:
getDatain interfaceSupracontext- Returns:
- an unmodifiable view of the set of subcontexts contained in this supracontext.
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceSupracontext- Returns:
- true if this supracontext contains no subcontexts; false otherwise.
-
getCount
public java.math.BigInteger getCount()
- Specified by:
getCountin interfaceSupracontext- Returns:
- the number of copies of this supracontext contained in the lattice
-
setCount
public void setCount(java.math.BigInteger count)
Description copied from interface:SupracontextSet the count of the supracontext.- Specified by:
setCountin interfaceSupracontext- Parameters:
count- the count
-
getContext
public Label getContext()
Description copied from interface:SupracontextRetrieve the supracontextual context, represented with aLabelobject. Label mismatches should be interpreted as "contained subcontexts may or may not match for this attribute, while matches should be regarded as "all contained subcontexts matched for this attribute". The running time for this default implementation is linear in the number of contained subcontexts.- Specified by:
getContextin interfaceSupracontext- Returns:
- The context for this supracontext, or
nullif the subcontexts are empty
-
equals
public boolean equals(java.lang.Object other)
Description copied from interface:SupracontextTwo Supracontexts are equal if they are of the same class and contain the same subcontexts.- Specified by:
equalsin interfaceSupracontext- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Description copied from interface:SupracontextThe hashcode depends solely on the set of subcontexts contained in a supracontext.- Specified by:
hashCodein interfaceSupracontext- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-