predict()

noun

say it: “prih-DIKT” /prɪˈdɪkt/

In scikit-learn, the method that uses a trained model to guess the answer for new examples, one guess per row.

What does predict() do in scikit-learn?

predict() uses a fitted model to guess an answer for each row of new features: model.predict(X) hands back one guess per row. The model must have been trained with fit() first.

from sklearn.linear_model import LinearRegression
model = LinearRegression().fit([[60], [70], [80]], [20, 40, 60])
print(model.predict([[75], [90]]))   # [50. 80.]: cups for a 75° and a 90° day

In a sentence

  • “She passed next week's forecast to predict() to plan how much lemonade to make.”
  • “predict() guessed 50 cups for a 75-degree day.”

Level: Apprentice · More Python terms at this level

Updated