%matplotlib inline
%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import mglearn
import sys
print(“Python version:{}”.format(sys.version))
Python version:3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
import pandas as pd
print(“pandas version:{}”.format(pd.version))
pandas version:0.22.0
import matplotlib
print(“matplotlib version:{}”.format(matplotlib.version))
matplotlib version:2.1.2
import numpy as np
print(“Numpy version:{}”.format(np.version))
Numpy version:1.14.0
import scipy as sp
print(“SciPy version:{}”.format(sp.version))
SciPy version:1.0.0
import IPython
print(“IPython version:{}”.format(IPython.version))
IPython version:6.2.1
import sklearn
print(“scikit-learn version:{}”.format(sklearn.version))
scikit-learn version:0.19.1
A first application:Classifying Iris Species
Goal:build a machine learning model that can learn from the measurements of these irises whose species is known, and we can predicted the species the new iris.
Because we have measurement for which we know the correct species ,so this machine learning is a Supervised Learning.and this a classification Problem,the output called :”classes”.
The desired output for a single data is the species this flower, the species it belongs to is call “label”
For example:
#this a c;assical dataset in the machine learning and statistics so we can call the "load_iris "function in the scikit-learn
from sklearn.datasets import load_iris
iris_dataset=load_iris()
#the iris object is return by load_iris(which seems like a dictory which has keys and values )
print(“Keys of iris_dataset:\n{}”.format(iris_dataset.keys()))
Keys of iris_dataset:
dict_keys([‘data’, ‘target’, ‘target_names’, ‘DESCR’, ‘feature_names’])
print(iris_dataset[‘DESCR’][:]+"\n")
Iris Plants Database
Notes
Data Set Characteristics:
:Number of Instances: 150 (50 in each of three classes)
:Number of Attributes: 4 numeric, predictive attributes and the class
:Attribute Information:
- sepal length in cm
- sepal width in cm
- petal length in cm
- petal width in cm
- class:
- Iris-Setosa
- Iris-Versicolour
- Iris-Virginica
:Summary Statistics:
============== ====