How to do hyperparameter tuning with Dask?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

How to do hyperparameter tuning with Dask?

How to do hyperparameter tuning with Dask?

This recipe helps you do hyperparameter tuning with Dask

0

Recipe Objective

How to do hyperparameter tuning with Dask

The hyperparameters controls the quality of the predictions made by models. For example, if learning rate is too small the model will take too much time to learn.

#!pip install dask_ml #!pip install dask distributed --upgrade

Step 1- Importing Libraries

We will have to import multiple libraries to do the tuning of our hyper parameters

from dask.distributed import Client from dask_ml.datasets import make_classification from dask_ml.model_selection import train_test_split from sklearn.linear_model import SGDClassifier from dask_ml.model_selection import HyperbandSearchCV from scipy.stats import uniform, loguniform

Step 2- Instantiating Client.

We will create the client and divide the dataset into train and test.

client = Client() x, y = make_classification(chunks=20, random_state=0) xtrain, xtest, ytrain, ytest = train_test_split(x, y)

Step 3- Instantiating SGD classifier.

We will instantiate SGDClassifier with its parameters.

cls = SGDClassifier(tol=1e-3, penalty='elasticnet', random_state=0)

Step 4- Initializing loss parameters.

We will define the learning rate and L1 loss.

parameters = {'alpha': loguniform(1e-2, 1e0), 'l1_ratio': uniform(0, 1)}

Step 5- Initializing HyperbandSearchCV

We will use the HyperbandSearchCV and insert classifier and parameter model in it to get the best parameters for the model.

search = HyperbandSearchCV(cls, parameters, max_iter=81, random_state=0) search.fit(xtrain, ytrain, classes=[0, 1]) print(search.best_params_) print(search.best_score_) print(search.score(xtest, ytest))

Relevant Projects

Build a Music Recommendation Algorithm using KKBox's Dataset
Music Recommendation Project using Machine Learning - Use the KKBox dataset to predict the chances of a user listening to a song again after their very first noticeable listening event.

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.

Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

Census Income Data Set Project - Predict Adult Census Income
Use the Adult Income dataset to predict whether income exceeds 50K yr based on census data.

Expedia Hotel Recommendations Data Science Project
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

Build a Similar Images Finder with Python, Keras, and Tensorflow
Build your own image similarity application using Python to search and find images of products that are similar to any given product. You will implement the K-Nearest Neighbor algorithm to find products with maximum similarity.

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.

Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

Build a Collaborative Filtering Recommender System in Python
Use the Amazon Reviews/Ratings dataset of 2 Million records to build a recommender system using memory-based collaborative filtering in Python.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.