how to read iris data in python

Solutions on MaxInterview for how to read iris data in python by the best coders in the world

showing results for - "how to read iris data in python"
Viktoria
17 Nov 2016
1print(__doc__)
2
3
4# Code source: Gaël Varoquaux
5# Modified for documentation by Jaques Grobler
6# License: BSD 3 clause
7
8import matplotlib.pyplot as plt
9from mpl_toolkits.mplot3d import Axes3D
10from sklearn import datasets
11from sklearn.decomposition import PCA
12
13# import some data to play with
14iris = datasets.load_iris()
15X = iris.data[:, :2]  # we only take the first two features.
16y = iris.target
17
18x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
19y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
20
21plt.figure(2, figsize=(8, 6))
22plt.clf()
23
24# Plot the training points
25plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Set1,
26            edgecolor='k')
27plt.xlabel('Sepal length')
28plt.ylabel('Sepal width')
29
30plt.xlim(x_min, x_max)
31plt.ylim(y_min, y_max)
32plt.xticks(())
33plt.yticks(())
34
35# To getter a better understanding of interaction of the dimensions
36# plot the first three PCA dimensions
37fig = plt.figure(1, figsize=(8, 6))
38ax = Axes3D(fig, elev=-150, azim=110)
39X_reduced = PCA(n_components=3).fit_transform(iris.data)
40ax.scatter(X_reduced[:, 0], X_reduced[:, 1], X_reduced[:, 2], c=y,
41           cmap=plt.cm.Set1, edgecolor='k', s=40)
42ax.set_title("First three PCA directions")
43ax.set_xlabel("1st eigenvector")
44ax.w_xaxis.set_ticklabels([])
45ax.set_ylabel("2nd eigenvector")
46ax.w_yaxis.set_ticklabels([])
47ax.set_zlabel("3rd eigenvector")
48ax.w_zaxis.set_ticklabels([])
49
50plt.show()
51
queries leading to this page
python display iris datasetwhat is an iris datasethow to access iris dataset in pythonimport iris dataset in python as dataframehow to load the iris dataset in pythonimport iris datasetiris dataset analysis pythonplotting iris dataset in pythoniris data pythoniris dataset classification pythonpandas iris datasethow to load iris dataset in pythonwhat is iris dataset in pythoniris dataset pythoniris data pythonhow to load the iris dataset in rhow to read iris dataset in pythonanalysis of iris dataset using pythonload iris datasetiris dataset in which modulepython load iris datasetload iris dataset in pythonimporting iris datasetneeded to load the iris datasetiris dataset informationclassification iris dataset pythonhow to import iris dataset in pythonhow to view iris dataset in pythonget iris data in sklearniris dataset importdisplay iris datasetiris dataset in pythonpandas get iris datasetimport iris data in pythonload the iris dataset in pythonpython pandas load iris datasethow to represent iris dataframe in pythondata 28iris 29python iris datasetiris 3d data load iris 28 29load iris pandashow to get iris dataset in python pdiris data in python iris dataset pythonhow to classify iris datasethow to use iris dataset in pythonload iris dataset in python as dataframethe iris datasetimport iris in pyhtonpython iris dataplotting iris data in pythonimport iris dataset in pythonhow to import iris dataset from sklearnturn iris into a dataframe in pythonunderstanding iris datasethow to read iris data in python