In [1]:
import glob

In [2]:
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib import colors as mcolors
from matplotlib import patches
import numpy as np
import pandas as pd
import seaborn.apionly as sns
from scipy import stats
import pymc3 as pm
%matplotlib inline

In [3]:
default_cycler = plt.rcParamsDefault["axes.prop_cycle"]
colorblind_cmaps = ["Dark2", "Set2"]
colorblind_cyclers = {cmap: plt.cycler("color", plt.cm.get_cmap(cmap).colors) for cmap in colorblind_cmaps}
plt.rcParams["axes.prop_cycle"] = colorblind_cyclers["Dark2"]

In [4]:
plt.rc("text", usetex=True)
plt.rc("font", family="serif")

In [5]:
plt.rc("text", usetex=False)
plt.rc("font", family="serif")

In [6]:
import re
FILENAME_PATTERN = "experiment-(\d)_user-(\d+)_run-(\d+)"
filename_regex = re.compile(pattern=FILENAME_PATTERN)

from collections import namedtuple
RunData = namedtuple("RunData", "experiment user run")
BestResult = namedtuple("BestResult", "trace model")
TlxResponse = namedtuple("TlxResponse", "code raw weight score")
Coords = namedtuple("Coords", "x y")
TARGET = Coords(0, 6)

from enum import Enum
DroneState = Enum("DroneState",
                  "Emergency Inited Landed Flying Hovering Test TakingOff GotoHover Landing Looping",
                  start=0)
ExperimentType = Enum("ExperimentType", "Onboard Spirit Combined LineOfSight")

In [7]:
def change_color(color, saturation=0, value=0):
    rgb = mcolors.ColorConverter.to_rgb(color)
    h, s, v = mcolors.rgb_to_hsv(rgb)
    s *= 1 + saturation/100
    s = np.clip(s, 0, 1)
    v *= 1 + value/100
    v = np.clip(v, 0, 1)
    r, g, b = mcolors.hsv_to_rgb((h, s, v))
    return r, g, b

In [8]:
def saturate_color(color, percent):
    rgb = mcolors.ColorConverter.to_rgb(color)
    h, s, v = mcolors.rgb_to_hsv(rgb)
    s *= 1 + percent/100
    s = np.clip(s, 0, 1)
    r, g, b = mcolors.hsv_to_rgb((h, s, v))
    return r, g, b

In [9]:
def shade_color(color, percent):
    rgb = mcolors.ColorConverter.to_rgb(color)
    h, s, v = mcolors.rgb_to_hsv(rgb)
    v *= 1 + percent/100
    v = np.clip(v, 0, 1)
    r, g, b = mcolors.hsv_to_rgb((h, s, v))
    return r, g, b

In [10]:
def plot_overview(df, experiment_type, color="C0", title=None, target=TARGET,
                  alpha_path=0.2, zorder_path=0, 
                  alpha_point=0.5, zorder_point=1,
                  xlabel="$x$ (m)", ylabel="$y$ (m)"):
        
    df_ex = df[df.experiment_type == experiment_type]
    df_arr = df_ex[df_ex.arrived == 1]
    if title is None:
        title = df_ex.experiment.iloc[0]
    for run in set(df_ex.total_ordering):
        df_run = df_ex[df_ex.total_ordering == run]
        plt.plot(df_run.xn, df_run.yn, alpha=alpha_path, color=color, zorder=zorder_path)
    plt.scatter(df_arr.xn, df_arr.yn, alpha=alpha_point, color=color, zorder=zorder_point)
    plot_targets(show_start=True, show_final=False, target_coords=[target])
    plt.axis("equal")
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.title(title)

In [11]:
def plot_by_distance(df, experiment_type, cmap="C0", target=TARGET,
                     alpha_point=0.5, zorder_point=1, crosshair=False,
                     xlabel="$x$ (m)", ylabel="$y$ (m)"):
    df_ex = df[df.experiment_type == experiment_type]
    df_arr = df_ex[df_ex.arrived == 1]
    plt.scatter(df_arr.xn, df_arr.yn,
                c=df_arr.distance, cmap=cmap)
    plt.colorbar(label="distance (m)")
    plt.clim(df[df.arrived==1].distance.min(), df[df.arrived==1].distance.max())
    plot_targets(show_start=False, show_final=False, target_coords=[TARGET], crosshair=crosshair)
    plt.axis("equal")
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)

In [12]:
def plot_detailed(df, experiment_type, color="C0", title=None, target=TARGET,
                  alpha_point=0.5, zorder_point=1, crosshair=False,
                  xlabel="$x$ (m)", ylabel="$y$ (m)"):
    df_ex = df[df.experiment_type == experiment_type]
    df_arr = df_ex[df_ex.arrived == 1]
    if title is None:
        title = df_ex.experiment.iloc[0]
    for order in np.arange(1, df.order.max()+1):
        df_run = df_arr[df_arr.order==order]
        plt.scatter(df_run.xn, df_run.yn,
                    label=f"Run {order}", color=shade_color(color, -50+25*(order-1)))
    plot_targets(show_start=False, show_final=False, target_coords=[TARGET], crosshair=crosshair)
    plt.title(title)
    plt.axis("equal")
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.legend()

In [13]:
def plot_distribution(df, experiment_type, color="C0", title=None,
                      target_color="C2", background_shade=-50, crosshair=False):
    df_ex = df[df.experiment_type == experiment_type]
    df_arr = df_ex[df_ex.arrived == 1]
    if title is None:
        title = df_ex.experiment.iloc[0]
    g = sns.jointplot(df_arr.xn, df_arr.yn, kind="kde", size=7, space=0, color=color)
    g.plot_marginals(sns.rugplot, height=0.1, color=color)
    g.ax_joint.get_children()[0].set_zorder(-1)
    for child in g.ax_joint.get_children()[1:]:
        if isinstance(child, mpl.collections.PathCollection):
            child.set_alpha(0.8)
    plt.sca(g.ax_joint)
    plot_targets(show_start=False, show_final=False, target_coords=[TARGET],
                 target_color=target_color, zorder=0, crosshair=crosshair)
    g.set_axis_labels("$x$", "$y$")
    plt.axis("equal")

    xmin, xmax = plt.xlim()
    ymin, ymax = plt.ylim()
    xsize = xmax - xmin
    ysize = ymax - ymin

    if xsize > ysize:
        ymin -= (xsize - ysize) / 2
        ymax += (xsize - ysize) / 2
        ysize = xsize
    else:
        xmin -= (ysize - xsize) / 2
        xmax += (ysize - xsize) / 2
        xsize = ysize

    plt.gca().add_patch(patches.Rectangle((xmin, ymin), xsize, ysize,
                                          color=saturate_color(color, background_shade), zorder=-1))
    g.fig.suptitle(title)

In [14]:
def plot_xy(df, x="x", y="y", invert_x=True, invert_y=True, s=None, c=None,
            cmap="viridis", alpha=1, show_cbar=True, label=None, line=False, zorder=0):
    """
    Coords in real frame. +x is towards doors, +y is away from table.
    
    """
    if s is not None:
        s = df[s]*25
    if c is not None:
        label = c
        try:
            df[c]
        except KeyError:
            pass
        else:
            c = df[c]
    else:
        if line:
            c = "C0"
        else:
            c = df.index
            label="time"
    
    if line:
        plt.plot(df[x] * (-1 if invert_x else 1), df[y] * (-1 if invert_y else 1), c=c, alpha=alpha, zorder=zorder)
    else:
        plt.scatter(df[x] * (-1 if invert_x else 1), df[y] * (-1 if invert_y else 1), s=s, c=c, cmap=cmap, alpha=alpha, zorder=zorder)
        if show_cbar:
            plt.colorbar(label=label)
    plt.axis("equal")

In [15]:
def plot_xy_conditional(df, condition=None, x="x", y="y", invert_x=True, invert_y=True,
                        s=None, c=None, c_condition=None, cmap_condition="viridis", cmap_not_condition="gray",
                        alpha_condition=1, alpha_not_condition=1, show_cbar=True, label=None, line=False,
                        zorder_condition=1, zorder_not_condition=0):
    if condition is None:
        cmap_not_condition = cmap_condition
    plot_xy(df, x=x, y=y, invert_x=invert_x, invert_y=invert_y,
            s=s, c=c, cmap=cmap_not_condition, alpha=alpha_not_condition, show_cbar=show_cbar,
            label=label, line=line, zorder=zorder_not_condition)
    if condition is not None:
        if line:
            show_cbar = False
            if c_condition is None:
                c = "C0"
            else:
                c = c_condition
        plot_xy(df[condition], x=x, y=y, invert_x=invert_x, invert_y=invert_y,
                s=s, c=c, cmap=cmap_condition, alpha=alpha_condition, show_cbar=show_cbar,
                label=label, zorder=zorder_condition)

In [16]:
def plot_targets(p_init=Coords(0, 0), p_final=Coords(0, 0), invert_x=False, invert_y=False,
                 target_coords=None, target_coord_offsets=None, target_color="C2",
                 target_size=Coords(0.525, 0.37), show_start=True, show_final=True,
                 scale=100, zorder=0, crosshair=False, background_shade=-50):
    if target_coords is not None and target_coord_offsets is not None:
        raise ValueError("Use either target_coords or target_coord_offsets")
    
    ax = plt.gca()
    
    if target_coords is None:
        if target_coord_offsets is None:
            target_coord_offsets = TARGET_COORD_OFFSETS
        target_coords = [Coords(p_init.x - offset.x, p_init.y - offset.y) for offset in target_coord_offsets]
    
    if show_start:
        plt.scatter(-p_init.x, -p_init.y, marker=(5, 0), s=100, c="g")
    for coord in target_coords:
        if crosshair:
            plt.axhline(coord.y, color=shade_color(target_color, background_shade/2), zorder=zorder)
            plt.axvline(coord.x, color=shade_color(target_color, background_shade/2), zorder=zorder)
        ax.add_patch(patches.Rectangle((coord.x * (-1 if invert_x else 1) - target_size.x / 2,
                                        coord.y * (-1 if invert_y else 1) - target_size.y / 2),
                                       target_size.x,
                                       target_size.y,
                                       color=target_color,
                                       zorder=zorder))
    if show_final:
        plt.scatter(p_final.x * (-1 if invert_x else 1), p_final.y * (-1 if invert_y else 1), marker=(3, 0), s=scale, c="r")

In [17]:
def tag_data(df):
    df["tag"] = (df.arrived.diff(1) != 0).astype('int').cumsum()

In [18]:
def distance(df, target):
    return np.sqrt((df.xn - target.x)**2 + (df.yn - target.y)**2)

In [41]:
def usable_filenames():
    filenames = sorted([filename for filename in glob.glob("csv/*.csv") if "user-99" not in filename])
    
    for filename in filenames:
        if not filename_regex.search(filename):
            continue
        if "user-99" not in filename:
            df = pd.read_csv(filename, parse_dates=["time"])
            if any(df.arrived):
                yield filename

In [42]:
def extract_run_data(filename):
    data = filename_regex.findall(filename)[0]
    return RunData(ExperimentType(int(data[0])), int(data[1]), int(data[2]))

In [43]:
def analyze_all():
    results = pd.DataFrame(columns="user experiment_type run dist_err x_err y_err "
                                    "dist_std x_std y_std rms rms_x rms_y duration".split())
    
    for i, filename in enumerate(usable_filenames()):
        data = extract_run_data(filename)
        df = pd.read_csv(filename, parse_dates=["time"])
        df.xn *= -1
        df.yn *= -1
        found = df[df.arrived == 1]

        distances = distance(found, TARGET)
        dist_err = distances.mean()
        dist_std = distances.std()

        dx = found.xn - TARGET.x
        x_err = dx.mean()
        x_std = dx.std()

        dy = found.yn - TARGET.y
        y_err = dy.mean()
        y_std = dy.std()

        rms = np.sqrt(np.mean(((found.xn - TARGET.x)**2 + (found.yn - TARGET.y)**2)))
        rms_x = np.sqrt(np.mean((dx)**2))
        rms_y = np.sqrt(np.mean((dy)**2))
        
        duration = (found.time.iloc[0] - df[df.z > 0.25].time.iloc[0]).total_seconds()

        results.loc[i] = [
            data.user, data.experiment, data.run,
            dist_err, x_err, y_err,
            dist_std, x_std, y_std,
            rms, rms_x, rms_y, duration
        ]    
    return results

