Class WeightedDataset<L,​F>

    • Field Detail

      • weights

        protected float[] weights
    • Constructor Detail

      • WeightedDataset

        public WeightedDataset​(Index<L> labelIndex,
                               int[] labels,
                               Index<F> featureIndex,
                               int[][] data,
                               int size,
                               float[] weights)
      • WeightedDataset

        public WeightedDataset()
      • WeightedDataset

        public WeightedDataset​(int initSize)
    • Method Detail

      • getWeights

        public float[] getWeights()
      • getFeatureCounts

        public float[] getFeatureCounts()
        Description copied from class: GeneralDataset
        Get the total count (over all data instances) of each feature
        Overrides:
        getFeatureCounts in class GeneralDataset<L,​F>
        Returns:
        an array containing the counts (indexed by index)
      • add

        public void add​(Datum<L,​F> d,
                        float weight)
      • 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:
        randomize in class GeneralDataset<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:
        shuffleWithSideInformation in class GeneralDataset<L,​F>
        Parameters:
        randomSeed - A seed for the Random object (allows you to reproduce the same ordering)