weka.core
Class SoftClassifiedSparseInstance

java.lang.Object
  extended byweka.core.Instance
      extended byweka.core.SparseInstance
          extended byweka.core.SoftClassifiedSparseInstance
All Implemented Interfaces:
Copyable, java.io.Serializable, SoftClassifiedInstance

public class SoftClassifiedSparseInstance
extends SparseInstance
implements SoftClassifiedInstance

An Instance that has a probability distribution across class values. Particularly useful for EM using a SoftClassifier

See Also:
Serialized Form

Field Summary
protected  double[] m_ClassDistribution
          An array of probabilities giving the probability of each class for this Instance
 
Fields inherited from class weka.core.SparseInstance
m_Indices, m_NumAttributes
 
Fields inherited from class weka.core.Instance
m_AttValues, m_Dataset, m_Weight, MISSING_VALUE
 
Constructor Summary
SoftClassifiedSparseInstance()
           
SoftClassifiedSparseInstance(SparseInstance instance)
          Constructor that copies the attribute values and the weight from the given instance and gives SoftInstance random class probabilities that assign all probability (1) to the instance's given class
SoftClassifiedSparseInstance(SparseInstance instance, java.util.Random randomizer)
          Constructor that copies the attribute values and the weight from the given instance and gives SoftInstance random class probabilities generated by the given randomizer.
 
Method Summary
 java.lang.Object copy()
          Produces a shallow copy of this instance.
 double[] getClassDistribution()
          Get the class distribution for this instance
 double getClassProbability(int classNum)
          Return the probability the instance is in the given class
protected  double[] randomClassDistribution(java.util.Random randomizer)
          Return a random class distribution
 void setClassDistribution(double[] dist)
          Set the class distribution for this instance
 void setClassProbability(int classNum, double prob)
          Set the probability the instance is in the given class
 
Methods inherited from class weka.core.SparseInstance
attributeSparse, index, isMissing, locateIndex, main, mergeInstance, numAttributes, numValues, replaceMissingValues, setValue, setValueSparse, toDoubleArray, toString, value
 
Methods inherited from class weka.core.Instance
attribute, classAttribute, classIndex, classIsMissing, classValue, dataset, deleteAttributeAt, enumerateAttributes, equalHeaders, insertAttributeAt, isMissing, isMissingSparse, isMissingValue, missingValue, numClasses, setClassMissing, setClassValue, setClassValue, setDataset, setMissing, setMissing, setValue, setValue, setValue, setValueArray, setWeight, stringValue, stringValue, toString, toString, value, valueSparse, weight
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_ClassDistribution

protected double[] m_ClassDistribution
An array of probabilities giving the probability of each class for this Instance

Constructor Detail

SoftClassifiedSparseInstance

public SoftClassifiedSparseInstance(SparseInstance instance,
                                    java.util.Random randomizer)
Constructor that copies the attribute values and the weight from the given instance and gives SoftInstance random class probabilities generated by the given randomizer.


SoftClassifiedSparseInstance

public SoftClassifiedSparseInstance(SparseInstance instance)
Constructor that copies the attribute values and the weight from the given instance and gives SoftInstance random class probabilities that assign all probability (1) to the instance's given class


SoftClassifiedSparseInstance

public SoftClassifiedSparseInstance()
Method Detail

randomClassDistribution

protected double[] randomClassDistribution(java.util.Random randomizer)
Return a random class distribution


getClassProbability

public double getClassProbability(int classNum)
Return the probability the instance is in the given class

Specified by:
getClassProbability in interface SoftClassifiedInstance

setClassProbability

public void setClassProbability(int classNum,
                                double prob)
Set the probability the instance is in the given class

Specified by:
setClassProbability in interface SoftClassifiedInstance

getClassDistribution

public double[] getClassDistribution()
Get the class distribution for this instance

Specified by:
getClassDistribution in interface SoftClassifiedInstance

setClassDistribution

public void setClassDistribution(double[] dist)
                          throws java.lang.Exception
Set the class distribution for this instance

Specified by:
setClassDistribution in interface SoftClassifiedInstance
Throws:
java.lang.Exception

copy

public java.lang.Object copy()
Produces a shallow copy of this instance. The copy has access to the same dataset. (if you want to make a copy that doesn't have access to the dataset, use new Instance(instance)

Specified by:
copy in interface Copyable
Overrides:
copy in class SparseInstance
Returns:
the shallow copy