In [148]:
def load():
    analyses = pd.DataFrame(columns="user experiment_type run dist_err x_err y_err "
                                    "dist_std x_std y_std rms rms_x rms_y "
                                    "idx_start idx_end t_start t_end duration "
                                    "path_length "
                                    "move_x move_l move_r "
                                    "move_y move_b move_f".split())
    
    records = []
    
    for i, filename in enumerate(usable_filenames()):
        data = extract_run_data(filename)
        df = pd.read_csv(filename, parse_dates=["time"])
        df.xn *= -1
        df.yn *= -1
        
        df["experiment_type"] = data.experiment
        df["user"] = data.user
        df["run"] = data.run
        records.append(df)
        
        found = df[df.arrived == 1]

        distances = distance(found, TARGET)
        dist_err = distances.mean()
        dist_std = distances.std()

        dx = found.xn - TARGET.x
        x_err = dx.mean()
        x_std = dx.std()

        dy = found.yn - TARGET.y
        y_err = dy.mean()
        y_std = dy.std()

        rms = np.sqrt(np.mean(((found.xn - TARGET.x)**2 + (found.yn - TARGET.y)**2)))
        rms_x = np.sqrt(np.mean((dx)**2))
        rms_y = np.sqrt(np.mean((dy)**2))
        
        t_start = df[df.z > 0.25].time.iloc[0]
        t_end = found.time.iloc[0]
        duration = (t_end - t_start).total_seconds()
        
        idx_start = df[df.time==t_start].index[0]
        idx_end = df[df.time==t_end].index[0]
        
        df_running = df[["xn", "yn"]].iloc[idx_start:idx_end+1]
        points = np.array(df_running)
        lengths = np.sqrt(np.sum(np.diff(points, axis=0)**2, axis=1))
        path = lengths.sum()
        
        diff_x = np.diff(points[:, 0])
        move_r = np.abs(np.sum(diff_x[diff_x > 0]))  # movement in negative direction
        move_l = np.abs(np.sum(diff_x[diff_x < 0]))  # movement in positive direction
        move_x = move_l + move_r

        diff_y = np.diff(points[:, 1])
        move_f = np.abs(np.sum(diff_y[diff_y > 0]))  # movement in negative direction
        move_b = np.abs(np.sum(diff_y[diff_y < 0]))  # movement in positive direction
        move_y = move_b + move_f

        analyses.loc[i] = [
            data.user, data.experiment, data.run,
            dist_err, x_err, y_err,
            dist_std, x_std, y_std,
            rms, rms_x, rms_y,
            idx_start, idx_end, t_start, t_end, duration,
            path,
            move_x, move_l, move_r,
            move_y, move_b, move_f,
        ]
        
    results = pd.concat(records, ignore_index=True)
    
    analyses["group"] = (analyses.user % 2).astype(int)
    analyses["start"] = [ExperimentType(e % 2 + 1) for e in analyses.user]
    analyses["experiment_int"] = [e.value for e in analyses.experiment_type]
    analyses["experiment"] = [e.name for e in analyses.experiment_type]
    analyses.experiment.replace("Spirit", "SPIRIT", inplace=True)

    results["group"] = (results.user % 2).astype(int)
    results["start"] = [ExperimentType(e % 2 + 1) for e in results.user]
    results["experiment_int"] = [e.value for e in results.experiment_type]
    results["experiment"] = [e.name for e in results.experiment_type]
    results.experiment.replace("Spirit", "SPIRIT", inplace=True)
    results.distance = distance(results, TARGET)
    results.dx = results.xn - TARGET.x
    results.dy = results.yn - TARGET.y
    results["total_ordering"] = ((results.run.diff(1) != 0)
                              | (results.experiment_int.diff(1) != 0)
                              | (results.user.diff(1) != 0)).astype('int').cumsum() - 1
    
    for user in set(analyses.user):
        df = analyses[analyses.user == user].sort_values(
            by="experiment_int", ascending=np.all(analyses[analyses.user==user]
                                             .start==ExperimentType.Onboard))
        df["order"] = range(1, len(df) + 1)
        for idx in df.index:
            analyses.loc[idx, "order"] = int(df.loc[idx, "order"])
            results.loc[results.total_ordering==idx, "order"] = int(df.loc[idx, "order"])
            
    for col in ["user", "run", "group", "order"]:
        analyses[col] = analyses[col].astype(int)
    for col in ["arrived", "order"]:
        results[col] = results[col].astype(int)
        
    return results, analyses

In [149]:
results, analyses = load()

In [134]:
analysis.move_x.plot()
analysis.move_y.plot()
analysis.path_length.plot()


Out[134]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f66b35323c8>

In [136]:
sns.factorplot(data=analysis, hue="experiment", x="order", y="path_length")


Out[136]:
<seaborn.axisgrid.FacetGrid at 0x7f66b3625a58>

In [137]:
sns.factorplot(data=analysis, hue="experiment", x="order", y="move_x")


Out[137]:
<seaborn.axisgrid.FacetGrid at 0x7f66b3393908>

In [138]:
sns.factorplot(data=analysis, hue="experiment", x="order", y="move_y")


Out[138]:
<seaborn.axisgrid.FacetGrid at 0x7f66b3576ef0>

In [141]:
sns.factorplot(data=analysis, x="experiment", y="move_b", kind="bar", )


Out[141]:
<seaborn.axisgrid.FacetGrid at 0x7f66b315dbe0>

In [91]:
analysis[analysis.user==8].index[0]


Out[91]:
16

In [93]:
analysis.iloc[16]


Out[93]:
user                                    8
experiment_type    ExperimentType.Onboard
run                                     0
dist_err                         0.330663
x_err                           -0.329519
y_err                           0.0269535
dist_std                       0.00443956
x_std                          0.00399099
y_std                           0.0057639
rms                              0.330693
rms_x                            0.329543
rms_y                           0.0275549
duration                          24.8964
group                                   0
start              ExperimentType.Onboard
experiment_int                          1
experiment                        Onboard
order                                   1
Name: 16, dtype: object

In [ ]:
analysis[analysis.user==8].iloc

In [ ]:
analysis[analysis.user==8].loc

In [60]:
filenames = usable_filenames()

In [104]:
_df = pd.read_csv(next(filenames), parse_dates=["time"])
points = np.array(_df[["xn", "yn"]])
lengths = np.sqrt(np.sum(np.diff(points, axis=0)**2, axis=1))
print(lengths.sum())


15.139666224

In [105]:
plt.scatter(_df.xn, _df.yn)


Out[105]:
<matplotlib.collections.PathCollection at 0x7f66fd1bd898>

In [95]:
analysis[["rms_x", "rms_y"]].iloc[15:17]


Out[95]:
rms_x rms_y
15 0.109587 0.362615
16 0.329543 0.027555

In [106]:
points


Out[106]:
array([[ 0.        ,  0.        ],
       [ 0.        ,  0.        ],
       [ 0.        ,  0.        ],
       ..., 
       [-0.42237988, -4.6361208 ],
       [-0.42237999, -4.63604355],
       [-0.42237999, -4.63604355]])

In [112]:
len(points[:, 0]


Out[112]:
array([ 0.        ,  0.        ,  0.        , ..., -0.42237988,
       -0.42237999, -0.42237999])

In [113]:
np.sum(np.diff(np.abs(points[:, 0])))


Out[113]:
0.42237998545200006

In [120]:
diff = np.diff(points[:, 1])
np.sum(diff[diff > 0])  # movement in negative direction
np.sum(diff[diff < 0])  # movement in positive direction

In [108]:
np.sum(np.diff(points[points[:, 0] > 0][:, 0]))


Out[108]:
0.00070208311080915964

In [95]:
def load_all():
    frames = []
    for filename in usable_filenames():
        df = pd.read_csv(filename, parse_dates=["time"])
        data = extract_run_data(filename)
        df["experiment_type"] = data.experiment
        df["user"] = data.user
        df["run"] = data.run
        frames.append(df)
    result = pd.concat(frames, ignore_index=True)
    result.xn *= -1
    result.yn *= -1
    return result

In [178]:
def parse_tlx_component(component):
    return TlxResponse(component.code, component.score, component.weight, component.weighted_score)

In [136]:
def best(sample1, sample2, σ_range, exponential_m, n_iter=2000, n_jobs=2):
    print(σ_range, exponential_m)
    y1 = np.array(sample1)
    y2 = np.array(sample2)
    y = pd.DataFrame(dict(value=np.r_[y1, y2],
                          group=np.r_[["onboard"]*len(sample1),
                                      ["spirit"]*len(sample2)]))
    μ_m = y.value.mean()
    μ_s = y.value.std() * 2

    with pm.Model() as model:
        group1_mean = pm.Normal("group1_mean", μ_m, sd=μ_s)
        group2_mean = pm.Normal("group2_mean", μ_m, sd=μ_s)
        σ_low, σ_high = σ_range
        group1_std = pm.Uniform("group1_std", lower=σ_low, upper=σ_high)
        group2_std = pm.Uniform("group2_std", lower=σ_low, upper=σ_high)
        ν = pm.Exponential("ν_minus_one", abs(1/(exponential_m-1))) + 1    
        
        λ1 = group1_std**-2
        λ2 = group2_std**-2

        group1 = pm.StudentT("onboard",
                             nu=ν, mu=group1_mean, lam=λ1, observed=y1)
        group2 = pm.StudentT("spirit",
                             nu=ν, mu=group2_mean, lam=λ2, observed=y2)
        
        diff_of_means = pm.Deterministic("difference of means",
                                         group1_mean - group2_mean)
        diff_of_stds = pm.Deterministic("difference of stds",
                                        group1_std - group2_std)
        effect_size = pm.Deterministic("effect size",
                                       diff_of_means / np.sqrt((group1_std**2
                                                                + group2_std**2)
                                                                / 2))
        trace = pm.sample(n_iter, init=None, njobs=n_jobs)
    return BestResult(trace, model)

In [130]:
def summarize(best_result, kde=True, plot=True):
    trace, model = best_result
    if plot:
        ax = pm.plot_posterior(trace[100:],
                               varnames=[r"group1_mean", r"group2_mean",
                                         r"group1_std", "group2_std",
                                         r"ν_minus_one"],
                               kde_plot=kde, color="C0");
        if kde:
            for a in (1, 3):
                ax[a].lines[0].set_color("C1")
        plt.figure()
        pm.plot_posterior(trace[1000:],
                          varnames=["difference of means", "difference of stds",
                                    "effect size"],
                          ref_val=0, kde_plot=True, color="C2");
        plt.figure()
        pm.forestplot(trace[1000:], varnames=[v.name for v in model.vars[:2]]);
        plt.figure()
        pm.forestplot(trace[1000:], varnames=[v.name for v in model.vars[2:]])

    pm.summary(trace[1000:],
               varnames=["difference of means", "difference of stds",
                         "effect size"])

In [138]:
def analyze_differences(df, columns, params, n_iter=2000, n_jobs=2,
                        show_summaries=True, plot=False):
    traces = {}
    for column, param in zip(columns, params):
        sample1 = df[df.experiment_type==ExperimentType.Onboard][column]
        sample2 = df[df.experiment_type==ExperimentType.Spirit][column]
        best_result = best(sample1, sample2, *param,
                           n_iter=n_iter, n_jobs=n_jobs)
        traces[column] = best_result
        if show_summaries:
            summarize(best_result, plot=plot)

In [143]:
analyze_differences(analyses, ["dist_err", "duration"], [[(0, 2), 0.5], [(5, 50), 50]])


(0, 2) 0.5
Assigned NUTS to group1_mean
Assigned NUTS to group2_mean
Assigned NUTS to group1_std_interval_
Assigned NUTS to group2_std_interval_
Assigned NUTS to ν_minus_one_log_
100%|██████████| 2000/2000 [00:22<00:00, 88.10it/s] 
difference of means:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.262            0.115            0.003            [0.057, 0.495]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  0.045          0.183          0.256          0.343          0.486


difference of stds:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.048            0.099            0.003            [-0.154, 0.242]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -0.149         -0.014         0.047          0.110          0.255


effect size:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  1.035            0.521            0.017            [0.116, 2.131]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  0.155          0.674          0.985          1.372          2.201

(5, 50) 50
Assigned NUTS to group1_mean
Assigned NUTS to group2_mean
Assigned NUTS to group1_std_interval_
Assigned NUTS to group2_std_interval_
Assigned NUTS to ν_minus_one_log_
100%|██████████| 2000/2000 [01:53<00:00, 17.67it/s]
difference of means:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  -5.216           6.083            0.185            [-16.882, 6.862]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -16.996        -9.160         -5.314         -1.176         6.823


difference of stds:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  3.688            4.951            0.155            [-6.130, 13.679]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -5.904         0.542          3.696          6.579          14.144


effect size:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  -0.318           0.368            0.012            [-1.067, 0.385]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -1.084         -0.566         -0.315         -0.067         0.375

Import the files.


In [488]:
ax1 = plt.subplot("121")
for filename in glob.glob("csv/experiment-1_*.csv"):
    if "user-99" not in filename:
        df = pd.read_csv(filename, parse_dates=["time"])
        if any(df.arrived):
            plot_xy_conditional(df, df.arrived==1, x="xn", y="yn", c="C0", c_condition="C0",
                                alpha_not_condition=0.2, alpha_condition=0.5, line=True,
                                zorder_condition=1, zorder_not_condition=0)
plot_targets(target_coords=[TARGET], show_final=False, zorder=-1)
plt.title("Onboard")

ax2 = plt.subplot("122", sharex=ax1, sharey=ax1)
for filename in glob.glob("csv/experiment-2_*.csv"):
    if "user-99" not in filename:
        df = pd.read_csv(filename, parse_dates=["time"])
        if any(df.arrived):
            plot_xy_conditional(df, df.arrived==1, x="xn", y="yn", c="C1", c_condition="C1",
                                alpha_not_condition=0.2, alpha_condition=0.5, line=True,
                                zorder_condition=1, zorder_not_condition=0)
plot_targets(target_coords=[TARGET], show_final=False, zorder=-1)
plt.title("SPIRIT")


Out[488]:
<matplotlib.text.Text at 0x7feef4cac518>

In [489]:
for filename in glob.glob("csv/experiment-1_*.csv"):
    if "user-99" not in filename:
        df = pd.read_csv(filename, parse_dates=["time"])
        if any(df.arrived):
            plot_xy_conditional(df, df.arrived==1, x="xn", y="yn", c="C0", c_condition="C0",
                                alpha_not_condition=0.2, alpha_condition=0.5, line=True,
                                zorder_condition=1, zorder_not_condition=0)
onboard_path, = plt.plot([], [], color="C0", label="Onboard path")
onboard_arrival, = plt.plot([], [], linestyle="none", color="C0", marker="o", label="Onboard arrival")
for filename in glob.glob("csv/experiment-2_*.csv"):
    if "user-99" not in filename:
        df = pd.read_csv(filename, parse_dates=["time"])
        if any(df.arrived):
            plot_xy_conditional(df, df.arrived==1, x="xn", y="yn", c="C1", c_condition="C1",
                                alpha_not_condition=0.2, alpha_condition=0.5, line=True,
                                zorder_condition=1, zorder_not_condition=0)
spirit_path, = plt.plot([], [], color="C1", label="SPIRIT path")
spirit_arrival, = plt.plot([], [], linestyle="none", color="C1", marker="o", label="SPIRIT arrival")
plot_targets(target_coords=[TARGET], show_final=False, zorder=-1)
plt.xlabel(r"$x$")
plt.ylabel(r"$y$")
plt.legend(handles=[onboard_path, onboard_arrival, spirit_path, spirit_arrival])


Out[489]:
<matplotlib.legend.Legend at 0x7feef4a25e80>

Check not too many multiple arrivals.


In [96]:
filenames = list(usable_filenames())
filenames


Out[96]:
['csv/experiment-1_user-00_run-00.csv',
 'csv/experiment-1_user-00_run-01.csv',
 'csv/experiment-1_user-01_run-00.csv',
 'csv/experiment-1_user-01_run-01.csv',
 'csv/experiment-1_user-02_run-00.csv',
 'csv/experiment-1_user-02_run-02.csv',
 'csv/experiment-1_user-03_run-00.csv',
 'csv/experiment-1_user-03_run-01.csv',
 'csv/experiment-1_user-04_run-00.csv',
 'csv/experiment-1_user-04_run-01.csv',
 'csv/experiment-1_user-05_run-01.csv',
 'csv/experiment-1_user-05_run-02.csv',
 'csv/experiment-1_user-06_run-00.csv',
 'csv/experiment-1_user-06_run-01.csv',
 'csv/experiment-1_user-07_run-00.csv',
 'csv/experiment-1_user-07_run-01.csv',
 'csv/experiment-1_user-08_run-00.csv',
 'csv/experiment-1_user-08_run-01.csv',
 'csv/experiment-2_user-00_run-00.csv',
 'csv/experiment-2_user-00_run-01.csv',
 'csv/experiment-2_user-01_run-00.csv',
 'csv/experiment-2_user-01_run-01.csv',
 'csv/experiment-2_user-02_run-00.csv',
 'csv/experiment-2_user-02_run-01.csv',
 'csv/experiment-2_user-03_run-00.csv',
 'csv/experiment-2_user-03_run-03.csv',
 'csv/experiment-2_user-04_run-00.csv',
 'csv/experiment-2_user-04_run-02.csv',
 'csv/experiment-2_user-05_run-00.csv',
 'csv/experiment-2_user-05_run-02.csv',
 'csv/experiment-2_user-06_run-02.csv',
 'csv/experiment-2_user-06_run-03.csv',
 'csv/experiment-2_user-07_run-00.csv',
 'csv/experiment-2_user-07_run-01.csv',
 'csv/experiment-2_user-08_run-00.csv',
 'csv/experiment-2_user-08_run-01.csv']

In [499]:
for filename in glob.glob("csv/experiment-*_user-08*.csv"):
    df = pd.read_csv(filename, parse_dates=["time"])
    plot_targets(target_coords=[TARGET], show_final=False, zorder=0, crosshair=True)
    color = "C0" if filename[15]=="1" else "C1"
    plot_xy_conditional(df, df.arrived==1, x="xn", y="yn", c=color, c_condition=color,
                        alpha_not_condition=0.5, alpha_condition=0.5, line=True)


Mega dataframe


In [40]:
analyses = analyze_all()
results = load_all()


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-40-ecc79e51f3e5> in <module>()
----> 1 analyses = analyze_all()
      2 results = load_all()

<ipython-input-21-7b307c055f08> in analyze_all()
      4 
      5     for i, filename in enumerate(usable_filenames()):
----> 6         data = extract_run_data(filename)
      7         df = pd.read_csv(filename, parse_dates=["time"])
      8         df.xn *= -1

<ipython-input-20-bf8b637ca0c2> in extract_run_data(filename)
      1 def extract_run_data(filename):
----> 2     data = filename_regex.findall(filename)[0]
      3     return RunData(ExperimentType(int(data[0])), int(data[1]), int(data[2]))

IndexError: list index out of range

In [217]:
results, analyses = load()
analyses.head()


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-217-ba2d0a7fff3d> in <module>()
----> 1 results, analyses = load()
      2 analyses.head()

<ipython-input-215-b255fad8769b> in load()
      5     records = []
      6 
----> 7     for i, filename in enumerate(usable_filenames()):
      8         data = extract_run_data(filename)
      9         df = pd.read_csv(filename, parse_dates=["time"])

<ipython-input-91-b7e7553e13d1> in usable_filenames()
      4     for filename in filenames:
      5         if "user-99" not in filename:
----> 6             df = pd.read_csv(filename, parse_dates=["time"])
      7             if any(df.arrived):
      8                 yield filename

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
    644                     skip_blank_lines=skip_blank_lines)
    645 
