<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Title
Step1:  Load Iris Dataset
Step2:  Create Logistic Regression
Step3:  Create Hyperparameter Search Space
Step4:  Create Grid Search
Step5:  Conduct Grid Search
Step6:  View Hyperparameter Values Of Best Model
Step7:  Predict Using Best Model
<ASSISTANT_TASK:>
Python Code:
# Load libraries
import numpy as np
from sklearn import linear_model, datasets
from sklearn.model_selection import GridSearchCV
Explanation: Title: Hyperparameter Tuning Using Grid Search
Slug: hyperparameter_tuning_using_grid_search
Summary: How to conduct grid search for hyperparameter tuning in scikit-learn for machine learning in Python. 
Date: 2017-09-18 12:00
Category: Machine Learning
Tags: Model Selection
Authors: Chris Albon
<a alt="Hyperparameter Tuning Using Grid Search" href="https://machinelearningflashcards.com">
    <img src="hyperparameter_tuning_using_grid_search/Hyperparameter_Tuning_print.png" class="flashcard center-block">
</a>
Preliminaries
End of explanation
# Load data
iris = datasets.load_iris()
X = iris.data
y = iris.target
Explanation: Load Iris Dataset
End of explanation
# Create logistic regression
logistic = linear_model.LogisticRegression()
Explanation: Create Logistic Regression
End of explanation
# Create regularization penalty space
penalty = ['l1', 'l2']
# Create regularization hyperparameter space
C = np.logspace(0, 4, 10)
# Create hyperparameter options
hyperparameters = dict(C=C, penalty=penalty)
Explanation: Create Hyperparameter Search Space
End of explanation
# Create grid search using 5-fold cross validation
clf = GridSearchCV(logistic, hyperparameters, cv=5, verbose=0)
Explanation: Create Grid Search
End of explanation
# Fit grid search
best_model = clf.fit(X, y)
Explanation: Conduct Grid Search
End of explanation
# View best hyperparameters
print('Best Penalty:', best_model.best_estimator_.get_params()['penalty'])
print('Best C:', best_model.best_estimator_.get_params()['C'])
Explanation: View Hyperparameter Values Of Best Model
End of explanation
# Predict target vector
best_model.predict(X)
Explanation: Predict Using Best Model
End of explanation
<END_TASK>