In [74]:
import matplotlib.pyplot as plt
import neurolab as nl
import numpy as np
import pandas as pd

#from sklearn import metrics
#from sklearn.linear_model import LogisticRegression

data_frame = pd.read_csv("personal_stats2.csv")
data_frame = data_frame[["Happiness", "Motivation", "Flexibility", "Strength", "Endurance", "Relationships"]]

# Get 80% of our dataset
index_at_80_percent = int(len(data_frame) * .8)
#truth_data = data_frame[:index_at_80_percent]
#training_data = data_frame[index_at_80_percent:]

In [149]:
# Get the first 80% as input and the following day as the target result
training_input = data_frame[:index_at_80_percent]
training_target = data_frame[1:index_at_80_percent + 1]

# The final 20% same as above, current day as input next day as expected output
test_input = data_frame[index_at_80_percent + 1: len(data_frame) - 1]
test_target = data_frame[index_at_80_percent + 2:]

# training_input = training_input / 10
# training_target = training_target / 10
# test_input = test_input / 10
# test_target = test_target / 10

In [153]:
# Make 6 inputs, 20 neurons and 6 outputs
net = nl.net.newff(
    [
        #[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]
        [0, 10], [0, 10], [0, 10], [0, 10], [0, 10], [0, 10], 
    ], 
    [20, 6]
)
#net = nl.net.newff([[0, 1],[0, 1],[0, 1],[0, 1],[0, 1],[0, 1]], 1)

err = net.train_gdx(training_input, training_target, lr=0.005, epochs=1000, show=15, goal=10)


# Take the data and expand it into input -> output
# truth_data_expanded = []
# print dir(truth_data)
# for truth in truth_data.items():
#     print truth


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-153-8a71ef794a7f> in <module>()
      9 #net = nl.net.newff([[0, 1],[0, 1],[0, 1],[0, 1],[0, 1],[0, 1]], 1)
     10 
---> 11 err = net.train(training_input, training_target, lr=0.005, epochs=1000, show=15, goal=10)
     12 
     13 

/Users/eric/.virtualenvs/machine-learning/lib/python2.7/site-packages/neurolab/core.pyc in train(self, *args, **kwargs)
    163 
    164         """
--> 165         return self.trainf(self, *args, **kwargs)
    166 
    167     def reset(self):

/Users/eric/.virtualenvs/machine-learning/lib/python2.7/site-packages/neurolab/core.pyc in __call__(self, net, input, target, **kwargs)
    347         self.error = []
    348         try:
--> 349             train(net, *args)
    350         except TrainStop as msg:
    351             if self.params['show']:

/Users/eric/.virtualenvs/machine-learning/lib/python2.7/site-packages/neurolab/train/spo.pyc in __call__(self, net, input, target)
     77 
     78         x = fmin_bfgs(self.fcn, self.x.copy(), fprime=self.grad, callback=self.step,
---> 79                       **self.kwargs)
     80         self.x[:] = x
     81 

TypeError: fmin_bfgs() got an unexpected keyword argument 'lr'

In [133]:
doc = '''
Input -> 6 metrics with 1-10 in each
Output -> Next days prediction

Input layer has 6 inputs
Output layer has 6 outputs OR 1 output "happiness rating?"

Normalize data / 10
Denormalize * 10
'''

#model = LogisticRegression()
#model.fit(training_data, truth_data)
#predicted = model.predict(training_data)
#print metrics.classification_report(truth_data, predicted)
#print metrics.confusion_matrix(truth_data, predicted)

In [ ]:


In [20]:
# data["measurement"][:,3]  -> can only tuple-index with a MultiIndex, google that

In [ ]: