How to use Regression Metrics in Python?
MACHINE LEARNING RECIPES

How to use Regression Metrics in Python?

How to use Regression Metrics in Python?

This recipe helps you use Regression Metrics in Python

0
In [1]:
## How to use Regression Metrics in Python
## DataSet: skleran.load_boston()
def Snippet_182():
    print()
    print(format('How to use Regression Metrics in Python','*^82'))
    import warnings
    warnings.filterwarnings("ignore")

    # load libraries
    from sklearn import datasets
    from sklearn import tree, model_selection
    from sklearn.model_selection import train_test_split
    import matplotlib.pyplot as plt

    plt.style.use('ggplot')

    # load the iris datasets
    seed = 42
    dataset = datasets.load_boston()
    X = dataset.data; y = dataset.target
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
    kfold = model_selection.KFold(n_splits=10, random_state=seed)
    # fit a tree.DecisionTreeClassifier() model to the data
    model = tree.DecisionTreeRegressor()

    # metrics -> Mean Absolute Error
    scoring = 'neg_mean_absolute_error'
    results = model_selection.cross_val_score(model, X_train, y_train, cv=kfold, scoring=scoring)
    print(); print("Mean Absolute Error: ", results.mean()); print("Standard Deviation: ", results.std())

    # metrics -> Mean Squred Error
    scoring = 'neg_mean_squared_error'
    results = model_selection.cross_val_score(model, X_train, y_train, cv=kfold, scoring=scoring)
    print(); print("Mean Squared Error: ", results.mean()); print("Standard Deviation: ", results.std())

    # metrics -> R squared
    scoring = 'r2'
    results = model_selection.cross_val_score(model, X_train, y_train, cv=kfold, scoring=scoring)
    print(); print("R squared val: ", results.mean()); print("Standard Deviation: ", results.std())
Snippet_182()
*********************How to use Regression Metrics in Python**********************

Mean Absolute Error:  -3.0952560455192035
Standard Deviation:  0.4539146116435922

Mean Squared Error:  -21.0677652916074
Standard Deviation:  9.255250927975112

R squared val:  0.7561802285707946
Standard Deviation:  0.1692887494698974

Relevant Projects

Solving Multiple Classification use cases Using H2O
In this project, we are going to talk about H2O and functionality in terms of building Machine Learning models.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.

Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

Choosing the right Time Series Forecasting Methods
There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.