Package edu.stanford.nlp.classify
Class WeightedDataset<L,F>
- java.lang.Object
-
- edu.stanford.nlp.classify.GeneralDataset<L,F>
-
- edu.stanford.nlp.classify.Dataset<L,F>
-
- edu.stanford.nlp.classify.WeightedDataset<L,F>
-
- All Implemented Interfaces:
Serializable,Iterable<RVFDatum<L,F>>
public class WeightedDataset<L,F> extends Dataset<L,F>
- Author:
- Galen Andrew, Sarah Spikes (sdspikes@cs.stanford.edu) (Templatization)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected float[]weights-
Fields inherited from class edu.stanford.nlp.classify.GeneralDataset
data, featureIndex, labelIndex, labels, size
-
-
Constructor Summary
Constructors Constructor Description WeightedDataset()WeightedDataset(int initSize)WeightedDataset(Index<L> labelIndex, int[] labels, Index<F> featureIndex, int[][] data, int size, float[] weights)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Datum<L,F> d)voidadd(Datum<L,F> d, float weight)voidadd(Collection<F> features, L label)voidadd(Collection<F> features, L label, float weight)protected voidensureSize()float[]getFeatureCounts()Get the total count (over all data instances) of each featurefloat[]getWeights()voidrandomize(long randomSeed)Randomizes (shuffles) the data array in place.voidsetWeight(int i, float weight)Set the weight of datum i.<E> voidshuffleWithSideInformation(long randomSeed, List<E> sideInformation)Randomizes (shuffles) the data array in place.-
Methods inherited from class edu.stanford.nlp.classify.Dataset
add, add, addFeatureIndices, addFeatures, addFeatures, addLabel, addLabelIndex, applyFeatureCountThreshold, changeFeatureIndex, changeLabelIndex, getDatum, getFeatureCounter, getInformationGains, getL1NormalizedTFIDFDataset, getL1NormalizedTFIDFDatum, getRandomSubDataset, getRVFDatum, getValuesArray, initialize, printFullFeatureMatrix, printSparseFeatureMatrix, printSparseFeatureMatrix, printSVMLightFormat, readSVMLightFormat, readSVMLightFormat, readSVMLightFormat, readSVMLightFormat, selectFeatures, selectFeaturesBinaryInformationGain, split, split, summaryStatistics, svmLightLineToDatum, toString, toSummaryStatistics, toSummaryString, updateLabels
-
Methods inherited from class edu.stanford.nlp.classify.GeneralDataset
addAll, applyFeatureCountThreshold, applyFeatureMaxCountThreshold, clear, clear, featureIndex, getDataArray, getLabelsArray, iterator, labelIndex, labelIterator, makeSvmLabelMap, mapDataset, mapDataset, mapDatum, numClasses, numDatumsPerLabel, numFeatures, numFeatureTokens, numFeatureTypes, printSVMLightFormat, printSVMLightFormat, retainFeatures, sampleDataset, size, splitOutFold, trimData, trimLabels, trimToSize, trimToSize, trimToSize
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getWeights
public float[] getWeights()
-
getFeatureCounts
public float[] getFeatureCounts()
Description copied from class:GeneralDatasetGet the total count (over all data instances) of each feature- Overrides:
getFeatureCountsin classGeneralDataset<L,F>- Returns:
- an array containing the counts (indexed by index)
-
ensureSize
protected void ensureSize()
- Overrides:
ensureSizein classDataset<L,F>
-
add
public void add(Collection<F> features, L label, float weight)
-
setWeight
public void setWeight(int i, float weight)Set the weight of datum i.- Parameters:
i- The index of the datum to change the weight of.weight- The weight to set
-
randomize
public void randomize(long randomSeed)
Randomizes (shuffles) the data array in place. Needs to be redefined here because we need to randomize the weights as well.- Overrides:
randomizein classGeneralDataset<L,F>- Parameters:
randomSeed- A seed for the Random object (allows you to reproduce the same ordering)
-
shuffleWithSideInformation
public <E> void shuffleWithSideInformation(long randomSeed, List<E> sideInformation)Randomizes (shuffles) the data array in place. Needs to be redefined here because we need to randomize the weights as well.- Overrides:
shuffleWithSideInformationin classGeneralDataset<L,F>- Parameters:
randomSeed- A seed for the Random object (allows you to reproduce the same ordering)
-
-