koho.cpp  1.1.0
Public Member Functions | Public Attributes | Protected Attributes | List of all members
koho::BestSplitter Class Reference

Splitter to find the best split for a node. More...

#include <decision_tree.h>

Collaboration diagram for koho::BestSplitter:
Collaboration graph
[legend]

Public Member Functions

 BestSplitter (OutputsIdx_t n_outputs, ClassesIdx_t *n_classes, ClassesIdx_t n_classes_max, FeaturesIdx_t n_features, SamplesIdx_t n_samples, ClassWeights_t *class_weight, FeaturesIdx_t max_features, unsigned long max_thresholds, RandomState const &random_state)
 Create and initialize a new best splitter. More...
 
void init_node (Classes_t *y, SamplesIdx_t start, SamplesIdx_t end)
 Initialize node and calculate weighted histograms for all outputs and impurity for the node. More...
 
void split_feature (Features_t *X, Classes_t *y, std::vector< SamplesIdx_t > &s, FeaturesIdx_t feature, int &NA, Features_t &threshold, SamplesIdx_t &pos, double &improvement)
 Find the best split and partition (actually sorted) samples for a given feature. More...
 
void split_feature_extreme_random (Features_t *X, Classes_t *y, std::vector< SamplesIdx_t > &s, FeaturesIdx_t feature, int &NA, Features_t &threshold, SamplesIdx_t &pos, double &improvement)
 
void split_node (Features_t *X, Classes_t *y, FeaturesIdx_t &feature, int &NA, Features_t &threshold, SamplesIdx_t &pos, double &improvement)
 Find the best split and partition (actually sorted) samples. More...
 

Public Attributes

GiniCriterion criterion
 

Protected Attributes

FeaturesIdx_t n_features
 
SamplesIdx_t n_samples
 
FeaturesIdx_t max_features
 
unsigned long max_thresholds
 
RandomState random_state
 
std::vector< SamplesIdx_tsamples
 
SamplesIdx_t start
 
SamplesIdx_t end
 

Detailed Description

Splitter to find the best split for a node.

Constructor & Destructor Documentation

◆ BestSplitter()

koho::BestSplitter::BestSplitter ( OutputsIdx_t  n_outputs,
ClassesIdx_t n_classes,
ClassesIdx_t  n_classes_max,
FeaturesIdx_t  n_features,
SamplesIdx_t  n_samples,
ClassWeights_t class_weight,
FeaturesIdx_t  max_features,
unsigned long  max_thresholds,
RandomState const &  random_state 
)

Create and initialize a new best splitter.

Member Function Documentation

◆ init_node()

void koho::BestSplitter::init_node ( Classes_t y,
SamplesIdx_t  start,
SamplesIdx_t  end 
)

Initialize node and calculate weighted histograms for all outputs and impurity for the node.

◆ split_feature()

void koho::BestSplitter::split_feature ( Features_t X,
Classes_t y,
std::vector< SamplesIdx_t > &  s,
FeaturesIdx_t  feature,
int &  NA,
Features_t threshold,
SamplesIdx_t pos,
double &  improvement 
)

Find the best split and partition (actually sorted) samples for a given feature.

◆ split_feature_extreme_random()

void koho::BestSplitter::split_feature_extreme_random ( Features_t X,
Classes_t y,
std::vector< SamplesIdx_t > &  s,
FeaturesIdx_t  feature,
int &  NA,
Features_t threshold,
SamplesIdx_t pos,
double &  improvement 
)

Find a split and partition samples for a given feature using the Extreme Random Tree formulation for the threshold.

◆ split_node()

void koho::BestSplitter::split_node ( Features_t X,
Classes_t y,
FeaturesIdx_t feature,
int &  NA,
Features_t threshold,
SamplesIdx_t pos,
double &  improvement 
)

Find the best split and partition (actually sorted) samples.

Find the split (feature, threshold) on samples[start:end] and partition samples[start:end] into samples[start:pos] and samples[pos:end] according to split.

Assuming: init_node()

Member Data Documentation

◆ criterion

GiniCriterion koho::BestSplitter::criterion

◆ end

SamplesIdx_t koho::BestSplitter::end
protected

◆ max_features

FeaturesIdx_t koho::BestSplitter::max_features
protected

◆ max_thresholds

unsigned long koho::BestSplitter::max_thresholds
protected

◆ n_features

FeaturesIdx_t koho::BestSplitter::n_features
protected

◆ n_samples

SamplesIdx_t koho::BestSplitter::n_samples
protected

◆ random_state

RandomState koho::BestSplitter::random_state
protected

◆ samples

std::vector<SamplesIdx_t> koho::BestSplitter::samples
protected

◆ start

SamplesIdx_t koho::BestSplitter::start
protected

The documentation for this class was generated from the following files: