In [1]:
%matplotlib inline
DEFAULT_FIGSIZE = (16, 12)
import itertools
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import seaborn as sns
sns.set_style('darkgrid')
import pandas as pd
sys.path.append('..')
from antlia.plotdf import plotjoint
%load_ext autoreload
%autoreload 2
import matplotlib as mpl
mpl.rcParams['figure.figsize'] = DEFAULT_FIGSIZE
In [2]:
braking_df = pd.read_pickle('trial2_braking_ttc.p.gz')
In [26]:
import enum
class BrakingType(enum.Enum):
Constant = 0
Increasing = 1
TwoStage = 2
def __str__(self):
return self.name
def __float__(self):
return float(self.value)
braking_df['braking type'] = [
# rider 0
BrakingType.TwoStage,
BrakingType.TwoStage,
BrakingType.TwoStage,
BrakingType.Constant,
BrakingType.Increasing,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Increasing,
# rider 1
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
# rider 2
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
# rider 3
BrakingType.Constant,
BrakingType.TwoStage,
BrakingType.Constant,
BrakingType.TwoStage,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.TwoStage,
# rider 4
BrakingType.Constant,
BrakingType.Increasing,
BrakingType.Increasing,
BrakingType.Constant,
BrakingType.TwoStage,
BrakingType.Increasing,
BrakingType.Increasing,
BrakingType.Increasing,
BrakingType.Constant,
# rider 5
BrakingType.Constant,
BrakingType.Increasing,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
# rider 6
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Increasing,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.TwoStage,
BrakingType.TwoStage,
# rider 7
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.Constant,
BrakingType.TwoStage,
BrakingType.TwoStage,
BrakingType.TwoStage,
BrakingType.TwoStage,
BrakingType.Constant,
]
In [27]:
df = braking_df.drop([
'linregress intercept',
'braking starttime',
'braking endtime',
'window size',
'lockup ranges'
], axis=1)
cols = df.columns.tolist()
cols = cols[-5:] + cols[:-5]
df = df[cols]
with pd.option_context('display.max_rows', None,
'display.max_columns', None,
'float_format', '{:0.3f}'.format):
display(df)
In [32]:
for t in BrakingType:
print(t, t.value)
In [43]:
from antlia.plotdf import plotjoint
colors = sns.color_palette('tab10', 10)
plt.close('all')
fig, ax = plt.subplots(figsize=(16, 12))
sns.swarmplot(x='braking type', y='starting velocity',
hue='rider id',
data=df, ax = ax)
plt.show()
In [41]:
print('BrakingType\tcount')
for t in BrakingType:
n = df[df['braking type'] == t].count().values[0]
print('{}\t{}'.format(t, n))