<jupyter_start><jupyter_text>Workout DetectionUse GBM to classify all points in a file. Run a sliding window to identify the "best fitting" window as a workout.<jupyter_code># Load data
#imu_file = IMU_DATA_DIR / '11L_2020-08-13T09.48.23.554_E8E376103A59_Accelerometer.csv'
imu_file = IMU_DATA_DIR / '8L_2020-10-17T09.41.54.354_E1051277C793_Accelerometer.csv'
imu_data = load_imu_data(imu_file)

# Load models
boot_model = load_model(Activity.Boot)
pole_model = load_model(Activity.Pole)

# Clean data
imu_data = clean_imu_data(imu_data)

# Identify workouts
boot_workouts = get_activity_workouts(imu_data, Activity.Boot)
pole_workouts = get_activity_workouts(imu_data, Activity.Pole)

print(boot_workouts)
print(pole_workouts)

# Plot
def plot_helper(plot_id, plot):
    plot.plot(imu_data[:, ImuCol.TIME], imu_data[:, ImuCol.XACCEL], label = "x-axis acceleration")
    
    # plot boot workouts
    plot.title.set_text('Boot')
    for boot in boot_workouts:
        plot.axvspan(imu_data[boot.start_row, ImuCol.TIME], imu_data[boot.end_row, ImuCol.TIME], color='orange', alpha=0.5)

    # plot pole workouts
    plot.title.set_text('Pole')
    for pole in pole_workouts:
        plot.axvspan(imu_data[pole.start_row, ImuCol.TIME], imu_data[pole.end_row, ImuCol.TIME], color='yellow', alpha=0.5)
        
    plot.legend()
multiplot(1, plot_helper)
# Combine into one
all_workouts: List[Window] = get_all_workouts(imu_data)

# Plot
def plot_helper(plot_id, plot):
    plot.plot(imu_data[:, ImuCol.TIME], imu_data[:, ImuCol.XACCEL], label = "x-axis acceleration")

    for workout in all_workouts:
        plot.axvspan(imu_data[workout.start_row, ImuCol.TIME], imu_data[workout.end_row, ImuCol.TIME], color='yellow', alpha=0.5)
        
    plot.legend()
multiplot(1, plot_helper)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11823204419889503, 'fraction_numerical': 0.03535911602209945, 'mean_word_length': 5.097643097643098, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '444323', 'license': 'MIT', 'n_tokens_mistral': 752, 'n_tokens_neox': 704, 'n_words': 125, 'path': 'model/notebooks/archive/2B-workout-detection.ipynb', 'repo_name': 'MultiW/nimble-xc', 'size': '1810'}