Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Student assignment updates.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Write your name and PRN no
Name:Gayatri Sopan Gade
PRN:2020BTECS00210
Hello Updated
63 changes: 63 additions & 0 deletions assignment2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
"""Assignment2.ipynb

Automatically generated by Colaboratory.

Original file is located at
https://colab.research.google.com/drive/1uLqr_xv_w9FyRqQyk7gDjuOH39EVvHXG
"""

from google.colab import drive
drive.mount('/content/drive')

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split

print('Booting into Machine Learning....')

data=pd.read_csv('/content/drive/MyDrive/hour.csv')

data.head(10)

print('Defining variables')
X = data['atemp']
y = data['registered']

plt.scatter(X,y, color='green')

print('Splitting the data into hour')
X_hour, X_test, y_hour, y_test = train_test_split(X,y,random_state=0)

plt.scatter(X_hour,y_hour, color='green')

plt.scatter(X_test,y_test, color='green')

print('Training the model using X_hour, y_hour')
lr = LinearRegression()

#print(X_hour)
#print(y_hour)
#print(X_hour.values.reshape(-1,1))
lr.fit(X_hour.values.reshape(-1,1),y_hour)

print('Predicting using the trained model - X_hour')
y_pred=lr.predict(X_test.values.reshape(-1,1))

print(y_test) #Test data - actual data
print(y_pred) #Model predicted dataset

plt.scatter(X_hour,y_hour,color='green')
plt.scatter(X_test,y_pred,color='red')

plt.xticks()
plt.yticks()
plt.show()

print('Finding intercept & coeff')
print('Intercept', lr.intercept_)
print('Coefficient', lr.coef_)
print(lr.coef_,'x +',lr.intercept_)