#THE SPARK FOUNDTAION:Predict the percentage of an student based on the no. of study hours using supervised learning
# TASK-1
#NAME: VIGNESH.A

#importing libraries
library(readr)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.4
#loading given file
data<-read.csv("http://bit.ly/w-data")
#applying linear regression
model<- lm(Scores~Hours,data)
model
## 
## Call:
## lm(formula = Scores ~ Hours, data = data)
## 
## Coefficients:
## (Intercept)        Hours  
##       2.484        9.776
#plotting the data
ggplot(data,aes(x=Hours,y=Scores))+geom_point()

plot(data)
abline(model, col="yellow")

#predicting the score if a student studies for 9.25 hrs/ day?
a<-data.frame(Hours=9.25)
result<-predict(model,a)
print(result)
##        1 
## 92.90985