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')