What does the function load_iris()
do ?
Also, I don't understand what type of data it contains and where to find it.
iris = datasets.load_iris()
X = iris.data
target = iris.target
names = iris.target_names
Can somebody please tell in detail what does this piece of code does? Thanks in advance.
To thread off the previous comments and posts from above, wanted to add another way to load iris() besides iris = datasets.load_iris()
from sklearn.datasets import load_iris
iris = load_iris()
Then, you can do:
X = iris.data
target = iris.target
names = iris.target_names
And see posts and comments from other people here.
And you can make a dataframe with :
df = pd.DataFrame(X, columns=iris.feature_names)
df['species'] = iris.target
df['species'] = df['species'].replace(to_replace= [0, 1, 2], value = ['setosa', 'versicolor', 'virginica'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With