POLAYOR

LinearRegression_1

Linear Regression

packages

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn import linear_model

model

reg = Linear_model.LinearRegression()
reg.predict(data)
reg.coef_ # coefficient
reg.intercept_ # interception

Note: data requires 2D array like [[3300]]

plt

plt.xlabel()
plt.ylabel()
plt.scatter(..., color='red', marker='') # marker为数据点的标记
plt.plot(df.x, reg.predict(df[['x']]), color='blue')

posted on 2023-02-22 17:26  POLAYOR  阅读(13)  评论(0编辑  收藏  举报

导航