下面是Siraj的演示:下面是我的代码,它最适合单变量数据
(可以在here中找到文件):
#import dependencies
import pandas as pd
from sklearn import linear_model
import matplotlib.pyplot as plt
#read data
dataframe = pd.read_fwf('brain_body.txt')
x_values = dataframe[['Brain']]
y_values = dataframe[['Body']]
#train model on data
body_reg = linear_model.LinearRegression()
body_reg.fit(x_values, y_values)
#visualize results
plt.scatter(x_values, y_values)
plt.plot(x_values, body_reg.predict(x_values))
plt.show()
我总是弄得一团糟:
达伦·奥洛克的回答值得称赞
因为熊猫图书馆似乎有区别,numpy为我解决了这个问题。你知道吗
我希望这能解决问题。你知道吗
干杯
我的看起来一模一样。我来这里是想看看有没有人帮我贴了什么。问题似乎与2个异常值(2547-4603和6654-5712)有关,因为它们明显更高。你知道吗
相关问题 更多 >
编程相关推荐