dendritic-trees

Crates.iodendritic-trees
lib.rsdendritic-trees
version1.5.0
sourcesrc
created_at2024-10-28 13:25:42.581203
updated_at2024-11-01 19:43:32.763744
descriptionPacakge for tree based modeling
homepage
repository
max_upload_size
id1425618
size843,404
Shay (shaysingh818)

documentation

README

Dendritic Trees Crate

This crate contains all tree based machine learning models. Contains standard decision tree and random forest classifier and regressors.

Features

  • Decision Tree: Standard scalar and min max normlization of data.
  • Random Forest: One hot encoding for multi class data
  • Bootstrap: One hot encoding for multi class data

Disclaimer

The dendritic project is a toy machine learning library built for learning and research purposes. It is not advised by the maintainer to use this library as a production ready machine learning library. This is a project that is still very much a work in progress.

Example Usage

This is an example of using the decision tree classifier model provided by dendritic. The example below uses decision trees but random forest can be used with RandomForestClassifier or RandomForestRegressor.

use dendritic_ndarray::ndarray::NDArray;
use dendritic_ndarray::ops::*;
use dendritic_metrics::loss::*;
use dendritic_metrics::utils::*;
use dendritic_trees::decision_tree::*;
use dendritic_datasets::iris::*;

fn main() {

   // load data
   let data_path = "../dendritic-datasets/data/iris.parquet";
   let max_depth = 3;
   let samples_split = 3; 
   let (x_train_test, y_train_test) = load_iris(data_path).unwrap();
   let (x_train, y_train) = load_all_iris(data_path).unwrap();
   
   // Decision tree classifier model
   let mut model = DecisionTreeClassifier::new(
       max_depth, 
       samples_split, 
       gini_impurity
   );
   model.fit(&x_train, &y_train);

   let sample_index = 100;
   let x_test = x_train_test.batch(5).unwrap();
   let y_test = y_train_test.batch(5).unwrap();
   let y_pred = model.predict(x_test[sample_index].clone());
   println!("Actual: {:?}", y_test[sample_index]);
   println!("Prediction: {:?}", y_pred.values()); 

}
Commit count: 0

cargo fmt