Skip to content

Instantly share code, notes, and snippets.

@gkhayes
Last active January 21, 2019 06:49
Show Gist options
  • Select an option

  • Save gkhayes/dbc36174d58adff0106e15f94854dbe4 to your computer and use it in GitHub Desktop.

Select an option

Save gkhayes/dbc36174d58adff0106e15f94854dbe4 to your computer and use it in GitHub Desktop.
Load and explore Iris dataset
from sklearn.datasets import load_iris
# Load the Iris dataset
data = load_iris()
# Get feature values
print('The feature values for Obs 0 are: ', data.data[0])
# Get feature names
print('The feature names are: ', data.feature_names)
# Get target value of first observation
print('The target value for Obs 0 is:', data.target[0])
# Get target name of first observation
print('The target name for Obs 0 is:', data.target_names[data.target[0]])
# Get minimum feature values
print('The minimum values of the four features are:', np.min(data.data, axis = 0))
# Get maximum feature values
print('The maximum values of the four features are:', np.max(data.data, axis = 0))
# Get unique target values
print('The unique target values are:', np.unique(data.target))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment