在我的程序中的某一点上,我使用了sklearn.linear_model.LogisticRegression,有时它只是在思考/运行而且它不会继续前进。这取决于它获得的数据。一些样本数据,它不按我想要的方式工作:
from sklearn.linear_model import LogisticRegression
from numpy import array
x = LogisticRegression()
a = [array([2.24711642e+307,1.12355821e+307,7.86490747e+307,1.68533731e+308,1.00000000e+000,
5.00000000e-001,1.12355821e+307,0.00000000e+000,1.46062567e+308,3.37067463e+307,5.00000000e-001,
0.00000000e+000,0.00000000e+000,1.23591403e+308,5.61779105e+307,5.00000000e-001,6.74134926e+307,
1.12355821e+307,6.74134926e+307,1.23591403e+308,7.50000000e-001,4.49423284e+307,1.12355821e+307,
6.74134926e+307,6.74134926e+307]),array([1.00000000e+000,1.00000000e+000,3.37067463e+307,
7.86490747e+307,7.86490747e+307,1.00000000e+000,1.12355821e+307,2.24711642e+307,1.12355821e+308,
4.49423284e+307,1.00000000e+000,3.37067463e+307,7.86490747e+307,5.61779105e+307,1.00000000e+000,
2.24711642e+307,1.12355821e+307,1.23591403e+308,2.24711642e+307,1.00000000e+000,7.50000000e-001,
7.86490747e+307,6.74134926e+307,1.00000000e+000,1.00000000e+000]),array([2.24711642e+307,
2.24711642e+307,5.61779105e+307,1.34826985e+308,6.74134926e+307,0.00000000e+000,2.24711642e+307,
1.12355821e+307,7.86490747e+307,4.49423284e+307,2.24711642e+307,1.12355821e+308,1.12355821e+307,
1.23591403e+308,5.61779105e+307,7.50000000e-001,1.12355821e+307,0.00000000e+000,4.49423284e+307,
1.34826985e+308,7.50000000e-001,6.74134926e+307,2.24711642e+307,1.12355821e+307,6.74134926e+307]),
array([1.00000000e+000,1.12355821e+307,3.37067463e+307,4.49423284e+307,1.23591403e+308,
1.00000000e+000,1.12355821e+307,4.49423284e+307,0.00000000e+000,4.49423284e+307,1.12355821e+307,
2.50000000e-001,1.34826985e+308,1.12355821e+307,1.00000000e+000,2.24711642e+307,0.00000000e+000,
1.79769313e+308,1.00000000e+000,1.00000000e+000,1.12355821e+307,1.12355821e+307,1.01120239e+308,
1.00000000e+000,1.00000000e+000]),array([2.24711642e+307,5.61779105e+307,6.74134926e+307,
3.37067463e+307,1.00000000e+000,7.50000000e-001,3.75000000e-001,8.98846567e+307,8.98846567e+307,
1.00000000e+000,1.00000000e+000,2.24711642e+307,6.74134926e+307,6.74134926e+307,1.00000000e+000,
1.00000000e+000,5.00000000e-001,1.34826985e+308,3.37067463e+307,1.00000000e+000,1.00000000e+000,
8.12500000e-001,8.98846567e+307,8.98846567e+307,1.00000000e+000])]
b = [5, 3, 6, 4, 0]
x.fit(a,b)
print 'finished'
任何人都可以向我解释发生了什么事吗?为什么它不给我任何衣服?
编辑:这是示例数据,在我的计算机上,程序永远不会超过x.fit(a,b)
。它只是继续处理x.fit(a,b)
,从不打印'完成'。问题是为什么。
答案 0 :(得分:1)
Regressor
可以在相对较短的时间内轻松安装您显示的数据集; fit
很久以前就完成了 。您需要调用predict
的{{1}}方法来估算新样本的结果:
LogisticRegressor
如果您的原始数据功能太多,您可以尝试进行一些功能选择,以减少学习回归量的时间。