org.apache.ignite.ml.tree.randomforest.data.impurity

## Class GiniHistogram

- java.lang.Object
- - org.apache.ignite.ml.tree.randomforest.data.impurity.ImpurityHistogram
  - - org.apache.ignite.ml.tree.randomforest.data.impurity.GiniHistogram

- All Implemented Interfaces:
    Serializable, Histogram<BootstrappedVector,GiniHistogram>, ImpurityComputer<BootstrappedVector,GiniHistogram>

      public class GiniHistogram
      extends ImpurityHistogram
      implements ImpurityComputer<BootstrappedVector,GiniHistogram>

  Class contains implementation of splitting point finding algorithm based on Gini metric (see https://en.wikipedia.org/wiki/Gini_coefficient) and represents a set of histograms in according to this metric.
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class org.apache.ignite.ml.tree.randomforest.data.impurity.ImpurityHistogram

      `featureId`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GiniHistogram(int sampleId, Map<Double,Integer> lblMapping, BucketMeta bucketMeta)` Creates an instance of GiniHistogram.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addElement(BootstrappedVector vector)` Add object to histogram.
    `Set<Integer>` | `buckets()`
    `Optional<NodeSplit>` | `findBestSplit()` Returns best split point computed on histogram if it exists.
    `Optional<Double>` | `getValue(Integer bucketId)`
    `boolean` | `isEqualTo(GiniHistogram other)` Compares histogram with other and returns true if they are equals
    `GiniHistogram` | `plus(GiniHistogram other)`

    - ### Methods inherited from class org.apache.ignite.ml.tree.randomforest.data.impurity.ImpurityHistogram

      `checkAndReturnSplitValue`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GiniHistogram

          public GiniHistogram(int sampleId,
                               Map<Double,Integer> lblMapping,
                               BucketMeta bucketMeta)

      Creates an instance of GiniHistogram.
      Parameters:
        `sampleId` - Sample id.
        `lblMapping` - Label mapping.
        `bucketMeta` - Bucket meta.

  - ### Method Detail

    - #### addElement

          public void addElement(BootstrappedVector vector)

      Add object to histogram.
      Specified by:
        `addElement` in interface `Histogram<BootstrappedVector,GiniHistogram>`
      Parameters:
        `vector` - Value.

    - #### getValue

          public Optional<Double> getValue(Integer bucketId)

      Specified by:
        `getValue` in interface `Histogram<BootstrappedVector,GiniHistogram>`
      Parameters:
        `bucketId` - Bucket id.
      Returns:
        Value in according to bucket id.

    - #### plus

          public GiniHistogram plus(GiniHistogram other)

      Specified by:
        `plus` in interface `Histogram<BootstrappedVector,GiniHistogram>`
      Parameters:
        `other` - Other histogram.
      Returns:
        Sum of this and other histogram.

    - #### findBestSplit

          public Optional<NodeSplit> findBestSplit()

      Returns best split point computed on histogram if it exists. Split point may be absent when there is no data in histograms or split point lay in last bucket in histogram.
      Specified by:
        `findBestSplit` in interface `ImpurityComputer<BootstrappedVector,GiniHistogram>`
      Returns:
        Splitting point for decision tree.

    - #### buckets

          public Set<Integer> buckets()

      Specified by:
        `buckets` in interface `Histogram<BootstrappedVector,GiniHistogram>`
      Returns:
        Bucket ids.

    - #### isEqualTo

          public boolean isEqualTo(GiniHistogram other)

      Compares histogram with other and returns true if they are equals
      Specified by:
        `isEqualTo` in interface `Histogram<BootstrappedVector,GiniHistogram>`
      Parameters:
        `other` - Other histogram.
      Returns:
        True if histograms are equal.

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021