<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Iris Project
Data Exploration and Analysis
Step1:  Iris Data from Seaborn
Step2:  Visualisation
Step3:  scikit-learn
url = http
Step4:  Key points
Data in the form of a table
Features in the form of a matrix
Label or target array
Step5:  Scikit-Learn API
url = https
Step6:  Step 1. Choose a class of model
Step7:  Step 2. Choose model hyperparameters
Step8:  Step 3. Arrage data into features matrix and target array
Step9:  Step 4. Fit model to data
Step10:  Step 5. Apply trained model to new data
Step11:  Visualise
<ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(color_codes=True)
%matplotlib inline
df = pd.read_csv('iris.data')
df.head()
df = pd.read_csv('iris.data', header=-1)
df.head()
col_name =   ['sepal length', 'sepal width', 'petal length', 'petal width', 'class']
df.columns = col_name
df.head()
Explanation: Iris Project
Data Exploration and Analysis
End of explanation
iris = sns.load_dataset('iris')
iris.head()
df.describe()
iris.describe()
print(iris.info())
print(iris.groupby('species').size())
Explanation: Iris Data from Seaborn
End of explanation
sns.pairplot(iris, hue='species', size=3, aspect=1);
iris.hist(edgecolor='black', linewidth=1.2, figsize=(12,8));
plt.show();
plt.figure(figsize=(12,8));
plt.subplot(2,2,1)
sns.violinplot(x='species', y='sepal_length', data=iris)
plt.subplot(2,2,2)
sns.violinplot(x='species', y='sepal_width', data=iris)
plt.subplot(2,2,3)
sns.violinplot(x='species', y='petal_length', data=iris)
plt.subplot(2,2,4)
sns.violinplot(x='species', y='petal_width', data=iris);
iris.boxplot(by='species', figsize=(12,8));
pd.plotting.scatter_matrix(iris, figsize=(12,10))
plt.show()
sns.pairplot(iris, hue="species",diag_kind="kde");
Explanation: Visualisation
End of explanation
%%HTML
<iframe width=100% height=500 src='http://scikit-learn.org/stable/'></iframe>
Explanation: scikit-learn
url = http://scikit-learn.org/stable/
End of explanation
iris.head()
Explanation: Key points
Data in the form of a table
Features in the form of a matrix
Label or target array
End of explanation
generate_random = np.random.RandomState(0)
x = 10 * generate_random.rand(100)
y = 3 * x + np.random.randn(100)
plt.figure(figsize = (10, 8))
plt.scatter(x, y);
Explanation: Scikit-Learn API
url = https://arxiv.org/abs/1309.0238
General principles
Consistency. All objects (basic or composite) share a consistent interface composed of a limited set of methods. This interface is documented in a consistent manner for all objects. 
Inspection. Constructor parameters and parameter values determined by learning algorithms are stored and exposed as public attributes. 
Non-proliferation of classes. Learning algorithms are the only objects to be represented using custom classes. Datasets are represented as NumPy arrays or SciPy sparse matrices. Hyper-parameter names and values are represented as standard Python strings or numbers whenever possible. This keeps scikitlearn easy to use and easy to combine with other libraries. 
Composition. Many machine learning tasks are expressible as sequences or combinations of transformations to data. Some learning algorithms are also naturally viewed as meta-algorithms parametrized on other algorithms. Whenever feasible, such algorithms are implemented and composed from existing building blocks. 
Sensible defaults. Whenever an operation requires a user-deﬁned parameter, an appropriate default value is deﬁned by the library. The default value should cause the operation to be performed in a sensible way (giving a baseline solution for the task at hand).
Basic Steps of Using Scikit-Learn API
Choose a class of model
Choose model hyperparameters
Arrage data into features matrix and target array
Fit model to data
Apply trained model to new data
Supervised Learning: Simple Linear Regression
End of explanation
from sklearn.linear_model import LinearRegression
Explanation: Step 1. Choose a class of model
End of explanation
model = LinearRegression(fit_intercept=True)
model
Explanation: Step 2. Choose model hyperparameters
End of explanation
X = x.reshape(-1, 1)
X.shape
Explanation: Step 3. Arrage data into features matrix and target array
End of explanation
model.fit(X, y)
model.coef_
model.intercept_
Explanation: Step 4. Fit model to data
End of explanation
x_fit = np.linspace(-1, 11)
X_fit = x_fit.reshape(-1,1)
y_fit = model.predict(X_fit)
Explanation: Step 5. Apply trained model to new data
End of explanation
plt.figure(figsize = (10, 8))
plt.scatter(x, y)
plt.plot(x_fit, y_fit);
Explanation: Visualise
End of explanation
<END_TASK>