--> 646         return _read(filepath_or_buffer, kwds)
    647 
    648     parser_f.__name__ = name

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
    387 
    388     # Create the parser.
--> 389     parser = TextFileReader(filepath_or_buffer, **kwds)
    390 
    391     if (nrows is not None) and (chunksize is not None):

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
    728             self.options['has_index_names'] = kwds['has_index_names']
    729 
--> 730         self._make_engine(self.engine)
    731 
    732     def close(self):

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
    921     def _make_engine(self, engine='c'):
    922         if engine == 'c':
--> 923             self._engine = CParserWrapper(self.f, **self.options)
    924         else:
    925             if engine == 'python':

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
   1434                 raise ValueError("Usecols do not match names.")
   1435 
-> 1436         self._set_noconvert_columns()
   1437 
   1438         self.orig_names = self.names

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in _set_noconvert_columns(self)
   1484                         _set(k)
   1485                 else:
-> 1486                     _set(val)
   1487 
   1488         elif isinstance(self.parse_dates, dict):

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in _set(x)
   1474 
   1475             if not is_integer(x):
-> 1476                 x = names.index(x)
   1477 
   1478             self._reader.set_noconvert(x)

ValueError: 'time' is not in list

In [ ]:
analyses["group"] = (analyses.user % 2).astype(int)
analyses["start"] = [ExperimentType(e % 2 + 1) for e in analyses.user]
analyses["experiment_int"] = [e.value for e in analyses.experiment_type]
analyses["experiment"] = [e.name for e in analyses.experiment_type]
analyses.experiment.replace("Spirit", "SPIRIT", inplace=True)

results["group"] = (results.user % 2).astype(int)
results["start"] = [ExperimentType(e % 2 + 1) for e in results.user]
results["experiment_int"] = [e.value for e in results.experiment_type]
results["experiment"] = [e.name for e in results.experiment_type]
results.experiment.replace("Spirit", "SPIRIT", inplace=True)
results["distance"] = distance(results, TARGET)
results["dx"] = results.xn - TARGET.x
results["dy"] = results.yn - TARGET.y
results["total_ordering"] = ((results.run.diff(1) != 0)
                             | (results.experiment_int.diff(1) != 0)
                             | (results.user.diff(1) != 0)).astype('int').cumsum() - 1

In [27]:
for user in set(analyses.user):
    _df = analyses[analyses.user == user].sort_values(by="experiment_int", ascending=np.all(analyses[analyses.user==user].start==ExperimentType.Onboard))
    _df["order"] = range(1, len(_df) + 1)
    for idx in _df.index:
        analyses.loc[idx, "order"] = int(_df.loc[idx, "order"])
        results.loc[results.total_ordering==idx, "order"] = int(_df.loc[idx, "order"])

In [28]:
for col in ["user", "run", "group", "order"]:
    analyses[col] = analyses[col].astype(int)
for col in ["arrived", "order"]:
    results[col] = results[col].astype(int)

In [29]:
spirit_arrived = results[(results.arrived==1) & (results.experiment_type==ExperimentType.Spirit)]
onboard_arrived = results[(results.arrived==1) & (results.experiment_type==ExperimentType.Onboard)]

In [1160]:
plt.scatter(onboard_arrived.xn, onboard_arrived.yn, label="Onboard")
plt.scatter(spirit_arrived.xn, spirit_arrived.yn, label="SPIRIT")
plot_targets(show_start=False, show_final=False, target_coords=[TARGET])
plt.legend()


Out[1160]:
<matplotlib.legend.Legend at 0x7fee521dfb38>

In [632]:
plt.scatter(spirit_arrived[spirit_arrived.start==ExperimentType.Onboard].xn,
            spirit_arrived[spirit_arrived.start==ExperimentType.Onboard].yn,
            c="C1", label="Group 0")
plt.scatter(spirit_arrived[spirit_arrived.start==ExperimentType.Spirit].xn,
            spirit_arrived[spirit_arrived.start==ExperimentType.Spirit].yn,
            c=shade_color("C1", -50), label="Group 1")
plot_targets(show_start=False, show_final=False, target_coords=[TARGET])
plt.title("SPIRIT")
plt.legend()


Out[632]:
<matplotlib.legend.Legend at 0x7feee2736048>

In [633]:
plt.scatter(onboard_arrived[onboard_arrived.group==0].xn,
            onboard_arrived[onboard_arrived.group==0].yn,
            c=shade_color("C0", -50), label="Group 0")
plt.scatter(onboard_arrived[onboard_arrived.group==1].xn,
            onboard_arrived[onboard_arrived.group==1].yn,
            c="C0", label="Group 1")
plot_targets(show_start=False, show_final=False, target_coords=[TARGET])
plt.title("Onboard")
plt.legend()


Out[633]:
<matplotlib.legend.Legend at 0x7feee2523da0>

In [101]:
plt.scatter(spirit_arrived[spirit_arrived.order==1].xn, spirit_arrived[spirit_arrived.order==1].yn, label="Run 1", c=saturate_color("C1", -50))
plt.scatter(spirit_arrived[spirit_arrived.order==2].xn, spirit_arrived[spirit_arrived.order==2].yn, label="Run 2", c=saturate_color("C1", -25))
plt.scatter(spirit_arrived[spirit_arrived.order==3].xn, spirit_arrived[spirit_arrived.order==3].yn, label="Run 3", c=saturate_color("C1", 10))
plt.scatter(spirit_arrived[spirit_arrived.order==4].xn, spirit_arrived[spirit_arrived.order==4].yn, label="Run 4", c=saturate_color("C1", 50))
plot_targets(show_start=False, show_final=False, target_coords=[TARGET])
plt.title("SPIRIT")
plt.legend()
plt.axis("equal")


Out[101]:
(-0.35671556917940106,
 0.83579532867796602,
 4.7432750819855078,
 7.253605687744491)

In [640]:
plt.scatter(onboard_arrived[onboard_arrived.order==1].xn, onboard_arrived[onboard_arrived.order==1].yn, label="Run 1", c=shade_color("C0", -50))
plt.scatter(onboard_arrived[onboard_arrived.order==2].xn, onboard_arrived[onboard_arrived.order==2].yn, label="Run 2", c=shade_color("C0", -25))
plt.scatter(onboard_arrived[onboard_arrived.order==3].xn, onboard_arrived[onboard_arrived.order==3].yn, label="Run 3", c=shade_color("C0", 0))
plt.scatter(onboard_arrived[onboard_arrived.order==4].xn, onboard_arrived[onboard_arrived.order==4].yn, label="Run 4", c=shade_color("C0", 25))
plot_targets(show_start=False, show_final=False, target_coords=[TARGET])
plt.title("Onboard")
plt.legend()


Out[640]:
<matplotlib.legend.Legend at 0x7feee1f9a5c0>

In [642]:
analyses[analyses.user == 6].sort_values


Out[642]:
<bound method DataFrame.sort_values of     user              experiment  run   dist_err     x_err     y_err  \
12   6.0  ExperimentType.Onboard  0.0  11.322550 -0.611649  0.693983   
13   6.0  ExperimentType.Onboard  1.0  11.728489  0.252302  0.274229   
28   6.0   ExperimentType.Spirit  2.0  11.754809 -0.087296  0.245515   
29   6.0   ExperimentType.Spirit  3.0  11.920676 -0.270667  0.082450   

    dist_std     x_std     y_std       rms     rms_x     rms_y   duration  \
12  0.003611  0.003397  0.003434  0.925068  0.611658  0.693991  23.331129   
13  0.001770  0.008907  0.001584  0.372745  0.252457  0.274233  45.919718   
28  0.004243  0.003775  0.004216  0.260633  0.087376  0.245551  61.347842   
29  0.010691  0.035311  0.011451  0.285352  0.272942  0.083235  40.722825   

    group                   start  experiment_int  order  
12    0.0  ExperimentType.Onboard               1    1.0  
13    0.0  ExperimentType.Onboard               1    2.0  
28    0.0  ExperimentType.Onboard               2    3.0  
29    0.0  ExperimentType.Onboard               2    4.0  >

