机器学习——数据预处理

机器学习主要有两种,监督学习和非监督学习。监督学习就是督促计算机去学习,明确告诉它目标是什么,非监督学习是让计算机“自学成才”,没有设定目标,学习完告诉我你学到了什么

1 # encoding=utf-8 2 3 from sklearn import linear_model 4 import matplotlib.pyplot as plt 5 import numpy as np 6 7 # 房屋面积与价格历史数据(csv文件) 8 data = np.array([[150, 6450], [200, 7450], [250, 8450], [300, 9450], [350, 11450], [400, 15450], [600, 18450]]) 9 # print data[:, 0].reshape(-1, 1) 10 # plt.scatter(data[:, 0], data[:, 1], color='blue') 11 # plt.show() 12 13 # 线性模型 14 # regr = linear_model.LinearRegression() 15 # 拟合 16 # regr.fit(data[:, 0].reshape(-1, 1), data[:, 1]) 17 # 直线的斜率、截距 18 # a, b = regr.coef_, regr.intercept_ 19 # print a, b 20 # plt.plot(data[:,0],regr.predict(data[:,0].reshape(-1,1)),color='red',linewidth=4) 21 # plt.scatter(data[:, 0], regr.predict(data[:, 0].reshape(-1, 1)), color='red') 22 # 预测175天和800天房价数据 23 # print regr.predict(175) 24 # print regr.predict(800) 25 # plt.show()

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpxpzw.html