date = datetime.strptime(row[0], DATE_FORMAT) should have been date =
datetime.datetime.strptime(row[0], DATE_FORMAT)
and had %y-%m-%d instead of %Y.


On Mon, Jun 30, 2014 at 2:58 PM, joseph skippings <[email protected]>
wrote:

> The error below occurred when I ran the command again.
> date = datetime.strptime(row[0], DATE_FORMAT) is causing an error.
>
>
> -------------------------------------------------------------------------------------
> python run.py
> Traceback (most recent call last):
>   File "run.py", line 50, in <module>
>     runStockData()
>   File "run.py", line 47, in runStockData
>     runModel(model)
>   File "run.py", line 34, in runModel
>     date = datetime.strptime(row[0], DATE_FORMAT)
> AttributeError: 'module' object has no attribute 'strptime'
>
>
>
> -------------------------------------------------------------------------------------------
> #!/usr/bin/env python
>
> import csv
> import datetime
>
>
> from nupic.frameworks.opf.modelfactory import ModelFactory
>
> from model_params import model_params
>
>
> DATE_FORMAT = "%y-%m-%d"
>
>
> def createModel():
>   model = ModelFactory.create(model_params.MODEL_PARAMS)
>
>   model.enableInference({"predictedField": "Volume"})
>   return model
>
> def runModel(model):
>   inputFilePath = "table.csv"
>   inputFile = open(inputFilePath, "rb")
>   csvReader = csv.reader(inputFile)
>   # skip header rows
>   csvReader.next()
>   csvReader.next()
>   csvReader.next()
>
>   counter = 0
>   for row in csvReader:
>     counter += 1
>     if (counter % 100 == 0):
>       print "Read %i lines..." % counter
>     date = datetime.strptime(row[0], DATE_FORMAT)
>
>     volume = float(row[1])
>     result = model.run({
>       "Date": date,
>       "Volume": volume
>     })
>
>     prediction = result.inferences["multiStepBestPredictions"][1]
>     print prediction
>
>
> def runStockData():
>  model = createModel()
>  runModel(model)
>
> if __name__ == "__main__":
>    runStockData()
>
>
> On Mon, Jun 30, 2014 at 2:10 PM, Matthew Taylor <[email protected]> wrote:
>
>> Thanks for the extra details. Try renaming your "table_model_params.py"
>> file to "model_params.py". Is the "table_model_params.py" in a directory
>> called "model_params"? If so, you might need to create an empty file within
>> that directory called "__init__.py". This tells python to treat that
>> directory as an importable module. See the structure of the example at
>> https://github.com/numenta/nupic/tree/master/examples/opf/clients/hotgym/prediction/one_gym/model_params
>>
>> ---------
>> Matt Taylor
>> OS Community Flag-Bearer
>> Numenta
>>
>>
>> On Mon, Jun 30, 2014 at 10:58 AM, joseph skippings <
>> [email protected]> wrote:
>>
>>> Using the hot_gym tutorial on youtube as a guide, I am trying to get my
>>> run.py file to complie. Command python swarm.py ran successfully creating
>>> the model params folder and file but  when running the command python
>>> run.py I get the error below.  Inside the model_params folder the file is
>>> called table_model_params.py.
>>>
>>> --------------------------------------------------------------------------------------------
>>> python run.py
>>> Traceback (most recent call last):
>>>   File "run.py", line 8, in <module>
>>>     from model_params import model_params
>>> ImportError: No module named model_params
>>>
>>>  
>>> -------------------------------------------------------------------------------------------------
>>>
>>> #!/usr/bin/env python
>>>
>>> import csv
>>> import datetime
>>>
>>> from nupic.frameworks.opf.modelfactory import ModelFactory
>>>
>>> from model_params import model_params
>>>
>>>
>>> DATE_FORMAT = "%y/%m/%d"
>>>
>>>
>>> def createModel(modelParams):
>>>   model = ModelFactory.create(model_Params.MODEL_PARAMS)
>>>   model.enableInference({"predictedField": "Volume"})
>>>   return model
>>>
>>> def runModel(model):
>>>   inputFilePath = "table.csv"
>>>   inputFile = open(inputFilePath, "rb")
>>>   csvReader = csv.reader(inputFile)
>>>   # skip header rows
>>>   csvReader.next()
>>>   csvReader.next()
>>>   csvReader.next()
>>>
>>>   counter = 0
>>>   for row in csvReader:
>>>     counter += 1
>>>     if (counter % 100 == 0):
>>>       print "Read %i lines..." % counter
>>>     date = datetime.datetime.strptime(row[0], DATE_FORMAT)
>>>     volume = float(row[1])
>>>     result = model.run({
>>>       "Date": date,
>>>       "Volume": volume
>>>     })
>>>
>>>     prediction = result.inferences["multiStepBestPredictions"][1]
>>>     print prediction
>>>
>>>
>>> def runStockData():
>>>  model = createModel()
>>>  runModel(model)
>>>
>>> if __name__ == "__main__":
>>>    runStockData()
>>>
>>> ------------------------------------------
>>>
>>>
>>>
>>> On Mon, Jun 30, 2014 at 1:25 PM, Matthew Taylor <[email protected]>
>>> wrote:
>>>
>>>> Joseph,
>>>>
>>>> When reporting problems to the mailing list, it is essential that you
>>>> include the following information so we can help you:
>>>>
>>>> - exact command you ran that received the error
>>>> - any steps you took before that command
>>>> - what you are trying to achieve with the command
>>>> - complete output that contains the error (use pastebin.com if it is
>>>> very long)
>>>>
>>>> From what I can tell about your report, you have model params in a file
>>>> named "table_model_params.py", but you are importing "model_params". You
>>>> should "import table_model_params" to get that file imported into another
>>>> Python script.
>>>>
>>>> ---------
>>>> Matt Taylor
>>>> OS Community Flag-Bearer
>>>> Numenta
>>>>
>>>>
>>>> On Mon, Jun 30, 2014 at 9:48 AM, Joseph Skippings <
>>>> [email protected]> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>>         I get this error when I run file run.py "From model_params
>>>>>  import model_params. ImportError: no module named model_params." In my
>>>>> model_params folder the file is called table_model_params.py, I'm not sure
>>>>> if that is causing the error.
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> Sent from my iPhone
>>>>> _______________________________________________
>>>>> nupic mailing list
>>>>> [email protected]
>>>>> http://lists.numenta.org/mailman/listinfo/nupic_lists.numenta.org
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> nupic mailing list
>>>> [email protected]
>>>> http://lists.numenta.org/mailman/listinfo/nupic_lists.numenta.org
>>>>
>>>>
>>>
>>> _______________________________________________
>>> nupic mailing list
>>> [email protected]
>>> http://lists.numenta.org/mailman/listinfo/nupic_lists.numenta.org
>>>
>>>
>>
>> _______________________________________________
>> nupic mailing list
>> [email protected]
>> http://lists.numenta.org/mailman/listinfo/nupic_lists.numenta.org
>>
>>
>
_______________________________________________
nupic mailing list
[email protected]
http://lists.numenta.org/mailman/listinfo/nupic_lists.numenta.org

Reply via email to