[Chicago] Fun in learning ML

Randy Baxley randy7771026 at gmail.com
Tue Feb 3 00:07:28 CET 2015


That statement is buried in a library called in statsmodels / pandas by
this piece of code that should work at least down to where reg(x) is called
because it was working for the guy who gave it to us in a breakout at
chihacknight:

import statsmodels.api as sm
# import statsmodels.api, numpy, scipy, matplotlib, pandas, sympy, nose as sm

y = [5, 6, 5, 7, 7, 8, 9, 9, 11, 12, 15]

print 'y', y

x = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4]

print 'x', x

x = sm.add_constant(x)

print x

model = sm.api.OLS(y,x) # does an ordinary least squared regression
results = model.fit()

p = results.params

print p

def reg(x):

    return p[0] + p[1]*x

print reg(3)



On Mon, Feb 2, 2015 at 2:19 PM, Carl Karsten <carl at personnelware.com> wrote:

> the link I gave might be close, but I doubt it is an exact hit.
>
> Where/why do you have this line: (why do you think it should work?)
>
> from pandas.core.api import get_dummies
>
> On Mon, Feb 2, 2015 at 1:46 PM, Randy Baxley <randy7771026 at gmail.com>
> wrote:
>
>> Yep and my mind has a lot of fun with the idea of get_dummies.
>>
>> I cut off the traceback one line too soon.  Maybe the link Carl gave will
>> have an answer but just for completeness here is the traceback with that
>> line included.
>>
>> >>> import statsmodels.api as sm
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File "/usr/local/lib/python2.7/dist-packages/statsmodels/api.py", line
>> 13, in <module>
>>     from .discrete.discrete_model import (Poisson, Logit, Probit,
>>   File
>> "/usr/local/lib/python2.7/dist-packages/statsmodels/discrete/discrete_model.py",
>> line 40, in <module>
>>     from pandas.core.api import get_dummies
>> ImportError: cannot import name get_dummies
>>
>>
>> On Mon, Feb 2, 2015 at 1:02 PM, Carl Karsten <carl at personnelware.com>
>> wrote:
>>
>>> You didn't post the error, but earlier I thnk I see it:
>>>
>>>     from pandas.core.api import get_dummies
>>> ImportError: cannot import name get_dummies
>>>
>>> Assuming that is still the error..
>>>
>>> That says there is no get_dummies in pandas.core.api.
>>>
>>> I did find this:
>>>
>>>
>>> http://pandas.pydata.org/pandas-docs/stable/generated/pandas.core.reshape.get_dummies.html
>>>
>>> So something has get_dummies.  but given the description I expect many
>>> things have get_dummies.
>>>
>>> I'll let you find the docs that relate to what you are trying to do.
>>>
>>>
>>>
>>> On Mon, Feb 2, 2015 at 12:35 PM, Randy Baxley <randy7771026 at gmail.com>
>>> wrote:
>>>
>>>> True that.
>>>>
>>>> The error comes up the same in terminal using python.
>>>>
>>>> >>> import statsmodels.api as sm
>>>> Traceback (most recent call last):
>>>>   File "<stdin>", line 1, in <module>
>>>>   File "/usr/local/lib/python2.7/dist-packages/statsmodels/api.py",
>>>> line 13, in <module>
>>>>     from .discrete.discrete_model import (Poisson, Logit, Probit,
>>>>   File
>>>> "/usr/local/lib/python2.7/dist-packages/statsmodels/discrete/discrete_model.py",
>>>> line 40, in <module>
>>>>     from pandas.core.api import get_dummies
>>>>
>>>>
>>>> On Mon, Feb 2, 2015 at 12:12 PM, Carl Karsten <carl at personnelware.com>
>>>> wrote:
>>>>
>>>>> good.  pandas is installed and available.
>>>>>
>>>>> Now try the line or lines that are giving you trouble.  Or if you need
>>>>> to run your program to get an error, do that.
>>>>>
>>>>> The idea is very simple text based cause and effect.
>>>>>
>>>>> An IDE (PyCharm) will help you write code, but does not help us debug
>>>>> your code.  It just makes things harder for us, so when asking for help
>>>>> with your code it is best to remove the IDE component.
>>>>>
>>>>> Unless you need help using the IDE, but that's a different problem
>>>>> than how do I use pandas.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Feb 2, 2015 at 11:56 AM, Randy Baxley <randy7771026 at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> user at freegeekchicago:~$ python
>>>>>> Python 2.7.3 (default, Dec 18 2014, 19:10:20)
>>>>>> [GCC 4.6.3] on linux2
>>>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>> >>> import pandas
>>>>>> >>>
>>>>>>
>>>>>>
>>>>>> On Mon, Feb 2, 2015 at 10:29 AM, Carl Karsten <carl at personnelware.com
>>>>>> > wrote:
>>>>>>
>>>>>>> IDEs and screen shots make it harder to converse over email.
>>>>>>>
>>>>>>> Use the simple text based python repl so you can cut/paste text.
>>>>>>> I don't have it installed, so this is what I get:
>>>>>>>
>>>>>>> carl at twist:~$ python
>>>>>>> Python 2.7.6 (default, Mar 22 2014, 22:59:56)
>>>>>>> [GCC 4.8.2] on linux2
>>>>>>> Type "help", "copyright", "credits" or "license" for more
>>>>>>> information.
>>>>>>>
>>>>>>> >>> import pandas
>>>>>>> Traceback (most recent call last):
>>>>>>>   File "<stdin>", line 1, in <module>
>>>>>>> ImportError: No module named pandas
>>>>>>> >>>
>>>>>>>
>>>>>>> Do that and post the results.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Sun, Feb 1, 2015 at 1:18 AM, Randy Baxley <randy7771026 at gmail.com
>>>>>>> > wrote:
>>>>>>>
>>>>>>>> It was worth a try so I did it.  I think Pandas is installed but on
>>>>>>>> the path highlighted and in yellow at the top in fir.
>>>>>>>> st attachment
>>>>>>>> Second attachment shows where I think Python is looking for Pandas,
>>>>>>>>
>>>>>>>> On Sat, Jan 31, 2015 at 10:23 PM, Carl Karsten <
>>>>>>>> carl at personnelware.com> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sat, Jan 31, 2015 at 10:02 PM, Randy Baxley <
>>>>>>>>> randy7771026 at gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>>     from pandas.core.api import get_dummies
>>>>>>>>>> ImportError: cannot import name get_dummies
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> pandas isn't installed right. (maybe not at all)
>>>>>>>>>
>>>>>>>>> my guess:
>>>>>>>>> sudo easy_install pandas
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Carl K
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Chicago mailing list
>>>>>>>>> Chicago at python.org
>>>>>>>>> https://mail.python.org/mailman/listinfo/chicago
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Chicago mailing list
>>>>>>>> Chicago at python.org
>>>>>>>> https://mail.python.org/mailman/listinfo/chicago
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Carl K
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Chicago mailing list
>>>>>>> Chicago at python.org
>>>>>>> https://mail.python.org/mailman/listinfo/chicago
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Chicago mailing list
>>>>>> Chicago at python.org
>>>>>> https://mail.python.org/mailman/listinfo/chicago
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Carl K
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Chicago mailing list
>>>>> Chicago at python.org
>>>>> https://mail.python.org/mailman/listinfo/chicago
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Chicago mailing list
>>>> Chicago at python.org
>>>> https://mail.python.org/mailman/listinfo/chicago
>>>>
>>>>
>>>
>>>
>>> --
>>> Carl K
>>>
>>>
>>> _______________________________________________
>>> Chicago mailing list
>>> Chicago at python.org
>>> https://mail.python.org/mailman/listinfo/chicago
>>>
>>>
>>
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> https://mail.python.org/mailman/listinfo/chicago
>>
>>
>
>
> --
> Carl K
>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20150202/10d3161f/attachment.html>


More information about the Chicago mailing list