Machine Learning courses with 110+ Real-time projects Start Now!!
Program 1
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn import linear_model
mydf=pd.read_csv("D://scikit_data/home/homeprices.csv")
mydf.bedrooms=mydf.bedrooms.fillna(mydf.bedrooms.median())
print(mydf)
model=linear_model.LinearRegression()
# print(model)
model.fit(mydf.drop('price',axis='columns'),mydf.price)
print(model)
sq=int(input("Enter area: "))
bdr=int(input("Enter No of Bedrooms: "))
age=int(input("Enter age of Home(How old is Home) : "))
print("Prediciated Price",model.predict([[sq,bdr,age]]))
print(model.intercept_)
print(model.coef_)
price=221323.0018654043 + 112.06244194*sq+23388.88007794*bdr+-3231.71790863*age
print("Formula Price",price)