supervised learning
A machine learning paradigm where a model is trained on labeled input-output pairs to learn the mapping from inputs to correct outputs.
Syntax
ai-fundamentals
model.fit(X_train, y_train)
predictions = model.predict(X_test)Example
ai-fundamentals
# Supervised learning with scikit-learn:
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = LogisticRegression()
model.fit(X_train, y_train)
accuracy = model.score(X_test, y_test)
print(f"Accuracy: {accuracy:.2%}")