0% found this document useful (0 votes)
6 views4 pages

Implementation of Supervised Learning Algorithm

The document outlines the implementation of supervised learning algorithms, focusing on classification and regression models. It provides a step-by-step guide to using Python and relevant libraries to predict outcomes based on input data, including examples for predicting pass/fail and marks based on study hours. The document also includes basic assignments for further practice and emphasizes the importance of data format and model training.

Uploaded by

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

Implementation of Supervised Learning Algorithm

The document outlines the implementation of supervised learning algorithms, focusing on classification and regression models. It provides a step-by-step guide to using Python and relevant libraries to predict outcomes based on input data, including examples for predicting pass/fail and marks based on study hours. The document also includes basic assignments for further practice and emphasizes the importance of data format and model training.

Uploaded by

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

Title: Implementation of Supervised Learning Algorithm

1. Objective

To understand the basics of supervised learning and implement simple classification and regression
models.

2. Theory (Simple Explanation)

Supervised Learning is a type of machine learning where:

 Input data (X) and output (Y) are already known.

 The model learns from this data and predicts results for new inputs.

🔹 Types:

1. Classification → Output is categories


Example: Pass/Fail

2. Regression → Output is numbers


Example: Marks prediction

3. Tools Required

 Python

 Jupyter Notebook / Google Colab

 Libraries:

o pandas

o numpy

o sklearn

4. Basic Steps

1. Import libraries

2. Load dataset

3. Split data (Training & Testing)

4. Train model

5. Predict output

6. Check accuracy

Experiment 1: Simple Classification (Pass/Fail)


5. Problem Statement

Predict whether a student will pass or fail based on study hours.

6. Steps

Step 1: Import Libraries

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression

Step 2: Create Dataset

data = {
'Hours': [1, 2, 3, 4, 5, 6, 7, 8],
'Result': [0, 0, 0, 0, 1, 1, 1, 1]
}
df = [Link](data)

Step 3: Split Data

X = df[['Hours']]
y = df['Result']

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

Step 4: Train Model

model = LogisticRegression()
[Link](X_train, y_train)

Step 5: Predict

prediction = [Link]([[5]])
print("Prediction (0=Fail, 1=Pass):", prediction)

7. Expected Output

 Output: 0 or 1

 Shows prediction of pass/fail

8. Experiment 2: Simple Regression (Marks Prediction)

📌 Problem Statement

Predict marks based on study hours.


9. Steps

Step 1: Import Library

from sklearn.linear_model import LinearRegression

Step 2: Dataset

data = {
'Hours': [1, 2, 3, 4, 5],
'Marks': [20, 40, 50, 70, 90]
}
df = [Link](data)

Step 3: Train Model

X = df[['Hours']]
y = df['Marks']

model = LinearRegression()
[Link](X, y)

Step 4: Predict

print("Predicted Marks:", [Link]([[6]]))

10. Expected Output

 Numeric value (predicted marks)

11. LAB TASKS (Basic Assignments)

✅ Task 1: Modify Dataset

 Change values of hours and results

 Observe change in prediction

✅ Task 2: Add More Data

 Add at least 5 more entries

 Retrain model

✅ Task 3: Accuracy Check


from [Link] import accuracy_score
y_pred = [Link](X_test)
print("Accuracy:", accuracy_score(y_test, y_pred))

✅ Task 4: Try New Input

 Give different study hours

 Check output

12. Result

 Learned how to train simple supervised models

 Successfully predicted outputs using basic datasets

13. Precautions

 Use correct data format

 Do not mix input/output columns

 Always train before prediction

14. Viva Questions

1. What is supervised learning?

2. Difference between classification and regression?

3. What is training data?

4. What is prediction?

5. What is accuracy?

15. Conclusion

This experiment helps beginners understand how machines learn from data and make predictions
using simple algorithms.

You might also like