Supervised learning is a machine learning approach in which a model learns from labeled training data to make predictions or decisions on unseen data. In supervised learning, the algorithm is presented with input features and corresponding target labels, and it learns the mapping between the inputs and outputs. Examples of supervised learning algorithms include linear regression, decision trees, and support vector machines. Here's an example of training a decision tree classifier using scikit-learn:
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
# Load the dataset
iris = datasets.load_iris()
X = iris.data
y = iris.target
# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Initialize the model
model = DecisionTreeClassifier()
# Train the model
model.fit(X_train, y_train)
# Make predictions on the test set
y_pred = model.predict(X_test)