MACHINE LEARNING RECIPES
# How to find optimal parameters using GridSearchCV for Regression?

# How to find optimal parameters using GridSearchCV for Regression?

This recipe helps you find optimal parameters using GridSearchCV for Regression

In [1]:

```
def Snippet_197():
print()
print(format('How to find parameters using GridSearchCV for Regression','*^82'))
import warnings
warnings.filterwarnings("ignore")
# load libraries
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import GradientBoostingRegressor
# load the iris datasets
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)
model = GradientBoostingRegressor()
parameters = {'learning_rate': [0.01,0.02,0.03],
'subsample' : [0.9, 0.5, 0.2],
'n_estimators' : [100,500,1000],
'max_depth' : [4,6,8]
}
grid = GridSearchCV(estimator=model, param_grid = parameters, cv = 2, n_jobs=-1)
grid.fit(X_train, y_train)
# Results from Grid Search
print("\n========================================================")
print(" Results from Grid Search " )
print("========================================================")
print("\n The best estimator across ALL searched params:\n",
grid.best_estimator_)
print("\n The best score across ALL searched params:\n",
grid.best_score_)
print("\n The best parameters across ALL searched params:\n",
grid.best_params_)
print("\n ========================================================")
Snippet_197()
```

Deep Learning Project- Learn about implementation of a machine learning algorithm using autoencoders for anomaly detection.

In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

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

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.

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.

In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.