In [643]:
analyses[analyses.group == 0].rms.mean()


Out[643]:
0.67435106579040993

In [644]:
analyses[analyses.group == 1].rms.mean()


Out[644]:
0.63270993517112506

In [645]:
analyses[analyses.experiment_type == ExperimentType.Spirit].dist_err.mean()


Out[645]:
11.966150697499852

In [646]:
analyses[analyses.experiment_type == ExperimentType.Onboard].rms.mean()


Out[646]:
0.83362377161648848

In [647]:
analyses[(analyses.experiment_type == ExperimentType.Spirit) & (analyses.group == 0)].rms.mean()


Out[647]:
0.32309553774994576

In [648]:
analyses[(analyses.experiment_type == ExperimentType.Spirit) & (analyses.group == 1)].rms.mean()


Out[648]:
0.6237789209401472

In [649]:
analyses[(analyses.experiment_type == ExperimentType.Onboard) & (analyses.group == 0)].rms.mean()


Out[649]:
1.0256065938308743

In [650]:
analyses[(analyses.experiment_type == ExperimentType.Onboard) & (analyses.group == 1)].rms.mean()


Out[650]:
0.64164094940210281

In [651]:
plt.get_cmap("Dark2").colors


Out[651]:
((0.10588235294117647, 0.6196078431372549, 0.4666666666666667),
 (0.8509803921568627, 0.37254901960784315, 0.00784313725490196),
 (0.4588235294117647, 0.4392156862745098, 0.7019607843137254),
 (0.9058823529411765, 0.1607843137254902, 0.5411764705882353),
 (0.4, 0.6509803921568628, 0.11764705882352941),
 (0.9019607843137255, 0.6705882352941176, 0.00784313725490196),
 (0.6509803921568628, 0.4627450980392157, 0.11372549019607843),
 (0.4, 0.4, 0.4))

In [652]:
dt=analyses.duration.iloc[0]

In [227]:
g = sns.factorplot(x="experiment", y="duration", data=analyses, hue="group",
                   size=6, aspect=.75, kind="box")
sns.swarmplot(x="experiment", y="duration", data=analyses, hue="group", split=True, palette="Set2")
plt.ylim(0, 80)
g.despine(left=True)


Out[227]:
<seaborn.axisgrid.FacetGrid at 0x7f2d0b48bac8>

In [655]:
g = sns.factorplot(x="experiment", y="duration", data=analyses, hue="group",
                   capsize=.2, size=6, aspect=.75, kind="bar")
g.despine(left=True)


Out[655]:
<seaborn.axisgrid.FacetGrid at 0x7feee1cb5f28>

In [658]:
g = sns.factorplot(x="experiment", y="duration", data=analyses, hue="group",
                   capsize=.2, size=6, aspect=.75, kind="bar")
sns.swarmplot(x="experiment", y="duration", data=analyses, color="C5")
g.despine(left=True)


Out[658]:
<seaborn.axisgrid.FacetGrid at 0x7feee1c40dd8>

In [659]:
g = sns.factorplot(x="experiment", y="rms", data=analyses, hue="group",
                   capsize=.2, size=6, aspect=.75, kind="bar")
g.despine(left=True)


Out[659]:
<seaborn.axisgrid.FacetGrid at 0x7feee1a90278>

In [660]:
g = sns.factorplot(x="experiment", y="rms", data=analyses,
                   capsize=.2, size=6, aspect=.75, kind="bar")
g.despine(left=True)


Out[660]:
<seaborn.axisgrid.FacetGrid at 0x7feee1caad68>

In [661]:
g = sns.factorplot(x="experiment", y="rms", col="group", data=analyses,
                   capsize=.2, size=6, aspect=.75)
g.despine(left=True)


Out[661]:
<seaborn.axisgrid.FacetGrid at 0x7feee17edda0>

In [662]:
g = sns.factorplot(x="order", y="rms", col="group", hue="experiment", data=analyses,
                   capsize=.2, size=6, aspect=.75)
g.despine(left=True)


Out[662]:
<seaborn.axisgrid.FacetGrid at 0x7feee17321d0>

In [663]:
g = sns.factorplot(x="order", y="rms", hue="experiment", data=analyses,
                   capsize=.2, size=6, aspect=.75, kind="bar")
g.despine(left=True)


Out[663]:
<seaborn.axisgrid.FacetGrid at 0x7feee1661550>

In [664]:
g = sns.factorplot(x="order", y="rms", hue="user", col="group", data=analyses,
                   capsize=.2, size=6, aspect=.75)
g.despine(left=True)


Out[664]:
<seaborn.axisgrid.FacetGrid at 0x7feee13606d8>

In [666]:
g = sns.factorplot(x="order", y="rms", hue="experiment", data=analyses,
                   capsize=.2, size=6, aspect=.75)
g.despine(left=True)


Out[666]:
<seaborn.axisgrid.FacetGrid at 0x7feee0e1c358>

