From the video series: Introduction to machine learning with scikit-learn
In [2]:
from IPython.display import HTML
HTML('<iframe src=http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data width=300 height=200></iframe>')
Out[2]:
In [3]:
# import load_iris function from datasets module
from sklearn.datasets import load_iris
In [4]:
# save "bunch" object containing iris dataset and its attributes
iris = load_iris()
type(iris)
Out[4]:
In [5]:
# print the iris data
print iris.data
In [6]:
# print the names of the four features
print iris.feature_names
In [7]:
# print integers representing the species of each observation
print iris.target
In [8]:
# print the encoding scheme for species: 0 = setosa, 1 = versicolor, 2 = virginica
print iris.target_names
In [9]:
# check the types of the features and response
print type(iris.data)
print type(iris.target)
In [10]:
# check the shape of the features (first dimension = number of observations, second dimensions = number of features)
print iris.data.shape
In [11]:
# check the shape of the response (single dimension matching the number of observations)
print iris.target.shape
In [12]:
# store feature matrix in "X"
X = iris.data
# store response vector in "y"
y = iris.target
In [1]:
from IPython.core.display import HTML
def css_styling():
styles = open("styles/custom.css", "r").read()
return HTML(styles)
css_styling()
Out[1]: