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
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 [ ]: