0% found this document useful (0 votes)
2 views2 pages

Supervised Learning Basics and Examples

A brief introduction to supervised learning in machine learning and AI

Uploaded by

Sravan Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Supervised Learning Basics and Examples

A brief introduction to supervised learning in machine learning and AI

Uploaded by

Sravan Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to Supervised Learning

Supervised learning is a type of machine learning in which the algorithm is trained on labeled data.

This means that for each input, the corresponding output (or label) is provided, and the algorithm

learns to map the inputs to the correct outputs.

Examples of supervised learning tasks include:

- Predicting house prices based on features such as size, location, and condition.

- Classifying emails as spam or not spam.

- Recognizing handwritten digits from images.

Supervised learning can be further divided into:

1. Regression: Predicting continuous outputs (e.g., predicting temperature).

2. Classification: Predicting discrete labels (e.g., identifying if an email is spam).

Python Coding Example

# Example: Classification using scikit-learn

from [Link] import load_iris

from sklearn.model_selection import train_test_split

from [Link] import RandomForestClassifier

from [Link] import accuracy_score

# Load dataset

data = load_iris()

X, y = [Link], [Link]
# Split into training and testing data

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Train the model

clf = RandomForestClassifier()

[Link](X_train, y_train)

# Make predictions

predictions = [Link](X_test)

# Evaluate the model

print("Accuracy:", accuracy_score(y_test, predictions))

Exercises

1. Load the Boston housing dataset and train a regression model to predict

house prices.

2. Use the MNIST dataset to classify handwritten digits using a neural network.

3. Experiment with different classifiers (e.g., SVM, Decision Tree) on the Iris

dataset.

4. Implement cross-validation and check how it affects model performance.

You might also like