Zach,
For your second snippet, I get this output using the dev version of 
scikit-learn:

    coef array [ 0.33333333  0.33333333  0.33333333]
    length 3
    getting value 0: 0.333333333333
    getting value 1: 0.333333333333

What version of scikit-learn are you using?  You can find out by running

    import sklearn
    print sklearn.__version__

Thanks
    Jake


On 07/18/2012 02:09 PM, Zach Bastick wrote:
> I'm having trouble with linear_model.LinearRegression()
>
> This works:
>
> from sklearn import linear_model
> clf = linear_model.LinearRegression()
> clf.fit ([[0, 0, 0], [1, 1, 1], [2, 2, 2]], [0, 1, 2])
> # clf.fit([[394, 3878, 13, 4, 0, 0],[384, 10175, 14, 4, 0, 0]],[3,9])
> print 'coef array',clf.coef_
> print 'length', len(clf.coef_)
> print 'getting value 0:', clf.coef_[0]
> print 'getting value 1:', clf.coef_[1]
>
> output:
>
> coef array [ 0.33333333  0.33333333  0.33333333]
> length 3
> getting value 0: 0.333333333333
> getting value 1: 0.333333333333
>
>
> But this returns the values in a list of a list [[]] instead of a list
> []. Any ideas why?
>
> from sklearn import linear_model
> clf = linear_model.LinearRegression()
> # clf.fit ([[0, 0, 0], [1, 1, 1], [2, 2, 2]], [0, 1, 2])
> clf.fit([[394, 3878, 13, 4, 0, 0],[384, 10175, 14, 4, 0, 0]],[3,9])
> print 'coef array',clf.coef_
> print 'length', len(clf.coef_)
> print 'getting value 0:', clf.coef_[0]
> print 'getting value 1:', clf.coef_[1]
>
>
> Output:
>
> coef array [[  1.03428648e-03   9.54477167e-04   1.45135995e-07
> 0.00000000e+00  0.00000000e+00   0.00000000e+00]]
> length 1
> getting value 0: [  1.03428648e-03   9.54477167e-04   1.45135995e-07   
> 0.0000000
> 0e+00  0.00000000e+00   0.00000000e+00]
> getting value 1:
> Traceback (most recent call last):
>    File "regress.py", line 8, in <module>
>      print 'getting value 1:', clf.coef_[1]
> IndexError: index out of bounds
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to