# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

from sklearn.linear_model import LinearRegression
import numpy as np
from sklearn import model_selection

data = np.loadtxt("data.csv",delimiter=",")

data.shape

x=data[:,0].reshape(-1,1)
y=data[:,1]

x.shape

X_train,X_test,Y_train,Y_test=model_selection.train_test_split(x,y)

obj1=LinearRegression()
obj1.fit(X_train,Y_train)

obj1.coef_

obj1.intercept_

# +
import matplotlib.pyplot as plt
m=obj1.coef_
c=obj1.intercept_

x_line=np.arange(30,70,0.1)
y_line=m*x_line+c
plt.plot(x_line,y_line,"g")
train_id=X_train.reshape(75)
plt.scatter(train_id,Y_train)
plt.show()

# +
import matplotlib.pyplot as plt
m=obj1.coef_
c=obj1.intercept_

x_line=np.arange(30,70,0.1)
y_line=m*x_line+c
plt.plot(x_line,y_line,"g")
train_id=X_test.reshape(25)
plt.scatter(train_id,Y_test)
plt.show()
# -



StarcoderdataJupyterScriptsDedupFiltered