/scikit-learn

scikit-learn: machine learning in Python

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Here we have added a new criterion function to Scikit Learn's Decision Tree/Random Forest algorithm.

We strongly advice that this package be tested inside a separate environment. At this moment we are using a conda environment to deelop this project, so instructions for building the same using pip.

Steps to test

  1. Create an enviroment conda create --name sklearn_mod
  2. Activate the environemnt conda activate sklearn_mod
  3. Install the prerequisites
    1. pip install cython numpy scipy
    2. conda install -c conda-forge sphinx-gallery joblib threadpoolctl
  4. Clone this repository git clone https://github.com/ayan-iiitd/scikit-learn.git
  5. Get inside the repo directory cd scikit-learn
  6. Install the package pip install --verbose --no-build-isolation --editable .
  7. The Barron Loss function can be tested with using something similar to the following -
from sklearn.ensemble import RandomForestRegressor
from sklearn import metrics
from sklearn.model_selection import train_test_split

def func(X,y,a):    
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.20)
    print('Calling Random Forest Function')
    rg = RandomForestRegressor(criterion='barron',alpha=a)
    rg.fit(X_train, y_train)
    y_pred = rg.predict(X_test)
    print('Mean Absolute Error:', metrics.mean_absolute_error(y_test, y_pred))
    print('Mean Squared Error:', metrics.mean_squared_error(y_test, y_pred))