- Notifications
You must be signed in to change notification settings - Fork1
Python package to simplify plotting of common evaluation metrics for regression models. Metrics included are pearson correlation coefficient (r), coefficient of determination (r-squared), mean squared error (mse), root mean squared error(rmse), root mean squared relative error (rmsre), mean absolute error (mae), mean absolute percentage error (m…
License
ajayarunachalam/RegressorMetricGraphPlot
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
PyPI:https://pypi.org/project/regressormetricgraphplot/
Python implementations for comparing different Regression Models and Plotting with their most common evaluation metrics.
The purpose of this package is to help users plot the graph at ease with different widely used metrics for regression model evaluation for comparing them at a glance
Figure: Model evaluation plot with widely used metrics
# Importing librariesfromsklearn.datasetsimportmake_regressionfromsklearn.model_selectionimporttrain_test_splitfromsklearn.linear_modelimportLinearRegressionfromregressormetricgraphplotimport*%matplotlibinline
#Let's load a simple dataset and make a train & test set :X,y=make_regression(n_samples=1000,n_features=10,n_informative=7,n_targets=1,random_state=0)X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=10)
# Train the regressor and predict on test set# Fitting training set to linear regression modellr=LinearRegression(n_jobs=-1)lr.fit(X_train,y_train)# Predictingy_pred=lr.predict(X_test)
We can now useR2AndRMSE
to compute & output R-squared, and Root Mean Square Error.
# MetricsCompareModels.R2AndRMSE(y_test=y_test,y_pred=y_pred)
Make object of the classCompareModels
plot=CompareModels()
We can now useadd
&show
method to add the built model & plot the graph at ease with all the evaluated metrics.
plot.add(model_name='Linear Regression',y_test=y_test,y_pred=y_pred)plot.show(figsize=(10,5))
$ pip install regressormetricgraphplot OR$ git clone https://github.com/ajayarunachalam/RegressorMetricGraphPlot$ cd RegressorMetricGraphPlot$ python setup.py install
!pip install regressormetricgraphplot & import as 'from regressormetricgraphplot import *' OR!git clone https://github.com/ajayarunachalam/RegressorMetricGraphPlot.gitcd RegressorMetricGraphPlot/Just replace the line 'from CompareModels import *' with 'from regressormetricgraphplot import CompareModels'
Follow the rest as demonstrated in the demo example [here] -- (https://github.com/ajayarunachalam/RegressorMetricGraphPlot/blob/main/regressormetricgraphplot/demo.ipynb)
If you installed your Python with Anacoda you can run the following commands to get started:
# Clone the repositorygit clone https://github.com/ajayarunachalam/RegressorMetricGraphPlot.gitcd RegressorMetricGraphPlot# Create new conda environment with Python 3.6conda create --new your-env-name python=3.6# Activate the environmentconda activate your-env-name# Install conda dependenciesconda install --yes --file conda_requirements.txt# Instal pip dependenciespip install requirements.txt
Navigate to the demo example in a form of iPython notebooks: --here
* demo.ipynb
If there's some implementation you would like to see here or add in some examples feel free to do so. You can reach me atemail
About
Python package to simplify plotting of common evaluation metrics for regression models. Metrics included are pearson correlation coefficient (r), coefficient of determination (r-squared), mean squared error (mse), root mean squared error(rmse), root mean squared relative error (rmsre), mean absolute error (mae), mean absolute percentage error (m…
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.