///|
/// Configures deterministic regression-tree training.
pub(all) struct RegressionConfig {
  max_depth : Int
  min_samples_split : Int
  min_samples_leaf : Int
  min_impurity_decrease : Double
} derive(Eq, Debug)

///|
pub fn RegressionConfig::default() -> RegressionConfig {
  {
    max_depth: 10,
    min_samples_split: 2,
    min_samples_leaf: 1,
    min_impurity_decrease: 0.0,
  }
}

///|
/// Retains prediction and variance statistics for traversal and pruning.
pub(all) enum RegressionNode {
  RegressionLeaf(Double, Int, Double)
  RegressionBranch(
    Int,
    Double,
    RegressionNode,
    RegressionNode,
    Int,
    Double,
    Double
  )
} derive(Eq, Debug)

///|
/// Stores one immutable trained regression tree.
pub(all) struct RegressionTree {
  root : RegressionNode
  feature_total : Int
  config : RegressionConfig
} derive(Eq, Debug)

///|
priv struct RegressionSplit {
  feature_index : Int
  threshold : Double
  gain : Double
}