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
.
- Create an enviroment
conda create --name sklearn_mod
- Activate the environemnt
conda activate sklearn_mod
- Install the prerequisites
pip install cython numpy scipy
conda install -c conda-forge sphinx-gallery joblib threadpoolctl
- Clone this repository
git clone https://github.com/ayan-iiitd/scikit-learn.git
- Get inside the repo directory
cd scikit-learn
- Install the package
pip install --verbose --no-build-isolation --editable .
- 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))