In [259]:
g = sns.factorplot(x="order", y="rms", hue="group", col="experiment", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[259]:
<seaborn.axisgrid.FacetGrid at 0x7fef4d3b00b8>

In [260]:
g = sns.factorplot(x="order", y="rms_x", col="group", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[260]:
<seaborn.axisgrid.FacetGrid at 0x7fef09741048>

In [261]:
g = sns.factorplot(x="order", y="rms_y", col="group", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[261]:
<seaborn.axisgrid.FacetGrid at 0x7fef094aaeb8>

In [262]:
g = sns.factorplot(x="experiment", y="x_err", col="group", hue="user", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[262]:
<seaborn.axisgrid.FacetGrid at 0x7fef092c3d30>

In [263]:
g = sns.factorplot(x="experiment", y="rms_x", col="group", hue="user", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[263]:
<seaborn.axisgrid.FacetGrid at 0x7fef0a594ef0>

In [264]:
g = sns.factorplot(x="order", y="rms", col="group", hue="user", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[264]:
<seaborn.axisgrid.FacetGrid at 0x7fef09666d68>

In [270]:
g = sns.factorplot(x="order", y="rms_x", col="group", hue="user", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[270]:
<seaborn.axisgrid.FacetGrid at 0x7fef079c6588>

In [271]:
g = sns.factorplot(x="experiment", y="rms", col="group", hue="user", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[271]:
<seaborn.axisgrid.FacetGrid at 0x7fef074ab748>

In [1098]:
g = sns.factorplot(x="experiment", y="distance", col="group", data=results[results.arrived==1],
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[1098]:
<seaborn.axisgrid.FacetGrid at 0x7fee5c65f860>

In [273]:
g = sns.factorplot(x="experiment", y="distance", col="group", hue="user", data=results[results.arrived==1],
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[273]:
<seaborn.axisgrid.FacetGrid at 0x7fef07041438>

In [274]:
g = sns.factorplot(x="order", y="distance", col="group", hue="user", data=results[results.arrived==1],
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[274]:
<seaborn.axisgrid.FacetGrid at 0x7fef07a0bb38>

In [85]:
g = sns.factorplot(x="order", y="xn", col="group", hue="user", data=results[results.arrived==1],
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)
g.axes[0][0].axhline(0)
g.axes[0][1].axhline(0)


Out[85]:
<matplotlib.lines.Line2D at 0x7f203d393a90>

In [276]:
g = sns.factorplot(x="order", y="yn", col="group", hue="user", data=results[results.arrived==1],
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)
g.axes[0][0].axhline(6)
g.axes[0][1].axhline(6)


Out[276]:
<matplotlib.lines.Line2D at 0x7fef041407b8>

In [277]:
g = sns.factorplot(x="order", y="rms", col="group", hue="user", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[277]:
<seaborn.axisgrid.FacetGrid at 0x7fef06c4aef0>

In [278]:
g = sns.factorplot(x="order", y="rms", hue="experiment", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[278]:
<seaborn.axisgrid.FacetGrid at 0x7fef07d7f0f0>

In [279]:
g = sns.factorplot(x="order", y="rms", hue="experiment", data=analyses,
                   capsize=.2, palette="Dark2", size=6, aspect=.75, kind="bar")
g.despine(left=True)


Out[279]:
<seaborn.axisgrid.FacetGrid at 0x7feefb4f4e48>

In [280]:
g = sns.factorplot(x="experiment", y="yn", col="group", hue="user", data=results[results.arrived==1],
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)
g.axes[0][0].axhline(6)
g.axes[0][1].axhline(6)


Out[280]:
<matplotlib.lines.Line2D at 0x7feefadb8cf8>

In [281]:
g = sns.factorplot(x="experiment", y="xn", col="group", hue="user", data=results[results.arrived==1],
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)
g.axes[0][0].axhline(0)
g.axes[0][1].axhline(0)


Out[281]:
<matplotlib.lines.Line2D at 0x7feefadb8d68>

In [282]:
g = sns.PairGrid(analyses, y_vars="rms_x",
                 x_vars=["order", "experiment", "group"],
                 size=5, aspect=.5)

# Draw a seaborn pointplot onto each Axes
g.map(sns.pointplot, color=sns.xkcd_rgb["plum"])
g.set(ylim=(0, 1))
sns.despine(fig=g.fig, left=True)



In [283]:
g = sns.PairGrid(analyses, y_vars="rms_y",
                 x_vars=["order", "experiment", "group"],
                 size=5, aspect=.5)

# Draw a seaborn pointplot onto each Axes
g.map(sns.pointplot, color=sns.xkcd_rgb["plum"])
g.set(ylim=(0, 1))
sns.despine(fig=g.fig, left=True)



In [1029]:
g = sns.PairGrid(analyses, y_vars="rms",
                 x_vars=["order", "experiment", "group"],
                 size=5, aspect=.5)

# Draw a seaborn pointplot onto each Axes
g.map(sns.pointplot)
g.set(ylim=(0, 1))
sns.despine(fig=g.fig, left=True)



In [64]:
sns.lmplot(x="xn", y="yn", col="group", hue="experiment", data=results[results.arrived==1],
           col_wrap=2, palette="Dark2",
           scatter_kws={"s": 50, "alpha": 1})


Out[64]:
<seaborn.axisgrid.FacetGrid at 0x7fef0659af60>

In [65]:
sns.lmplot(x="xn", y="yn", col="experiment", hue="group", data=results[results.arrived==1],
           col_wrap=2, palette="Dark2",
           scatter_kws={"s": 50, "alpha": 1})


Out[65]:
<seaborn.axisgrid.FacetGrid at 0x7fef0598c668>

In [414]:
sns.distplot(analyses[analyses.experiment_type==ExperimentType.Onboard].duration, hist=False)
sns.distplot(analyses[analyses.experiment_type==ExperimentType.Spirit].duration, hist=False)


Out[414]:
<matplotlib.axes._subplots.AxesSubplot at 0x7feef787ba20>

In [788]:
g = sns.jointplot(spirit_arrived.xn, spirit_arrived.yn, kind="kde", size=7, space=0, color="C1")



In [66]:
g = sns.jointplot(spirit_arrived.xn, spirit_arrived.yn, kind="kde", size=7, space=0)
plt.title("SPIRIT")
g = sns.jointplot(spirit_arrived[spirit_arrived.group==0].xn, spirit_arrived[spirit_arrived.group==0].yn, kind="kde", size=7, space=0)
plt.title("SPIRIT - Group 0")
g = sns.jointplot(spirit_arrived[spirit_arrived.group==1].xn, spirit_arrived[spirit_arrived.group==1].yn, kind="kde", size=7, space=0)
plt.title("SPIRIT - Group 1")


Out[66]:
<matplotlib.text.Text at 0x7fef05be7fd0>

In [67]:
g = sns.jointplot(onboard_arrived.xn, onboard_arrived.yn, kind="kde", size=7, space=0)
g = sns.jointplot(onboard_arrived[onboard_arrived.group==0].xn, onboard_arrived[onboard_arrived.group==0].yn, kind="kde", size=7, space=0)
g = sns.jointplot(onboard_arrived[onboard_arrived.group==1].xn, onboard_arrived[onboard_arrived.group==1].yn, kind="kde", size=7, space=0)



In [27]:
g = sns.jointplot(results[results.arrived==1].xn, results[results.arrived==1].yn, kind="kde", size=7, space=0)
# g.plot_marginals(sns.rugplot, height=0.1



In [193]:
analyses["experiment_int"] = [e.value for e in analyses.experiment]
results["experiment_int"] = [e.value for e in results.experiment]

In [185]:
g = sns.factorplot(x="experiment", y="rms", hue="group", data=analyses,
                   size=6, kind="bar", palette="Dark2")
g.despine(left=True)


Out[185]:
<seaborn.axisgrid.FacetGrid at 0x7f0eef2a7a90>

In [186]:
g = sns.factorplot(x="order", y="rms", hue="group", data=analyses,
                   size=6, kind="bar", palette="Dark2")
g.despine(left=True)


Out[186]:
<seaborn.axisgrid.FacetGrid at 0x7f0eee787860>

In [187]:
g = sns.factorplot(x="order", y="rms", hue="experiment", col="group", data=analyses,
                   size=6, kind="bar", palette="Dark2")
g.despine(left=True)


Out[187]:
<seaborn.axisgrid.FacetGrid at 0x7f0eef9b4ba8>

In [1030]:
g = sns.FacetGrid(analyses, col="experiment", margin_titles=True)
bins = np.linspace(0, 2.5, 13)
g.map(plt.hist, "rms", bins=bins, lw=0)


Out[1030]:
<seaborn.axisgrid.FacetGrid at 0x7fee617b34a8>

In [1186]:
sns.distplot(analyses[analyses.experiment_type == ExperimentType.Spirit].duration, hist=False, rug=True, color="C1")
sns.distplot(analyses[analyses.experiment_type == ExperimentType.Onboard].duration, hist=False, rug=True, color="C0")


Out[1186]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fee4f4160f0>

In [1187]:
sns.distplot(analyses[analyses.experiment_type == ExperimentType.Spirit].rms, hist=False, rug=True, color="C0")
sns.distplot(analyses[analyses.experiment_type == ExperimentType.Onboard].rms, hist=False, rug=True, color="C1")


Out[1187]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fee4ee2ddd8>

In [291]:
analyses[analyses.experiment_type == ExperimentType.Spirit].rms.mean()


Out[291]:
0.47343722934504651

In [292]:
analyses[analyses.experiment_type == ExperimentType.Onboard].rms.mean()


Out[292]:
0.83362377161648848

In [68]:
f, axes = plt.subplots(1, 2, figsize=(8, 8), sharex=True, sharey=True)
axes[0].set_aspect("equal")
axes[1].set_aspect("equal")

sns.kdeplot(onboard_arrived[onboard_arrived.group==0].xn, onboard_arrived[onboard_arrived.group==0].yn,
            cmap="Reds", shade=True, shade_lowest=False, ax=axes[0])
sns.kdeplot(onboard_arrived[onboard_arrived.group==1].xn, onboard_arrived[onboard_arrived.group==1].yn,
            cmap="Blues", shade=True, shade_lowest=False, ax=axes[0])

axes[0].scatter(0, 6, c="C7", s=100)

sns.kdeplot(spirit_arrived[spirit_arrived.group==1].xn, spirit_arrived[spirit_arrived.group==1].yn,
            cmap="Blues", shade=True, shade_lowest=False, ax=axes[1])
sns.kdeplot(spirit_arrived[spirit_arrived.group==0].xn, spirit_arrived[spirit_arrived.group==0].yn,
            cmap="Reds", shade=True, shade_lowest=False, ax=axes[1])

axes[1].scatter(0, 6, c="C7", s=100)


Out[68]:
<matplotlib.collections.PathCollection at 0x7fa300ac23c8>

In [84]:
g = sns.PairGrid(analyses[analyses.experiment_type==ExperimentType.Onboard][["rms", "rms_x", "rms_y"]], diag_sharey=False)
g.map_lower(sns.kdeplot, cmap="Blues_d")
g.map_upper(plt.scatter)
g.map_diag(sns.kdeplot, lw=3)


/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "
Out[84]:
<seaborn.axisgrid.PairGrid at 0x7f66764c62e8>

In [38]:
g = sns.PairGrid(analyses[analyses.experiment_type==ExperimentType.Spirit][["rms", "rms_x", "rms_y"]], diag_sharey=False)
g.map_lower(sns.kdeplot)
g.map_upper(plt.scatter)
g.map_diag(sns.kdeplot, lw=3)


/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "
Out[38]:
<seaborn.axisgrid.PairGrid at 0x7f20301edda0>

In [40]:
g = sns.PairGrid(analyses[analyses.experiment_type==ExperimentType.Spirit][["dist_err", r"x_err", r"y_err"]], diag_sharey=False)
g.map_lower(sns.kdeplot)
g.map_upper(plt.scatter)
g.map_diag(sns.kdeplot, lw=3)


/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "
Out[40]:
<seaborn.axisgrid.PairGrid at 0x7f2031bc2d30>

In [196]:
g = sns.PairGrid(analyses[["rms", "rms_x", "rms_y"]], diag_sharey=False)
g.map_lower(sns.kdeplot, cmap="Blues_d")
g.map_upper(plt.scatter)
g.map_diag(sns.kdeplot, lw=3)


/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "
Out[196]:
<seaborn.axisgrid.PairGrid at 0x7f0ef134dd68>

In [195]:
g = sns.PairGrid(analyses[["rms", "rms_x", "rms_y", "group", "order", "experiment_int"]], diag_sharey=False)
g.map_lower(sns.kdeplot, cmap="Blues_d")
g.map_upper(plt.scatter)
g.map_diag(sns.kdeplot, lw=3)


/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "
Out[195]:
<seaborn.axisgrid.PairGrid at 0x7f0ef3c84860>

In [70]:
g = sns.PairGrid(results[results.arrived==1][["xn", "yn", "group", "order", "experiment_int"]], diag_sharey=False)
g.map_lower(sns.kdeplot, cmap="Blues_d")
g.map_upper(plt.scatter)
g.map_diag(sns.kdeplot, lw=3)


/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labelled objects found. "
Out[70]:
<seaborn.axisgrid.PairGrid at 0x7fa30ced5470>

In [746]:
sns.pairplot(analyses[["rms", "rms_x", "rms_y", "group", "order", "experiment"]], hue="experiment")


Out[746]:
<seaborn.axisgrid.PairGrid at 0x7feeb7ee7400>

In [72]:
sns.pairplot(analyses[["rms", "rms_x", "rms_y", "group", "order", "experiment"]], hue="group")


Out[72]:
<seaborn.axisgrid.PairGrid at 0x7fa300609f28>

In [73]:
sns.pairplot(results[results.arrived==1][["xn", "yn", "group", "order", "experiment_int"]], hue="group")


Out[73]:
<seaborn.axisgrid.PairGrid at 0x7fa2f51ae128>

In [74]:
sns.pairplot(results[results.arrived==1][["xn", "yn", "group", "order", "experiment_int"]], hue="experiment_int")


Out[74]:
<seaborn.axisgrid.PairGrid at 0x7fa2f42b8b70>

In [75]:
sns.swarmplot(x="group", y="rms", hue="experiment", data=analyses)


Out[75]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fa2f5f11390>

SURVEYS!


In [171]:
import pickle

In [172]:
with open("data.pickle", "rb") as fin:
    data = pickle.load(fin)

In [173]:
users = pd.DataFrame({"user_id": user.id_, "name": user.name, "age": user.age,
                       "teleop": user.teleop, "flying": user.flying} for user in data)
users


Out[173]:
age flying name teleop user_id
0 23 0 takemori 0 0
1 22 0 tsujimoto 0 1
2 22 0 yanagiya 0 2
3 29 0 sajid nisar 75 3
4 25 0 chen 10 4
5 24 0 kawai 0 5
6 24 0 wen 0 6
7 24 0 konishi 0 7
8 25 0 michael wang 1 8

In [174]:
users.age.astype(int).std()


Out[174]:
2.1081851067789197

In [175]:
users.age.astype(int).mean()


Out[175]:
24.222222222222221

In [ ]:


In [179]:
_tlx_data = []
for user in data:
    for experiment in user.experiments:
        d = {"user": user.id_, "experiment_type": experiment.type_}
        for component in experiment.tlx.components.values():
            parsed = parse_tlx_component(component)
            d[parsed.code] = parsed.score
        _tlx_data.append(d)
tlx = pd.DataFrame(_tlx_data)
tlx["group"] = tlx.user % 2
tlx["tlx"] = tlx.mental + tlx.physical + tlx.temporal + tlx.performance + tlx.effort + tlx.frustration
tlx["order"] = [1, 2]*(len(tlx)//2)
tlx["experiment_int"] = [e.value for e in tlx.experiment_type]
tlx["experiment"] = [e.name for e in tlx.experiment_type]
tlx.experiment.replace("Spirit", "SPIRIT", inplace=True)
tlx


Out[179]:
effort experiment_type frustration mental performance physical temporal user group tlx order experiment_int experiment
0 14 ExperimentType.Onboard 56 10 42 0 60 0 0 182 1 1 Onboard
1 18 ExperimentType.Spirit 30 8 16 0 6 0 0 78 2 2 SPIRIT
2 4 ExperimentType.Spirit 10 20 10 0 0 1 1 44 1 2 SPIRIT
3 15 ExperimentType.Onboard 12 16 6 0 0 1 1 49 2 1 Onboard
4 57 ExperimentType.Onboard 54 32 20 0 10 2 0 173 1 1 Onboard
5 33 ExperimentType.Spirit 45 28 30 0 3 2 0 139 2 2 SPIRIT
6 9 ExperimentType.Spirit 5 15 25 0 6 3 1 60 1 2 SPIRIT
7 16 ExperimentType.Onboard 0 15 20 3 4 3 1 58 2 1 Onboard
8 20 ExperimentType.Onboard 36 64 16 0 5 4 0 141 1 1 Onboard
9 20 ExperimentType.Spirit 30 60 6 0 5 4 0 121 2 2 SPIRIT
10 28 ExperimentType.Spirit 22 44 24 0 6 5 1 124 1 2 SPIRIT
11 32 ExperimentType.Onboard 5 32 14 0 24 5 1 107 2 1 Onboard
12 64 ExperimentType.Onboard 0 36 60 32 28 6 0 220 1 1 Onboard
13 27 ExperimentType.Spirit 5 14 15 6 14 6 0 81 2 2 SPIRIT
14 12 ExperimentType.Spirit 9 25 4 0 3 7 1 53 1 2 SPIRIT
15 52 ExperimentType.Onboard 36 30 27 5 0 7 1 150 2 1 Onboard
16 24 ExperimentType.Onboard 13 26 40 28 10 8 0 141 1 1 Onboard
17 30 ExperimentType.Spirit 0 4 20 4 5 8 0 63 2 2 SPIRIT

In [180]:
_survey_data = []

for user in data:
    for experiment in user.experiments:
        d = {"user": user.id_, "experiment_type": experiment.type_}
        d.update({i.code:i.score for i in experiment.survey.questions.values()})
        _survey_data.append(d)

surveys = pd.DataFrame(_survey_data)
surveys["group"] = tlx.user % 2
surveys["order"] = [1, 2]*(len(surveys)//2)
surveys["experiment"] = [e.name for e in surveys.experiment_type]
surveys["experiment_int"] = [e.value for e in surveys.experiment_type]
surveys.experiment.replace("Spirit", "SPIRIT", inplace=True)
surveys


Out[180]:
experiment_type orientation_control orientation_understanding position_control position_understanding spacial_control spacial_understanding user group order experiment experiment_int
0 ExperimentType.Onboard 5 5 2 2 1 2 0 0 1 Onboard 1
1 ExperimentType.Spirit 4 4 6 5 6 5 0 0 2 SPIRIT 2
2 ExperimentType.Spirit 4 5 3 5 4 6 1 1 1 SPIRIT 2
3 ExperimentType.Onboard 4 4 2 4 2 2 1 1 2 Onboard 1
4 ExperimentType.Onboard 2 4 2 2 1 1 2 0 1 Onboard 1
5 ExperimentType.Spirit 4 5 3 4 4 5 2 0 2 SPIRIT 2
6 ExperimentType.Spirit 3 3 4 4 6 5 3 1 1 SPIRIT 2
7 ExperimentType.Onboard 5 5 5 5 5 2 3 1 2 Onboard 1
8 ExperimentType.Onboard 6 6 5 5 4 3 4 0 1 Onboard 1
9 ExperimentType.Spirit 6 6 6 6 6 6 4 0 2 SPIRIT 2
10 ExperimentType.Spirit 5 4 5 4 3 3 5 1 1 SPIRIT 2
11 ExperimentType.Onboard 3 3 4 3 4 4 5 1 2 Onboard 1
12 ExperimentType.Onboard 2 3 1 2 1 1 6 0 1 Onboard 1
13 ExperimentType.Spirit 4 4 5 6 6 6 6 0 2 SPIRIT 2
14 ExperimentType.Spirit 6 6 5 5 5 4 7 1 1 SPIRIT 2
15 ExperimentType.Onboard 3 2 4 3 2 2 7 1 2 Onboard 1
16 ExperimentType.Onboard 6 5 4 3 3 2 8 0 1 Onboard 1
17 ExperimentType.Spirit 2 2 4 3 3 4 8 0 2 SPIRIT 2

In [31]:
g = sns.factorplot(x="experiment", y="tlx", data=tlx,
                   size=6, kind="violin", split=True, inner=None)
sns.swarmplot(x="group", y="tlx", data=tlx, color="w", alpha=.5)
g.despine(left=True)


Out[31]:
<seaborn.axisgrid.FacetGrid at 0x7f4fc73ba978>

In [46]:
g = sns.factorplot(x="experiment", y="tlx", data=tlx,
                   size=6, kind="bar")



In [47]:
g = sns.factorplot(x="experiment", y="tlx", data=tlx,
                   size=6, kind="box")
plt.ylim(0, plt.ylim()[1])


Out[47]:
(0, 228.80000000000001)

In [48]:
g = sns.factorplot(x="variable", y="value", hue="experiment",
                   data=pd.melt(tlx, id_vars=["user", "experiment", "group", "tlx", "order"]),
                   size=6, kind="bar", palette="Dark2")
g.despine(left=True)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-48-6e408c896d82> in <module>()
      1 g = sns.factorplot(x="variable", y="value", hue="experiment",
      2                    data=pd.melt(tlx, id_vars=["user", "experiment", "group", "tlx", "order"]),
----> 3                    size=6, kind="bar", palette="Dark2")
      4 g.despine(left=True)

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/seaborn/categorical.py in factorplot(x, y, hue, data, row, col, col_wrap, estimator, ci, n_boot, units, order, hue_order, row_order, col_order, kind, size, aspect, orient, color, palette, legend, legend_out, sharex, sharey, margin_titles, facet_kws, **kwargs)
   3389     # facets to ensure representation of all data in the final plot
   3390     p = _CategoricalPlotter()
-> 3391     p.establish_variables(x_, y_, hue, data, orient, order, hue_order)
   3392     order = p.group_names
   3393     hue_order = p.hue_names

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/seaborn/categorical.py in establish_variables(self, x, y, hue, data, orient, order, hue_order, units)
    152 
    153             # Figure out the plotting orientation
--> 154             orient = self.infer_orient(x, y, orient)
    155 
    156             # Option 2a:

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/seaborn/categorical.py in infer_orient(self, x, y, orient)
    345             else:
    346                 return "h"
--> 347         elif is_not_numeric(y):
    348             if is_not_numeric(x):
    349                 raise ValueError(no_numeric)

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/seaborn/categorical.py in is_not_numeric(s)
    325         def is_not_numeric(s):
    326             try:
--> 327                 np.asarray(s, dtype=np.float)
    328             except ValueError:
    329                 return True

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/numpy/core/numeric.py in asarray(a, dtype, order)
    529 
    530     """
--> 531     return array(a, dtype, copy=False, order=order)
    532 
    533 

TypeError: float() argument must be a string or a number, not 'ExperimentType'

In [49]:
g = sns.factorplot(x="group", y="tlx", hue="experiment", data=tlx,
                   size=6, kind="bar", palette="Dark2")
g.despine(left=True)


Out[49]:
<seaborn.axisgrid.FacetGrid at 0x7f4ff4ab0a58>

In [97]:
g = sns.factorplot(x="experiment", y="tlx", hue="group", data=tlx,
                   size=6, kind="bar", palette="Dark2")
g.despine(left=True)


Out[97]:
<seaborn.axisgrid.FacetGrid at 0x7fef04b714a8>

In [98]:
g = sns.PairGrid(tlx, y_vars="tlx",
                 x_vars=["group", "experiment"],
                 size=5, aspect=.5)

# Draw a seaborn pointplot onto each Axes
g.map(sns.pointplot, color=sns.xkcd_rgb["plum"])
sns.despine(fig=g.fig, left=True)



In [99]:
g = sns.factorplot(x="experiment", y="tlx", col="group", hue="user", data=tlx,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[99]:
<seaborn.axisgrid.FacetGrid at 0x7fef04b78588>

In [100]:
g = sns.factorplot(x="experiment", y="tlx", col="group", data=tlx,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[100]:
<seaborn.axisgrid.FacetGrid at 0x7fef046c4278>

In [101]:
g = sns.factorplot(x="group", y="tlx", col="experiment", data=tlx,
                   size=6, kind="bar", palette="Dark2")
g.despine(left=True)


Out[101]:
<seaborn.axisgrid.FacetGrid at 0x7fef0465f048>

In [102]:
g = sns.factorplot(x="group", y="tlx", col="experiment", data=tlx,
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[102]:
<seaborn.axisgrid.FacetGrid at 0x7fef05242f98>

In [103]:
g = sns.factorplot(x="experiment", y="value", col="group", hue="variable",
                   data=pd.melt(tlx, id_vars=["user", "experiment", "group", "tlx", "order"]),
                   capsize=.2, palette="Dark2", size=6, aspect=.75)
g.despine(left=True)


Out[103]:
<seaborn.axisgrid.FacetGrid at 0x7fef049975f8>

In [104]:
g = sns.factorplot(x="variable", y="value", hue="experiment", col="group",
                   data=pd.melt(tlx, id_vars=["user", "experiment", "group", "tlx", "order"]),
                   size=6, kind="bar", palette="Dark2")
g.despine(left=True)


Out[104]:
<seaborn.axisgrid.FacetGrid at 0x7fef05dae320>

In [105]:
surveys


Out[105]:
experiment orientation_control orientation_understanding position_control position_understanding spacial_control spacial_understanding user group order
0 ExperimentType.Onboard 5 5 2 2 1 2 0 0 1
1 ExperimentType.Spirit 4 4 6 5 6 5 0 0 2
2 ExperimentType.Spirit 4 5 3 5 4 6 1 1 1
3 ExperimentType.Onboard 4 4 2 4 2 2 1 1 2
4 ExperimentType.Onboard 2 4 2 2 1 1 2 0 1
5 ExperimentType.Spirit 4 5 3 4 4 5 2 0 2
6 ExperimentType.Spirit 3 3 4 4 6 5 3 1 1
7 ExperimentType.Onboard 5 5 5 5 5 2 3 1 2
8 ExperimentType.Onboard 6 6 5 5 4 3 4 0 1
9 ExperimentType.Spirit 6 6 6 6 6 6 4 0 2
10 ExperimentType.Spirit 5 4 5 4 3 3 5 1 1
11 ExperimentType.Onboard 3 3 4 3 4 4 5 1 2
12 ExperimentType.Onboard 2 3 1 2 1 1 6 0 1
13 ExperimentType.Spirit 4 4 5 6 6 6 6 0 2
14 ExperimentType.Spirit 6 6 5 5 5 4 7 1 1
15 ExperimentType.Onboard 3 2 4 3 2 2 7 1 2

In [106]:
g = sns.factorplot(x="variable", y="value", hue="experiment",
                   data=pd.melt(surveys, id_vars=["user", "experiment", "group", "order"]),
                   size=6, kind="bar", palette="Dark2")
g.set_xticklabels(rotation=90)
g.despine(left=True)


Out[106]:
<seaborn.axisgrid.FacetGrid at 0x7fef056cbe80>

In [107]:
g = sns.factorplot(x="variable", y="value", hue="experiment", col="group",
                   data=pd.melt(surveys, id_vars=["user", "experiment", "group", "order"]),
                   size=6, kind="bar", palette="Dark2")
g.set_xticklabels(rotation=90)
g.despine(left=True)


Out[107]:
<seaborn.axisgrid.FacetGrid at 0x7fef04a013c8>

In [108]:
g = sns.factorplot(x="variable", y="value", hue="experiment", col="group",
                   data=pd.melt(surveys, id_vars=["user", "experiment", "group", "order"]),
                   size=6, kind="violin", split=True)

g.set_xticklabels(rotation=90)
g.despine(left=True)


Out[108]:
<seaborn.axisgrid.FacetGrid at 0x7fef0f6e2f98>

In [ ]:

PyMC3


In [142]:
sample1 = analyses[analyses.experiment_type==ExperimentType.Onboard].dist_err
sample2 = analyses[analyses.experiment_type==ExperimentType.Spirit].dist_err
trace_dist, model_dist = best(sample1, sample2, (0, 2), 0.5)
summarize(trace_dist, model_dist)


(0, 2) 0.5
Assigned NUTS to group1_mean
Assigned NUTS to group2_mean
Assigned NUTS to group1_std_interval_
Assigned NUTS to group2_std_interval_
Assigned NUTS to ν_minus_one_log_
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-142-79221a2fa39e> in <module>()
      1 sample1 = analyses[analyses.experiment_type==ExperimentType.Onboard].dist_err
      2 sample2 = analyses[analyses.experiment_type==ExperimentType.Spirit].dist_err
----> 3 trace_dist, model_dist = best(sample1, sample2, (0, 2), 0.5)
      4 summarize(trace_dist, model_dist)

<ipython-input-136-ec12daeed82f> in best(sample1, sample2, σ_range, exponential_m, n_iter, n_jobs)
     33                                                                 + group2_std**2)
     34                                                                 / 2))
---> 35         trace = pm.sample(n_iter, init=None, njobs=n_jobs)
     36     return BestResult(trace, model)

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/sampling.py in sample(draws, step, init, n_init, start, trace, chain, njobs, tune, progressbar, model, random_seed)
    151             start = start_
    152     else:
--> 153         step = assign_step_methods(model, step)
    154 
    155     if njobs is None:

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/sampling.py in assign_step_methods(model, step, methods)
     74 
     75     # Instantiate all selected step methods
---> 76     steps += [step(vars=selected_steps[step]) for step in selected_steps if selected_steps[step]]
     77 
     78     if len(steps) == 1:

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/sampling.py in <listcomp>(.0)
     74 
     75     # Instantiate all selected step methods
---> 76     steps += [step(vars=selected_steps[step]) for step in selected_steps if selected_steps[step]]
     77 
     78     if len(steps) == 1:

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/step_methods/nuts.py in __init__(self, vars, scaling, step_scale, is_cov, state, Emax, target_accept, gamma, k, t0, model, profile, **kwargs)
     70         if isinstance(scaling, dict):
     71             scaling = guess_scaling(
---> 72                 Point(scaling, model=model), model=model, vars=vars)
     73 
     74         n = scaling.shape[0]

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/tuning/scaling.py in guess_scaling(point, vars, model, scaling_bound)
    109     model = modelcontext(model)
    110     try:
--> 111         h = find_hessian_diag(point, vars, model=model)
    112     except NotImplementedError:
    113         h = fixed_hessian(point, vars, model=model)

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/tuning/scaling.py in find_hessian_diag(point, vars, model)
    102     """
    103     model = modelcontext(model)
--> 104     H = model.fastfn(hessian_diag(model.logpt, vars))
    105     return H(Point(point, model=model))
    106 

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/memoize.py in memoizer(*args, **kwargs)
     13 
     14         if key not in cache:
---> 15             cache[key] = obj(*args, **kwargs)
     16 
     17         return cache[key]

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/theanof.py in hessian_diag(f, vars)
    107 
    108     if vars:
--> 109         return -tt.concatenate([hessian_diag1(f, v) for v in vars], axis=0)
    110     else:
    111         return empty_gradient

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/theanof.py in <listcomp>(.0)
    107 
    108     if vars:
--> 109         return -tt.concatenate([hessian_diag1(f, v) for v in vars], axis=0)
    110     else:
    111         return empty_gradient

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pymc3/theanof.py in hessian_diag1(f, v)
     98         return gradient1(g[i], v)[i]
     99 
--> 100     return theano.map(hess_ii, idx)[0]
    101 
    102 

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/scan_module/scan_views.py in map(fn, sequences, non_sequences, truncate_gradient, go_backwards, mode, name)
     67                      go_backwards=go_backwards,
     68                      mode=mode,
---> 69                      name=name)
     70 
     71 

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/scan_module/scan.py in scan(fn, sequences, outputs_info, non_sequences, n_steps, truncate_gradient, go_backwards, mode, name, profile, allow_gc, strict)
    793     fake_outputs = scan_utils.clone(outputs,
    794                                     replace=OrderedDict(izip(non_seqs,
--> 795                                                              fake_nonseqs)))
    796     all_inputs = ifilter(
    797         lambda x: (isinstance(x, gof.Variable) and

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/scan_module/scan_utils.py in clone(output, replace, strict, share_inputs, copy_inputs)
    244                                          [],
    245                                          strict,
--> 246                                          share_inputs)
    247 
    248     # TODO Explain why we call it twice ?!

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in rebuild_collect_shared(outputs, inputs, replace, updates, rebuild_strict, copy_inputs_over, no_default_updates)
    216         for v in outputs:
    217             if isinstance(v, Variable):
--> 218                 cloned_v = clone_v_get_shared_updates(v, copy_inputs_over)
    219                 cloned_outputs.append(cloned_v)
    220             elif isinstance(v, Out):

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     90             if owner not in clone_d:
     91                 for i in owner.inputs:
---> 92                     clone_v_get_shared_updates(i, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/compile/pfunc.py in clone_v_get_shared_updates(v, copy_inputs_over)
     93 
     94                 clone_d[owner] = owner.clone_with_new_inputs(
---> 95                     [clone_d[i] for i in owner.inputs], strict=rebuild_strict)
     96                 for old_o, new_o in zip(owner.outputs, clone_d[owner].outputs):
     97                     clone_d.setdefault(old_o, new_o)

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/gof/graph.py in clone_with_new_inputs(self, inputs, strict)
    247             new_node.tag = copy(self.tag).__update__(new_node.tag)
    248         else:
--> 249             new_node = self.clone()
    250             new_node.inputs = new_inputs
    251         return new_node

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/gof/graph.py in clone(self)
    205         """
    206         cp = self.__class__(self.op, self.inputs,
--> 207                             [output.clone() for output in self.outputs])
    208         cp.tag = copy(self.tag)
    209         return cp

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/gof/graph.py in <listcomp>(.0)
    205         """
    206         cp = self.__class__(self.op, self.inputs,
--> 207                             [output.clone() for output in self.outputs])
    208         cp.tag = copy(self.tag)
    209         return cp

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/theano/gof/graph.py in clone(self)
    449         """
    450         # return copy(self)
--> 451         cp = self.__class__(self.type, None, None, self.name)
    452         cp.tag = copy(self.tag)
    453         return cp

KeyboardInterrupt: 

In [59]:
sample1 = analyses[analyses.experiment_type==ExperimentType.Onboard].x_err
sample2 = analyses[analyses.experiment_type==ExperimentType.Spirit].x_err
trace_x, model_x = best(sample1, sample2, (0, 2), 0.5)
summarize(trace_x, model_x)


Assigned NUTS to group1_mean
Assigned NUTS to group2_mean
Assigned NUTS to group1_std_interval_
Assigned NUTS to group2_std_interval_
Assigned NUTS to ν_minus_one_log_
100%|██████████| 2000/2000 [00:20<00:00, 96.01it/s] 
difference of means:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  -0.102           0.150            0.005            [-0.381, 0.208]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -0.380         -0.205         -0.109         -0.005         0.212


difference of stds:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.258            0.122            0.003            [0.038, 0.501]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  0.051          0.178          0.247          0.334          0.524


effect size:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  -0.351           0.502            0.017            [-1.351, 0.556]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -1.348         -0.654         -0.337         -0.018         0.569

<matplotlib.figure.Figure at 0x7f2d845f7fd0>

In [61]:
sample1 = analyses[analyses.experiment_type==ExperimentType.Onboard].y_err
sample2 = analyses[analyses.experiment_type==ExperimentType.Spirit].y_err
trace_y, model_y = best(sample1, sample2, (0, 2), 0.5)
summarize(trace_y, model_y)


Assigned NUTS to group1_mean
Assigned NUTS to group2_mean
Assigned NUTS to group1_std_interval_
Assigned NUTS to group2_std_interval_
Assigned NUTS to ν_minus_one_log_
100%|██████████| 2000/2000 [00:50<00:00, 39.48it/s]
difference of means:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  -0.403           0.171            0.006            [-0.744, -0.074]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -0.738         -0.518         -0.404         -0.288         -0.064


difference of stds:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.081            0.156            0.003            [-0.201, 0.423]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -0.212         -0.018         0.071          0.178          0.415


effect size:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  -1.015           0.478            0.015            [-1.913, -0.048]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -2.036         -1.313         -0.978         -0.693         -0.138

<matplotlib.figure.Figure at 0x7f2d8fadfcf8>

In [62]:
sample1 = analyses[analyses.experiment_type==ExperimentType.Onboard].rms_x
sample2 = analyses[analyses.experiment_type==ExperimentType.Spirit].rms_x
trace_rmsx, model_rmsx = best(sample1, sample2, (0, 2), 0.5)
summarize(trace_rmsx, model_rmsx)


Assigned NUTS to group1_mean
Assigned NUTS to group2_mean
Assigned NUTS to group1_std_interval_
Assigned NUTS to group2_std_interval_
Assigned NUTS to ν_minus_one_log_
100%|██████████| 2000/2000 [00:20<00:00, 99.04it/s] 
difference of means:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.146            0.075            0.002            [0.014, 0.304]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  0.005          0.094          0.145          0.197          0.299


difference of stds:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.070            0.070            0.002            [-0.065, 0.209]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -0.057         0.024          0.064          0.111          0.223


effect size:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.930            0.510            0.012            [0.058, 2.050]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  0.022          0.573          0.904          1.255          2.016

<matplotlib.figure.Figure at 0x7f2d8515dc88>

In [70]:
sample1 = analyses[analyses.experiment_type==ExperimentType.Onboard].rms_y
sample2 = analyses[analyses.experiment_type==ExperimentType.Spirit].rms_y
trace_rmsy, model_rmsy = best(sample1, sample2, (0, 2), 0.5)
summarize(trace_rmsy, model_rmsy)


Assigned NUTS to group1_mean
Assigned NUTS to group2_mean
Assigned NUTS to group1_std_interval_
Assigned NUTS to group2_std_interval_
Assigned NUTS to ν_minus_one_log_
100%|██████████| 2000/2000 [00:14<00:00, 138.38it/s]
difference of means:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.184            0.112            0.003            [-0.034, 0.403]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -0.039         0.110          0.188          0.260          0.400


difference of stds:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.074            0.099            0.003            [-0.129, 0.268]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -0.109         0.012          0.069          0.129          0.292


effect size:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  0.720            0.471            0.012            [-0.133, 1.726]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -0.153         0.413          0.695          1.010          1.719

<matplotlib.figure.Figure at 0x7f2d536dcb00>

In [65]:
sample1 = analyses[analyses.experiment_type==ExperimentType.Onboard].duration
sample2 = analyses[analyses.experiment_type==ExperimentType.Spirit].duration
trace_dur, model_dur = best(sample1, sample2, (5, 50), 50)
summarize(trace_dur, model_dur)


Assigned NUTS to group1_mean
Assigned NUTS to group2_mean
Assigned NUTS to group1_std_interval_
Assigned NUTS to group2_std_interval_
Assigned NUTS to ν_minus_one_log_
100%|██████████| 2000/2000 [02:04<00:00, 16.01it/s]
difference of means:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  -5.399           5.953            0.173            [-17.077, 5.981]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -16.728        -9.525         -5.519         -1.434         6.461


difference of stds:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  3.693            4.972            0.147            [-5.498, 14.555]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -5.925         0.491          3.582          6.617          14.390


effect size:

  Mean             SD               MC Error         95% HPD interval
  -------------------------------------------------------------------
  
  -0.326           0.361            0.011            [-1.013, 0.386]

  Posterior quantiles:
  2.5            25             50             75             97.5
  |--------------|==============|==============|--------------|
  
  -1.040         -0.562         -0.326         -0.084         0.370

<matplotlib.figure.Figure at 0x7f2d59e20080>

Graphs


In [212]:
ax1 = plt.subplot("121")
plot_overview(results, ExperimentType.Onboard, color="C0")
ax2 = plt.subplot("122", sharex=ax1, sharey=ax1)
plot_overview(results, ExperimentType.Spirit, color="C1", ylabel="")
plt.setp(ax2.get_yticklabels(), visible=False);


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-212-2bff6decd1bb> in <module>()
      1 ax1 = plt.subplot("121")
----> 2 plot_overview(results, ExperimentType.Onboard, color="C0")
      3 ax2 = plt.subplot("122", sharex=ax1, sharey=ax1)
      4 plot_overview(results, ExperimentType.Spirit, color="C1", ylabel="")
      5 plt.setp(ax2.get_yticklabels(), visible=False);

<ipython-input-9-37faf381c55b> in plot_overview(df, experiment_type, color, title, target, alpha_path, zorder_path, alpha_point, zorder_point, xlabel, ylabel)
      8     if title is None:
      9         title = df_ex.experiment.iloc[0]
---> 10     for run in set(df_ex.total_ordering):
     11         df_run = df_ex[df_ex.total_ordering == run]
     12         plt.plot(df_run.xn, df_run.yn, alpha=alpha_path, color=color, zorder=zorder_path)

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name)
   2742             if name in self._info_axis:
   2743                 return self[name]
-> 2744             return object.__getattribute__(self, name)
   2745 
   2746     def __setattr__(self, name, value):

AttributeError: 'DataFrame' object has no attribute 'total_ordering'

In [ ]:


In [213]:
ax1 = plt.subplot("121")
plot_detailed(results, ExperimentType.Onboard, color="C0", crosshair=True)
ax2 = plt.subplot("122", sharex=ax1, sharey=ax1)
plot_detailed(results, ExperimentType.Spirit, color="C1", crosshair=True, ylabel="")
plt.setp(ax2.get_yticklabels(), visible=False);



In [214]:
plot_distribution(results, ExperimentType.Onboard, color="C0", crosshair=True)
plot_distribution(results, ExperimentType.Spirit, color="C1", crosshair=True)



In [38]:
# plot_distribution(results[results.group==0], ExperimentType.Onboard, color="C0", crosshair=True)
# plot_distribution(results[results.group==0], ExperimentType.Spirit, color="C1", crosshair=True)

In [39]:
# plot_distribution(results[results.group==1], ExperimentType.Onboard, color="C0", crosshair=True)
# plot_distribution(results[results.group==1], ExperimentType.Spirit, color="C1", crosshair=True)

In [255]:
g = sns.boxplot(x="experiment", y="duration", data=analyses)
sns.swarmplot(x="experiment", y="duration", split=True, data=analyses, palette="Set2")
plt.ylim(0, plt.ylim()[1])
plt.ylabel("duration (s)")
plt.title("Duration")


Out[255]:
<matplotlib.text.Text at 0x7f2d4e2c2470>

In [154]:
g = sns.factorplot(x="order", y="duration", hue="experiment", data=analyses, capsize=0.2)
plt.title("Duration")
plt.ylabel("duration (s)")
plt.xlabel("run")
plt.ylim(0, plt.ylim()[1])


Out[154]:
(0, 77.268633470720005)

In [165]:
molten = pd.melt(analysis, id_vars=["user", "experiment", "order", "group"],
                                value_vars=["path_length", "move_x", "move_y"])
g = sns.factorplot(x="order", y="value", col="variable",
                   data=molten, hue="experiment",
                   size=4)
g.fig.axes[0].set_title("Path length")
g.fig.axes[1].set_title("Movement in $x$")
g.fig.axes[2].set_title("Movement in $y$")
g.fig.axes[0].set_ylabel("distance (m)")
plt.ylim(0, plt.ylim()[1])


Out[165]:
(0, 16.219244457287083)

In [150]:
molten = pd.melt(analysis, id_vars=["user", "experiment", "order", "group"],
                                value_vars=["path_length", "move_x", "move_y"])
g = sns.factorplot(x="experiment", y="value", col="variable",
                   data=molten,
                   kind="box", size=4)
g.fig.axes[0].set_title("Path length")
g.fig.axes[1].set_title("Movement in $x$")
g.fig.axes[2].set_title("Movement in $y$")
g.fig.axes[0].set_ylabel("distance (m)")
plt.ylim(0, plt.ylim()[1])


Out[150]:
(0, 17.847110715514205)

In [157]:
molten = pd.melt(analysis, id_vars=["user", "experiment", "order", "group"],
                                value_vars=["move_l", "move_r", "move_x"])
g = sns.factorplot(x="experiment", y="value", col="variable",
                   data=molten,
                   kind="box", size=4)
g.fig.axes[0].set_title("Movement to the left")
g.fig.axes[1].set_title("Movement to the right")
g.fig.axes[2].set_title("Movement in $x$")
g.fig.axes[0].set_ylabel("distance (m)")
plt.ylim(0, plt.ylim()[1])


Out[157]:
(0, 12.549668948016532)

In [162]:
sns.boxplot(x="experiment", y="move_b", data=analyses)
sns.swarmplot(x="experiment", y="move_b", split=True, data=analyses, palette="Set2")
plt.ylabel("distance (m)")
plt.title("Movement backwards")


Out[162]:
<matplotlib.text.Text at 0x7f66b1aba198>

In [169]:
sns.factorplot(x="experiment", y="move_b", data=analyses, kind="box", size=2.1)
sns.swarmplot(x="experiment", y="move_b", split=True, data=analyses, palette="Set2")
plt.ylabel("distance (m)")
plt.title("Movement backwards")


Out[169]:
<matplotlib.text.Text at 0x7f66b0854ef0>

In [154]:
molten = pd.melt(analyses, id_vars=["user", "experiment", "order", "group"],
                                value_vars=["move_b", "move_f", "move_y"])
g = sns.factorplot(x="experiment", y="value", col="variable",
                   data=molten,
                   kind="box", size=4)
g.fig.axes[0].set_title("Movement backwards")
g.fig.axes[1].set_title("Movement forwards")
g.fig.axes[2].set_title("Movement in $y$")
g.fig.axes[0].set_ylabel("distance (m)")
plt.ylim(0, plt.ylim()[1])


Out[154]:
(0, 13.082654605277256)

In [257]:
molten = pd.melt(analyses, id_vars=["user", "experiment", "order", "group"],
                                value_vars=["rms", "rms_x", "rms_y"])
g = sns.factorplot(x="experiment", y="value", col="variable",
                   data=molten,
                   kind="box", size=4)
g.fig.axes[0].set_title("RMS Error")
g.fig.axes[1].set_title("RMS Error in $x$")
g.fig.axes[2].set_title("RMS Error in $y$")
g.fig.axes[0].set_ylabel("error (m)")


Out[257]:
<matplotlib.text.Text at 0x7f2d3b9ddb70>

In [167]:
sns.boxplot?

In [43]:
g = sns.factorplot(x="order", y="value", hue="experiment", col="variable",
                   data=pd.melt(analyses, id_vars=["user", "experiment", "order", "group"],
                                value_vars=["rms", "rms_x", "rms_y"]),
                   capsize=0.2)
g.fig.axes[0].set_title("RMS Error")
g.fig.axes[1].set_title("RMS Error in $x$")
g.fig.axes[2].set_title("RMS Error in $y$")
g.fig.axes[0].set_ylabel("error (m)")j
g.fig.axes[0].set_xlabel("run")
g.fig.axes[1].set_xlabel("run")
g.fig.axes[2].set_xlabel("run")


Out[43]:
<matplotlib.text.Text at 0x7f2dc2e05630>

In [44]:
g = sns.factorplot(x="experiment", y="value", col="variable",
                   data=pd.melt(analyses, id_vars=["user", "experiment", "order", "group"],
                                value_vars=[r"dist_err", r"x_err", r"y_err"]),
                   size=4, kind="box")
g.fig.axes[0].set_title("Distance from target")
g.fig.axes[1].set_title("Distance from target in $x$")
g.fig.axes[2].set_title("Distance from target in $y$")
g.fig.axes[0].set_ylabel("distance (m)")
g.axes[0][0].axhline(0, color="black", linewidth=1, zorder=-1)
g.axes[0][1].axhline(0, color="black", linewidth=1, zorder=-1)
g.axes[0][2].axhline(0, color="black", linewidth=1, zorder=-1)


Out[44]:
<matplotlib.lines.Line2D at 0x7f2dc25d07f0>

In [228]:
g = sns.boxplot(x="experiment", y="tlx", data=tlx)
plt.ylim(0, plt.ylim()[1])
plt.title("NASA-TLX results")
plt.ylabel("weighted score")
sns.swarmplot(x="experiment", y=r"tlx", data=tlx, palette="Set2", split=True)


Out[228]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f2d0b388400>

In [252]:
molten = pd.melt(tlx, id_vars=["user", "experiment", "order"],
                                value_vars=["mental", "physical", "temporal",
                                            "performance", "effort", "frustration"],
                                var_name="component", value_name="score")
g = sns.barplot(x=r"component", y="score", hue="experiment",
                   data=molten, palette="Dark2")

sns.swarmplot(x="component", y=r"score", data=molten, hue="experiment", split=True, palette="Set2")
handles, labels = g.get_legend_handles_labels()
plt.legend(handles[2:], labels[2:])
plt.ylabel("component score")
plt.title("NASA-TLX component analysis")


Out[252]:
<matplotlib.text.Text at 0x7f2d4c324160>

In [193]:
molten = pd.melt(surveys, id_vars=["user", "experiment", "order"],
                               value_vars=[r"orientation_understanding", r"orientation_control",
                                           r"position_understanding", r"position_control",
                                           r"spacial_understanding", r"spacial_control"],
                               var_name="question", value_name="rating")
g = sns.factorplot(x=r"rating", y=r"question", hue="experiment",
                   data=molten, kind="bar", size=7)
g = sns.swarmplot(x="rating", y=r"question", data=molten, hue="experiment", split=True, palette="Set2")
plt.gca().set_yticklabels(["orientation understanding", "orientation control",
                           "absolute position understanding", "absolute positional control",
                           "relative position understanding", "relative position control"]);
# g.legend_.set_visible(False)
plt.xlabel("rating")
plt.title("Survey results")


Out[193]:
<matplotlib.text.Text at 0x7f66b3ae99e8>

In [183]:
g.ax.legend_.set_visible


Out[183]:
<seaborn.axisgrid.FacetGrid at 0x7f66b0695d68>

In [66]:
pm.plot_posterior(trace_dist[1000:],
                  varnames=[r'difference of means', "effect size"],
                  ref_val=0,
                  kde_plot=True)
plt.gcf().suptitle("Distance")


Out[66]:
<matplotlib.text.Text at 0x7f2d5ffa6d68>

In [69]:
pm.plot_posterior(trace_rmsx[1000:],
                  varnames=[r'difference of means', "effect size"],
                  ref_val=0,
                  kde_plot=True)
plt.gcf().suptitle("Distance in $x$")


Out[69]:
<matplotlib.text.Text at 0x7f2d6501b128>

In [71]:
pm.plot_posterior(trace_rmsy[1000:],
                  varnames=[r'difference of means', "effect size"],
                  ref_val=0,
                  kde_plot=True)
plt.gcf().suptitle("Distance in $y$")


Out[71]:
<matplotlib.text.Text at 0x7f2d6196aa20>

In [68]:
pm.plot_posterior(trace_dur[1000:],
                  varnames=[r'difference of means', "effect size"],
                  ref_val=0,
                  kde_plot=True)
plt.gcf().suptitle("Duration")


Out[68]:
<matplotlib.text.Text at 0x7f2d60db4358>

In [192]:
pd.read_csv("foo.csv")


---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-192-dc3c250597b2> in <module>()
----> 1 pd.read_csv("foo.csv")

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
    644                     skip_blank_lines=skip_blank_lines)
    645 
--> 646         return _read(filepath_or_buffer, kwds)
    647 
    648     parser_f.__name__ = name

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
    387 
    388     # Create the parser.
--> 389     parser = TextFileReader(filepath_or_buffer, **kwds)
    390 
    391     if (nrows is not None) and (chunksize is not None):

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
    728             self.options['has_index_names'] = kwds['has_index_names']
    729 
--> 730         self._make_engine(self.engine)
    731 
    732     def close(self):

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
    921     def _make_engine(self, engine='c'):
    922         if engine == 'c':
--> 923             self._engine = CParserWrapper(self.f, **self.options)
    924         else:
    925             if engine == 'python':

/home/masasin/.pyenv/versions/3.6.0/envs/scipy_stack/lib/python3.6/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
   1388         kwds['allow_leading_cols'] = self.index_col is not False
   1389 
-> 1390         self._reader = _parser.TextReader(src, **kwds)
   1391 
   1392         # XXX

pandas/parser.pyx in pandas.parser.TextReader.__cinit__ (pandas/parser.c:4184)()

pandas/parser.pyx in pandas.parser.TextReader._setup_parser_source (pandas/parser.c:8449)()

FileNotFoundError: File b'foo.csv' does not exist

t-Tests

Duration


In [72]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard)].duration
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit)].duration
stats.ttest_rel(sample1, sample2)


Out[72]:
Ttest_relResult(statistic=-0.91507962956471622, pvalue=0.37294779629332853)

In [73]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==0)].duration
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==0)].duration
stats.ttest_rel(sample1, sample2)


Out[73]:
Ttest_relResult(statistic=-0.30857789960721915, pvalue=0.76466579082207775)

In [74]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==1)].duration
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==1)].duration
stats.ttest_rel(sample1, sample2)


Out[74]:
Ttest_relResult(statistic=-0.95598318142183381, pvalue=0.37092235643331684)

Distance


In [75]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard)].dist_err
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit)].dist_err
stats.ttest_rel(sample1, sample2)


Out[75]:
Ttest_relResult(statistic=1.7409291086460894, pvalue=0.099762254469103459)

In [76]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==0)].dist_err
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==0)].dist_err
stats.ttest_rel(sample1, sample2)


Out[76]:
Ttest_relResult(statistic=2.0978248933226311, pvalue=0.0653485271874754)

In [77]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==1)].dist_err
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==1)].dist_err
stats.ttest_rel(sample1, sample2)


Out[77]:
Ttest_relResult(statistic=0.087693685916465369, pvalue=0.93257610546421488)

X-distance


In [78]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard)].x_err
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit)].x_err
stats.ttest_rel(sample1, sample2)


Out[78]:
Ttest_relResult(statistic=0.08089271794373934, pvalue=0.93647198905569196)

In [79]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==0)].x_err
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==0)].x_err
stats.ttest_rel(sample1, sample2)


Out[79]:
Ttest_relResult(statistic=0.67064979789923418, pvalue=0.51928118634465015)

In [80]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==1)].x_err
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==1)].x_err
stats.ttest_rel(sample1, sample2)


Out[80]:
Ttest_relResult(statistic=-0.92018296792624077, pvalue=0.38808786865899048)

X-error


In [81]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard)].rms_x
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit)].rms_x
stats.ttest_rel(sample1, sample2)


Out[81]:
Ttest_relResult(statistic=1.6723906011827947, pvalue=0.11274931636152256)

In [82]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==0)].rms_x
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==0)].rms_x
stats.ttest_rel(sample1, sample2)


Out[82]:
Ttest_relResult(statistic=2.5505570285562178, pvalue=0.031166249394182281)

In [83]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==1)].rms_x
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==1)].rms_x
stats.ttest_rel(sample1, sample2)


Out[83]:
Ttest_relResult(statistic=-0.88503695752902811, pvalue=0.40550994650102107)

Y-distance


In [84]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard)].y_err
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit)].y_err
stats.ttest_rel(sample1, sample2)


Out[84]:
Ttest_relResult(statistic=-2.4173737503049439, pvalue=0.02715420744778281)

In [85]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==0)].y_err
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==0)].y_err
stats.ttest_rel(sample1, sample2)


Out[85]:
Ttest_relResult(statistic=-3.1854296930177779, pvalue=0.011087650657090399)

In [86]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==1)].y_err
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==1)].y_err
stats.ttest_rel(sample1, sample2)


Out[86]:
Ttest_relResult(statistic=-0.44837591485948136, pvalue=0.66743167859471408)

Y-error


In [87]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard)].rms_y
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit)].rms_y
stats.ttest_rel(sample1, sample2)


Out[87]:
Ttest_relResult(statistic=1.1998126584143565, pvalue=0.24666688552714594)

In [88]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==0)].rms_y
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==0)].rms_y
stats.ttest_rel(sample1, sample2)


Out[88]:
Ttest_relResult(statistic=1.1838176121666046, pvalue=0.26680831168111419)

In [89]:
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==1)].rms_y
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==1)].rms_y
stats.ttest_rel(sample1, sample2)


Out[89]:
Ttest_relResult(statistic=0.34749337176320527, pvalue=0.73843469572198872)

Manual BEST


In [190]:
def dnorm(x, mu, sd):
    return 1/(sd * np.sqrt(2 * np.pi)) * np.exp(-(x - mu)**2 / (2 * sd**2))

def dexp(x, l):
    return l * np.exp(- l*x)

def likelihood(parameters):
    mu1, sd1, mu2, sd2 = parameters
    return dnorm(sample1, mu1, sd1).prod()*dnorm(sample2, mu2, sd2).prod()

def prior(pooled, parameters):
    mu1, sd1, mu2, sd2 = parameters
    return (dnorm(mu1, pooled.mean(), 1000*pooled.std())
            * dnorm(mu2, pooled.mean(), 1000*pooled.std())
            * dexp(sd1, 0.1) 
            * dexp(sd2, 0.1))

def posterior(pooled, parameters):
    return likelihood(parameters)*prior(pooled, parameters)

def mcmc(pooled, parameters, n_iter=10000):
    results = np.zeros([niter, 4])
    results[1,:] = parameters

    for iteration in np.arange(2, niter):
        candidate = parameters + np.random.normal(0, 0.5, 4)
        ratio = posterior(pooled, candidate) / posterior(pooled, parameters)
        if np.random.uniform() < ratio:
            parameters = candidate
        results[iteration, :] = parameters

    #burn-in
    results = results[499:niter-1, :]
    
    return results
    
def best(sample1, sample2, params=None, n_iter=10000):
    if params is None:
        params = np.array([100, 10, 100, 10])
    pooled = np.append(sample1, sample2)
    results = mcmc(pooled, params, n_iter=n_iter)
    mu1 = results[:, 1]
    mu2 = results[:, 3]
    return mu2 - mu1

In [191]:
sample1 = analyses[analyses.experiment_type==ExperimentType.Onboard].duration
sample2 = analyses[analyses.experiment_type==ExperimentType.Spirit].duration
sns.distplot(sample1, hist=False)
sns.distplot(sample2, hist=False)


Out[191]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f4fc04d3748>

In [163]:
d = best(sample1, sample2, n_iter=1000)
sns.distplot(d)
plt.title(np.mean(d > 0))


Out[163]:
<matplotlib.text.Text at 0x7f4fc159fc88>

In [178]:
sample1 = analyses[analyses.experiment_type==ExperimentType.Onboard].dist_err
sample2 = analyses[analyses.experiment_type==ExperimentType.Spirit].dist_err
sns.distplot(sample1, hist=False, rug=True)
sns.distplot(sample2, hist=False, rug=True)


Out[178]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f4fc07abdd8>

In [192]:
d = best(sample1, sample2, n_iter=10000)
sns.distplot(d)
plt.title(np.mean(d > 0))


Out[192]:
<matplotlib.text.Text at 0x7f4fc0103d68>

In [217]:
def dnorm(x, mu, sig):
    return 1/(sig * np.sqrt(2 * np.pi)) * np.exp(-(x - mu)**2 / (2 * sig**2))

def dexp(x, l):
    return l * np.exp(- l*x)

def like(parameters):
    [mu1, sig1, mu2, sig2] = parameters
    return dnorm(sample1, mu1, sig1).prod()*dnorm(sample2, mu2, sig2).prod()

def prior(parameters):
    [mu1, sig1, mu2, sig2] = parameters
    return dnorm(mu1, pooled.mean(), 1000*pooled.std()) * dnorm(mu2, pooled.mean(), 1000*pooled.std()) * dexp(sig1, 0.1) * dexp(sig2, 0.1)

def posterior(parameters):
    [mu1, sig1, mu2, sig2] = parameters
    return like([mu1, sig1, mu2, sig2])*prior([mu1, sig1, mu2, sig2])


#create samples
np.random.seed=7
#sample1 = np.random.normal(100, 3, 8)
#sample2 = np.random.normal(97, 3, 10)
sample1 = analyses[(analyses.experiment_type==ExperimentType.Onboard) & (analyses.group==0)].rms
sample2 = analyses[(analyses.experiment_type==ExperimentType.Spirit) & (analyses.group==0)].rms

pooled= np.append(sample1, sample2)

sns.distplot(sample1, hist=False, rug=True)
sns.distplot(sample2, hist=False, rug=True)

mu1 = 1
sig1 = 0.1
mu2 = 1
sig2 = 0.1
parameters = np.array([mu1, sig1, mu2, sig2])

niter = 10000

results = np.zeros([niter, 4])
results[1,:] = parameters

for iteration in np.arange(2,niter):
    candidate = parameters + np.random.normal(0,0.5,4)
    ratio = posterior(candidate)/posterior(parameters)
    if np.random.uniform() < ratio:
        parameters = candidate
    results[iteration,:] = parameters

#burn-in
results = results[499:niter-1,:]

mu1 = results[:,1]
mu2 = results[:,3]

d = (mu1 - mu2)
p_value = np.mean(mu1 < mu2)

plt.figure()
sns.distplot(d)
plt.title(p_value)


Out[217]:
<matplotlib.text.Text at 0x7f4fbd55e518>

In [ ]:


In [ ]: