Prediction on Perceptron using Iris Dataset

in the code below,help me with the predict line writtern,what does the numbers writtern in the predict means

import numpy as np
from sklearn.datasets import load_iris
from sklearn.linear_model import Perceptron
iris = load_iris()
X = iris.data[:, (2, 3)] # petal length, petal width
y = (iris.target == 0).astype(np.int) # Iris Setosa?
per_clf = Perceptron()
per_clf.fit(X, y)
y_pred = per_clf.predict([[2, 0.5]])

iris data set has 4 features by default

But you are building your training data X only using two features ( (2, 3) -> features at index 2 and index 3)

Once your model per_clf is built using fit function, you are making prediction for a new instance. And the instance should have 2 features which you are passing as 2 and 0.5.

1 Like