Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vihar
Last active December 13, 2019 10:50
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/d8eb696c2ecbaf7626003d62f099cdab to your computer and use it in GitHub Desktop.
Save vihar/d8eb696c2ecbaf7626003d62f099cdab to your computer and use it in GitHub Desktop.
# Importing Modules
from sklearn import datasets
import matplotlib.pyplot as plt
# Loading dataset
iris_df = datasets.load_iris()
# Available methods on dataset
print(dir(iris_df))
# Features
print(iris_df.feature_names)
# Targets
print(iris_df.target)
# Target Names
print(iris_df.target_names)
label = {0: 'red', 1: 'blue', 2: 'green'}
# Dataset Slicing
x_axis = iris_df.data[:, 0] # Sepal Length
y_axis = iris_df.data[:, 2] # Sepal Width
# Plotting
plt.scatter(x_axis, y_axis, c=iris_df.target)
plt.show()
@Gayathri-STC
Copy link

I have run the above code. But it shows the below error message

from sklearn import datasets
ModuleNotFoundError: No module named 'sklearn'

@nimish0511
Copy link

@Gayathri-STC use pip install -U scikit-learn scipy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment