Rocketeer Tutorial

Source code notebook compat Author Update time

Overview

This demo shows how to get started with Rocketeer.jl.

Setup

First, we load the package in the usual manner with using

using Rocketeer

Lets also declare a file name for saving the Rocket kernels along with some other script variables

# Save file name
filepath = "my_rocket"
# Rocket and data hyper parameters
input_length = 20
n_kernels = 200
200

Create a RocketModule

The hyperparameters of a RocketModule are the input_length of the features and the n_kernels number of kernels that we want to generate. To create a RocketModule, we have two constructors: one where we specify these two parameters, and one where we use the default values. Lets try out both:

# Create a default rocket module
my_rocket = RocketModule()

# Specify the hyperparameters
my_specific_rocket = RocketModule(input_length, n_kernels)
RocketModule(input_length=20, n_kernels=200)

We can save the Rocket kernels for later use:

# Save the module to the filepath
save_rocket(my_specific_rocket, filepath)

and we can load them back up into a new object:

# Load the rocket module
my_new_rocket = load_rocket(filepath)
RocketModule(input_length=20, n_kernels=200)

We can see here that the we got back the same RocketModule as the one we created in my_specific_rocket.

Extract Kernel Features

Lets generate some random raw input data for applying the kernels to:

X = rand(input_length)
20-element Vector{Float64}:
 0.12434182469766764
 0.7602932616557552
 0.822574010946166
 0.11593479743925894
 0.9937183293270065
 0.12851719383006532
 0.2527975304142407
 0.6120606755275079
 0.2628723705620196
 0.14280624707644973
 0.4751973786607706
 0.058864842018950925
 0.853929035466102
 0.9826182516227883
 0.6276786450363648
 0.24584033794828897
 0.40989717902853084
 0.258644669309786
 0.09041247414381559
 0.875414250798779

and apply the kernels on that data to extract a set of features:

kernel_features = apply_kernels(my_new_rocket, X)
200×2 Matrix{Float64}:
 0.15        1.25335
 0.0        -0.52593
 0.25        0.130908
 0.8         2.41262
 1.05        1.30741
 0.0        -0.237986
 0.0        -0.207206
 0.5         2.06233
 0.6         0.363042
 0.2         0.0333271
 0.0833333   0.439795
 0.45        0.413649
 0.0        -0.853612
 1.05        1.98971
 0.6         0.649258
 0.95        1.05367
 0.2         1.0535
 0.8         2.11912
 0.45        1.31281
 0.0        -0.207091
 0.85        5.03581
 0.25        0.120874
 0.0        -0.703271
 1.05        2.07818
 0.15        0.200497
 0.0        -0.559371
 0.4         0.807219
 0.4         0.406076
 0.0        -0.813158
 0.85        1.86769
 1.05        2.74302
 0.9         2.44447
 1.05        0.687402
 0.0        -0.990375
 1.05        2.99422
 1.0         1.65538
 0.0        -0.162145
 1.05        3.83279
 0.4         0.385992
 0.0        -0.0768463
 0.7         1.34187
 1.05        3.05184
 0.4         0.791457
 0.857143    2.04211
 0.0        -0.90891
 1.05        0.25483
 0.65        3.13249
 0.0        -0.545221
 1.05        0.474503
 1.05        0.86477
 0.25        0.366097
 0.5         3.86128
 0.0        -0.225314
 0.25        0.627953
 0.6         0.709539
 0.25        1.1428
 1.05        1.806
 0.6         0.907538
 1.05        0.916343
 1.05        4.24892
 0.5         1.62414
 0.7         4.49993
 1.05        0.818446
 1.05        1.9807
 0.65        0.344331
 1.05        3.65025
 0.95        4.2258
 0.4         0.965149
 0.785714    1.77281
 0.0        -0.0977228
 0.7         0.633598
 1.05        2.23104
 1.05        1.38587
 1.05        3.96268
 0.85        2.73696
 0.15        0.030514
 1.05        1.53767
 0.0        -0.829977
 0.0        -0.834894
 0.65        1.52394
 1.05        4.55427
 0.8         0.848512
 1.05        5.26601
 0.2         0.393259
 0.1         0.0267215
 0.0        -0.15405
 1.05        1.30801
 0.0        -0.257153
 0.2         0.226657
 0.0        -0.911402
 0.4         0.216755
 0.0        -0.151465
 1.05        4.84627
 0.0833333   0.367614
 0.95        3.16426
 0.95        0.457274
 1.05        2.08251
 0.0        -0.0772067
 0.5         0.229452
 0.4         0.513853
 0.9         4.2515
 1.05        3.87938
 0.15        0.194433
 0.15        0.643725
 0.65        1.62298
 0.2         0.378186
 1.05        1.53139
 0.95        2.05254
 0.15        0.319367
 1.05        0.075195
 0.0        -0.938327
 0.0        -0.0073278
 0.0        -0.530294
 0.0        -0.112489
 1.05        0.250802
 0.65        1.56063
 0.0        -0.40611
 0.9         7.08408
 0.15        0.377173
 1.05        5.17291
 0.45        1.04258
 0.8         0.749918
 0.2         0.297173
 0.857143    1.47996
 0.166667    0.258197
 1.05        1.9468
 0.0        -0.913138
 1.05        2.44988
 1.05        3.25076
 0.0        -0.931017
 0.1         0.0806664
 1.05        0.902645
 0.0        -0.146966
 1.05        3.20428
 1.07143     1.87108
 1.05        2.01073
 1.05        4.50918
 1.05        2.57992
 1.05        4.52836
 1.05        0.669032
 0.0        -0.0818428
 0.0        -0.773809
 0.4         0.94311
 1.05        1.95596
 1.05        5.94368
 1.05        2.25379
 0.9         1.90109
 0.95        9.09906
 0.0        -0.179648
 1.05        2.66059
 1.05        4.34553
 0.9         1.77159
 0.714286    1.94304
 0.0        -0.178628
 1.05        2.66725
 0.35        0.570523
 0.142857    0.216527
 1.05        4.13362
 0.0        -0.0321493
 0.2         0.181057
 0.0        -0.237033
 1.05        1.40804
 0.6         0.710142
 1.05        2.45068
 0.2         0.723823
 0.0        -0.67692
 0.8         0.775758
 0.4         0.237613
 1.05        1.96001
 0.7         0.735381
 0.1         0.00779609
 0.0        -0.0942841
 0.0        -0.128619
 0.2         0.388937
 1.05        3.21466
 0.4         0.588308
 0.4         0.705247
 0.0        -0.831161
 0.1         0.113441
 0.2         0.214164
 1.05        2.58219
 0.45        1.20596
 1.05        2.91522
 0.0        -0.219507
 0.35        0.35944
 1.05        2.96868
 1.05        2.43669
 0.0        -0.0394505
 0.4         0.803099
 0.333333    1.34904
 1.05        0.583822
 1.05        0.336799
 0.95        5.90629
 0.0        -0.750868
 0.4         1.14892
 0.428571    2.07694
 0.65        0.694127
 0.9         3.05876
 0.65        0.512423
 0.2         0.448929

And voila, it's as easy as that! We have some features to use for analysis or otherwise some good old time series classification with other machine learning models.

Just to make sure to be thorough, we sill end this script by deleting the generated rocket save file.

# Delete the saved file
rm(filepath)

This page was generated using DemoCards.jl and Literate.jl.