iris.target is an important attribute within the iris dataset object.
Here's a breakdown of what it is:
- Labels/Target Variable: In the context of machine learning, especially supervised learning,
iris.targetrefers to the labels or target variable for each sample (each flower) in the dataset. It's what we usually want to predict. - Species Information: For the Iris dataset specifically,
iris.targettells you the species of each Iris flower. - Numerical Encoding: The species names (setosa, versicolor, virginica) are not stored as text directly in
iris.target. Instead, they are encoded as integers:0represents 'setosa'1represents 'versicolor'2represents 'virginica'
- NumPy Array: Just like
iris.data,iris.targetis a NumPy array. It contains 150 integer values, one for each of the 150 flower samples. - Correspondence with
iris.data: Each integer iniris.targetcorresponds to the flower measurements (features) in the same row ofiris.data. For example, the first number iniris.targetis the species of the flower described by the first row iniris.data.
In summary, while iris.data gives you the features (measurements) of each flower, iris.target gives you the answer or category (species) for each flower.