Search in sources :

Example 1 with NormalDistributionStatistics

use of org.apache.ignite.ml.tree.randomforest.data.statistics.NormalDistributionStatistics in project ignite by apache.

the class RandomForestTrainer method computeHistogramMeta.

/**
 * Compute bucket metas based on feature metas and learning dataset.
 *
 * @param meta    Features meta.
 * @param dataset Dataset.
 * @return bucket metas.
 */
private Map<Integer, BucketMeta> computeHistogramMeta(List<FeatureMeta> meta, Dataset<EmptyContext, BootstrappedDatasetPartition> dataset) {
    List<NormalDistributionStatistics> stats = new NormalDistributionStatisticsComputer().computeStatistics(meta, dataset);
    if (stats == null)
        return Collections.emptyMap();
    Map<Integer, BucketMeta> bucketsMeta = new HashMap<>();
    for (int i = 0; i < stats.size(); i++) {
        BucketMeta bucketMeta = new BucketMeta(meta.get(i));
        if (!bucketMeta.getFeatureMeta().isCategoricalFeature()) {
            NormalDistributionStatistics stat = stats.get(i);
            bucketMeta.setMinVal(stat.min());
            bucketMeta.setBucketSize(stat.std() * BUCKET_SIZE_FACTOR);
        }
        bucketsMeta.put(i, bucketMeta);
    }
    return bucketsMeta;
}
Also used : HashMap(java.util.HashMap) NormalDistributionStatisticsComputer(org.apache.ignite.ml.tree.randomforest.data.statistics.NormalDistributionStatisticsComputer) NormalDistributionStatistics(org.apache.ignite.ml.tree.randomforest.data.statistics.NormalDistributionStatistics) BucketMeta(org.apache.ignite.ml.dataset.feature.BucketMeta)

Aggregations

HashMap (java.util.HashMap)1 BucketMeta (org.apache.ignite.ml.dataset.feature.BucketMeta)1 NormalDistributionStatistics (org.apache.ignite.ml.tree.randomforest.data.statistics.NormalDistributionStatistics)1 NormalDistributionStatisticsComputer (org.apache.ignite.ml.tree.randomforest.data.statistics.NormalDistributionStatisticsComputer)1