Created
May 3, 2015 10:55
-
-
Save dimi-tree/942def7766c410bbc43a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.read_csv( | |
'http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data', | |
names = ['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)', 'class'] | |
) | |
# store feature matrix in "X" | |
X = df.drop('class', axis=1).values | |
levels = {'Iris-setosa': 0, 'Iris-versicolor': 1, 'Iris-virginica':2} | |
# map 'class' column to numberic and store response vector in "y" | |
y = df['class'].map(lambda x: levels[x]).values | |
# check the types of the features and response | |
print type(X) | |
print type(y) | |
# check the shape of the features | |
print X.shape | |
# check the shape of the response | |
print y.shape |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment