How to access `iris.target`?

QuestionsQuestions8 SkillsProDec, 10 2025
072

To access iris.target, you simply refer to it as an attribute of the iris object.

You've already done it correctly in the code for this step:

from sklearn import datasets

# Load the Iris dataset
iris = datasets.load_iris()

# Access and print the target array
print(iris.target)

By using iris.target, you gain direct access to the NumPy array containing the encoded species labels for all the flowers in the dataset.

Is there anything else unclear about accessing it?

0 Comments

no data
Be the first to share your comment!