Code Monkey home page Code Monkey logo

implementation-of-simple-linear-regression-model-for-predicting-the-marks-scored's Introduction

Implementation-of-Simple-Linear-Regression-Model-for-Predicting-the-Marks-Scored

AIM:

To write a program to predict the marks scored by a student using the simple linear regression model.

Equipments Required:

  1. Hardware โ€“ PCs
  2. Anaconda โ€“ Python 3.7 Installation / Jupyter notebook

Algorithm

  1. Read the given dataset

  2. Assign values for x and y and plot them

  3. Split the dataset into train and test data

  4. Import linear regression and train the data

  5. find Y predict

  6. Plot train and test data

  7. Calculate mse,mae and rmse

Program:

/*
Program to implement the simple linear regression model for predicting the marks scored.
Developed by:S.SRIMATHI
RegisterNumber:212220040160 

import numpy as np

import pandas as pd

dataset=pd.read_csv('/content/student_scores.csv')

dataset.head()

dataset.tail()

#assingning hrs to x and scores to y

x=dataset.iloc[:,:-1].values

y=dataset.iloc[:,1].values

print(x)

print(y)

x=dataset.iloc[:,:-1].values

y=dataset.iloc[:,1].values

print(x)

print(y)

import matplotlib.pyplot as plt

from sklearn.metrics import mean_absolute_error, mean_squared_error

plt.scatter(x_train,y_train,color='grey')

plt.plot(x_train,reg.predict(x_train),color='magenta')

plt.title('Training set(H vs S)')

plt.xlabel('Hours')

plt.ylabel('Scores')

plt.show()

plt.scatter(x_test,y_test,color='magenta')

plt.plot(x_test,reg.predict(x_test),color='grey')

plt.title('Test set(H vs S)')

plt.xlabel('Hours')

plt.ylabel('Scores')

plt.show()

print(y_predict)

print(y_test)

mse=mean_squared_error(y_test,y_predict)

print('MSE = ',mse)

mae=mean_absolute_error(y_test,y_predict)

print('MAE = ',mae)

import numpy as np

np. sqrt(3)

rmse=np.sqrt(mse)

print('RMSE = ',rmse)

*/

Output:

DATA.HEAD():

image

DATA.TAIL():

image

ARRAY VALUES OF X AND Y:

image

TRAINING SET GRAPH:

image

TEST SET GRAPH:

image

VALUES OF Y PREDICTION:

image

ARRAY VALUES OF Y TEST:

image

VALUES OF MSE,MAE AND RMSE:

image

Result:

Thus the program to implement the simple linear regression model for predicting the marks scored is written and verified using python programming.

implementation-of-simple-linear-regression-model-for-predicting-the-marks-scored's People

Contributors

akilamohan avatar srimathi-25 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.