load_iris
- sklearn.datasets.load_iris(*, return_X_y=False, as_frame=False)
Load and return the iris dataset (classification).
The iris dataset is a classic and very easy multi-class classification dataset.
Classes
3
Load and return the iris dataset (classification).
The iris dataset is a classic and very easy multi-class classification dataset.
Classes | 3 |
Samples per class |
50 |
Samples total | 150 |
Dimensionality | 4 |
Features | real, positive |
Read more in the User Guide.
If True, returns (data, target) instead of a Bunch object. See
below for more information about the data and target objects.
If True, the data is a pandas DataFrame including columns with
appropriate dtypes (numeric). The target is
a pandas DataFrame or Series depending on the number of target columns.
If return_X_y is True, then (data, target) will be pandas
DataFrames or Series as described below.
BunchDictionary-like object, with the following attributes.
The data matrix. If as_frame=True, data will be a pandas
DataFrame.
The classification target. If as_frame=True, target will be
a pandas Series.
The names of the dataset columns.
Let’s say you are interested in the samples 10, 25, and 50, and want to know their class name.
>>> from sklearn.datasets import load_iris
>>> data = load_iris()
>>> samples = [10, 25, 50]
>>> data.target[samples]
array([0, 0, 1])
>>> data.target_names[data.target[samples]]
array(['setosa', 'setosa', 'versicolor'], dtype='<U10')
See Principal Component Analysis (PCA) on Iris Dataset for a more detailed example of how to work with the iris dataset.
Principal Component Analysis (PCA) on Iris Dataset
Comparison of LDA and PCA 2D projection of Iris dataset
Factor Analysis (with rotation) to visualize patterns
Plot the decision surfaces of ensembles of trees on the iris dataset
Gaussian process classification (GPC) on iris dataset
Evaluate the performance of a classifier with Confusion Matrix
Test with permutations the significance of a classification score
Multiclass Receiver Operating Characteristic (ROC)
Receiver Operating Characteristic (ROC) with cross validation
Comparing Nearest Neighbors with and without Neighborhood Components Analysis
Compare Stochastic learning strategies for MLPClassifier
Decision boundary of semi-supervised classifiers versus SVM on the Iris dataset
Plot different SVM classifiers in the iris dataset
Plot the decision surface of decision trees trained on the iris dataset
The names of target classes.
Only present when as_frame=True. DataFrame with data and
target.
The full description of the dataset.
The path to the location of the data.
return_X_y is TrueA tuple of two ndarrays. The first contains a 2D array of
shape (150, 4) with each row representing one sample and the columns
representing the features. The second ndarray of shape (150,) contains
the target samples. If as_frame=True, both arrays are pandas objects,
i.e. X a dataframe and y a series.