Exemple #1
0
    selectColumns,
    selectTime,
)
from sklearn.preprocessing import MinMaxScaler

# Getting data
input = open("../data/preprocessed/preprocessedDataParticipant1.txt", "rb")
data = pickle.load(input)
input.close()

# Removing "steps" caused by scooter riding
data["steps"] = data["steps"] - 37 * data["scooterRiding"]
data["steps"][data["steps"] < 0] = 0

# Selecting the different periods where different trackers where used
period1 = selectTime(data, "2015-12-26", "2016-06-21")  # basis and googlefit
period2 = selectTime(data, "2016-06-22", "2016-09-01")  # basis
period3 = selectTime(data, "2016-09-02", "2017-01-01")  # basis and fitbit
period4 = selectTime(data, "2017-01-02", "2017-10-16")  # fitbit
period5 = selectTime(data, "2017-10-17", "2018-07-02")  # fitbit and moves
period6 = selectTime(data, "2018-07-03",
                     "2018-07-30")  # fitbit and moves and googlefit
period7 = selectTime(data, "2018-07-31", "2020-02-01")  # fitbit and googlefit

# Creating the trackerMeanSteps variable in the dataframe and puts harmonized steps value inside
data["trackerMeanSteps"] = data["steps"]
data = adjustVarAndPlaceInData(period1, data, "googlefitSteps",
                               "basisPeakSteps", "2015-12-26", "2016-06-21")
data = addDataToTrackerMeanSteps(period2, data, "basisPeakSteps", "2016-06-22",
                                 "2016-09-01")
data = adjustVarAndPlaceInData(period3, data, "basisPeakSteps", "steps",
Exemple #2
0
# This scripts assumes that the dataframe has been created and saved in data.txt

import pickle
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
import numpy as np
from dataFrameUtilities import selectTime, selectColumns, addRollingMeanColumns

input = open('data.txt', 'rb')
data = pickle.load(input)
input.close()

timeSelected = selectTime(data, '2016-01-15', '2019-03-06')

pain = selectColumns(timeSelected, ['forearmElbowPain'])
pain = addRollingMeanColumns(pain, ['forearmElbowPain'], 21)

timeSelected[
    'swimAndSurf'] = timeSelected['swimming'] + timeSelected['surfing']
timeSelected['climbs'] = timeSelected['climbing'] + timeSelected['viaFerrata']

env = addRollingMeanColumns(timeSelected,
                            ['whatPulseT', 'swimAndSurf', 'climbs'], 21)

envOrdi = env[['whatPulseT']]
envSport = env[['swimAndSurf', 'climbs']]
envSportMean = env[[
    'whatPulseTRollingMean', 'swimAndSurfRollingMean', 'climbsRollingMean'
]]
# This scripts assumes that the dataframe has been created and saved in data.txt

import pickle

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from dataFrameUtilities import addRollingMeanColumns, selectColumns, selectTime
from sklearn.preprocessing import MinMaxScaler

input = open("data.txt", "rb")
data = pickle.load(input)
input.close()

timeSelected = selectTime(data, "2016-01-15", "2019-03-06")

pain = selectColumns(timeSelected, ["forearmElbowPain"])
pain = addRollingMeanColumns(pain, ["forearmElbowPain"], 21)

timeSelected[
    "swimAndSurf"] = timeSelected["swimming"] + timeSelected["surfing"]
timeSelected["climbs"] = timeSelected["climbing"] + timeSelected["viaFerrata"]

env = addRollingMeanColumns(timeSelected,
                            ["whatPulseT", "swimAndSurf", "climbs"], 21)

envOrdi = env[["whatPulseT"]]
envSport = env[["swimAndSurf", "climbs"]]
envSportMean = env[[
    "whatPulseTRollingMean", "swimAndSurfRollingMean", "climbsRollingMean"
]]
Exemple #4
0
# This scripts assumes that the dataframe has been created and saved in data.txt

import pickle

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from dataFrameUtilities import addRollingMeanColumns, selectColumns, selectTime

input = open("data.txt", "rb")
data = pickle.load(input)
input.close()

timeSelected = selectTime(data, "2016-09-01", "2019-10-20")

pain = selectColumns(timeSelected, ["kneePain"])
pain = addRollingMeanColumns(pain, ["kneePain"], 21)

env = addRollingMeanColumns(timeSelected, ["steps", "denivelation"], 21)
envRollingMean = selectColumns(env,
                               ["stepsRollingMean", "denivelationRollingMean"])
envBrut = selectColumns(env, ["steps", "denivelation"])

fig, axes = plt.subplots(nrows=3, ncols=1)

pain.plot(ax=axes[0])
envBrut.plot(ax=axes[1])
envRollingMean.plot(ax=axes[2])

plt.legend(loc="best")
plt.show()