from sklearn import datasets
from sklearn.model_selection import cross_val_predict
from sklearn import linear_model
import matplotlib.pyplot as plt
i= 1
print("\n", i,"========================")
j = 1
print(" ",i,"_", j,"list-------------------")
#https://www.cnblogs.com/zibu1234/p/4210571.html
import numpy as num
array = num.arange(-100,100,0.1)
print(array)
j= j +1
print(" ",i,"_", j,"-------------------")
j= j +1
print(" ",i,"_", j,"-------------------")
j= j +1
print(" ",i,"_", j,"-------------------")
j= j +1
print(" ",i,"_", j,"-------------------")
j= j +1
print(" ",i,"_", j,"-------------------")
j= j +1
print(" ",i,"_", j,"-------------------")
j= j +1
print(" ",i,"_", j,"-------------------")
j= j +1
i= i +1
print("\n", i,"循环========================")
print("changdu:",len(array))
for i in array:
print(i)
i= i +1
print("\n", i,"plot========================")
lr = linear_model.LinearRegression()
boston = datasets.load_boston()
y = boston.target
print(boston.data[0])
print(len(boston.data[0]))
print(len(boston.data))
newdata = [
[1,2,3],
[1,2,3]
]
print(newdata[0])
print(len(newdata))
# cross_val_predict returns an array of the same size as `y` where each entry
# is a prediction obtained by cross validation:
predicted = cross_val_predict(lr, boston.data, y, cv=10)
#predicted = cross_val_predict(lr, newdata, y, cv=10)
print(predicted)
fig, ax = plt.subplots()
ax.scatter(y, predicted, edgecolors=(0, 0, 0))
ax.plot([y.min(), y.max()], [y.min(), y.max()], 'k--', lw=4)
ax.set_xlabel('Measured')
ax.set_ylabel('Predicted')
plt.show()
i= i +1
print("\n", i,"========================")
i= i +1
print("\n", i,"========================")
i= i +1
print("\n", i,"========================")
Python基础
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 自然语言在不同的语境下有不同的理解,而计算机要根据编程语言执行任务,就必须保证编程语言写出的程序决不能有歧义 # ...
- 安装前准备 首先确定自己windows环境电脑位数,以便安装相应位数的Python。右键电脑属性就可以看到系统类型...
- 一、Python介绍 Python的创始人为吉多·范罗苏姆(Guido van Rossum)。1989年的圣诞节...