Skip to content

Instantly share code, notes, and snippets.

@vihar
Created January 28, 2018 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vihar/debab263007a49aa95f9b80d8bf03d4f to your computer and use it in GitHub Desktop.
Save vihar/debab263007a49aa95f9b80d8bf03d4f to your computer and use it in GitHub Desktop.
from sklearn import datasets
import pandas as pd
import matplotlib.pyplot as plt
# Loading IRIS dataset from scikit-learn object into iris variable.
iris = datasets.load_iris()
# Prints the type/type object of iris
print(type(iris))
# <class 'sklearn.datasets.base.Bunch'>
# prints the dictionary keys of iris data
print(iris.keys())
# prints the type/type object of given attributes
print(type(iris.data), type(iris.target))
# prints the no of rows and columns in the dataset
print(iris.data.shape)
# prints the target set of the data
print(iris.target_names)
# Load iris training dataset
X = iris.data
# Load iris target set
Y = iris.target
# Convert datasets' type into dataframe
df = pd.DataFrame(X, columns=iris.feature_names)
# Print the first five tuples of dataframe.
print(df.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment