得分非常低,scikit-learn线性回归得到明显的模式

时间:2017-05-27 16:06:45

标签: python scikit-learn linear-regression

from random import randint,choice
from sklearn.cross_validation import train_test_split
import numpy as np
from sklearn.linear_model import LinearRegression as LR

x1 = []
for i in range(1000):
    if i%2 == 0:
        x1.append(1001)
    else:
        x1.append(999)

leng = [x for x in range(len(x1))]

a = np.array(leng).reshape(len(leng),1)
b = np.array(x1).reshape(len(leng),1)

t1,t2,y1,y2 = train_test_split(a,b)

l = LR()
l.fit(t1,y1)
print(l.score(t2,y2))
print(l.predict(t2))

线性独立轴上的相关值仅为1001或999。线性回归应该用1.0得分;但是,我的分数低于0.任何想法为什么?我想我一定是做错了。

1 个答案:

答案 0 :(得分:2)

因为error: Failed dependencies: clang-3.9.0-libs(x86-64) = 3.9.0-3.1.el7.centos.alonid is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libLLVM-3.9.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclang.so.3.9()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangAST.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangBasic.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangCodeGen.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangDriver.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangFormat.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangFrontend.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangFrontendTool.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangIndex.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangRewrite.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangRewriteFrontend.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangStaticAnalyzerFrontend.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangTooling.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 libclangToolingCore.so()(64bit) is needed by clang-3.9.0-3.9.0-3.1.el7.centos.alonid.x86_64 a之间没有线性关系或明显的模式。 b属性给出R-squared,R平方为0。手动,

.score