import pandas as pd
import numpy as np
import matplotlib.pyplot as plt


df = pd.read_csv('data/train.csv')
df_list = []
for items in df.values:
    df_list.append([items[0]] + [float(i) for i in items[1].split(',')] + [items[2]])

df = pd.DataFrame(np.array(df_list))
df.columns = ['id'] + ['signal_'+str(i) for i in range(len(df_list[0])-2)] + ['label']
print(df.head())
print(df.describe())

label0 = df.loc[df['label'] == 0.0, ['signal_'+str(i) for i in range(205)]]
label0_mean = np.array(label0.mean())

label1 = df.loc[df['label'] == 1.0, ['signal_'+str(i) for i in range(205)]]
label1_mean = np.array(label1.mean())

label2 = df.loc[df['label'] == 2.0, ['signal_'+str(i) for i in range(205)]]
label2_mean = np.array(label2.mean())

label3 = df.loc[df['label'] == 3.0, ['signal_'+str(i) for i in range(205)]]
label3_mean = np.array(label3.mean())

time = list(range(205))

plt.plot(time, label0_mean ,c='blue', label='label0_line')
plt.plot(time,label1_mean, c='red', label='label1_line')
plt.plot(time, label2_mean ,c='green', label='label2_line')
plt.plot(time, label3_mean ,c='yellow', label='label3_line')
plt.xlabel("time")
plt.ylabel("heartbeat_signal")
plt.legend()
plt.show()
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt


df = pd.read_csv('data/train.csv')
df_list = []
for items in df.values:
    df_list.append([items[0]] + [float(i) for i in items[1].split(',')] + [items[2]])

df = pd.DataFrame(np.array(df_list))
df.columns = ['id'] + ['signal_'+str(i) for i in range(len(df_list[0])-2)] + ['label']
print(df.head())
print(df.describe())

label0 = df.loc[df['label'] == 0.0, ['signal_'+str(i) for i in range(205)]]
label0_mean = np.array(label0.mean())

label1 = df.loc[df['label'] == 1.0, ['signal_'+str(i) for i in range(205)]]
label1_mean = np.array(label1.mean())

label2 = df.loc[df['label'] == 2.0, ['signal_'+str(i) for i in range(205)]]
label2_mean = np.array(label2.mean())

label3 = df.loc[df['label'] == 3.0, ['signal_'+str(i) for i in range(205)]]
label3_mean = np.array(label3.mean())

time = list(range(205))

plt.plot(time, label0_mean ,c='blue', label='label0_line')
plt.plot(time,label1_mean, c='red', label='label1_line')
plt.plot(time, label2_mean ,c='green', label='label2_line')
plt.plot(time, label3_mean ,c='yellow', label='label3_line')
plt.xlabel("time")
plt.ylabel("heartbeat_signal")
plt.legend()
plt.show()