Rocketeer Tutorial
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.18909139257355534
0.06135472165786737
0.08816286119000771
0.3280467624448987
0.39094298573634656
0.8351636797518155
0.6511559456506343
0.060024524642967814
0.30643374092244924
0.251843987213918
0.6250114524893678
0.42215746398531384
0.6259445821035823
0.7133807239942422
0.27610503331403713
0.5891077380245436
0.5905410468689964
0.07874178868079096
0.8045376388627108
0.6494956803084848
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.35 0.515498
0.3 0.250155
0.0 -0.204845
0.1 0.0931433
1.05 1.14269
0.0 -0.552535
1.05 4.21011
0.0 -0.290131
0.65 0.919066
0.0 -0.0684495
1.0 1.62334
1.05 6.06472
0.5 0.23973
0.75 1.36426
1.05 4.20197
0.0 -0.658587
1.05 2.58693
0.75 2.79041
0.0 -0.684789
0.75 2.39867
0.0 -0.573916
1.05 0.0465936
1.08333 2.69516
0.0 -0.961451
0.4 0.245169
0.85 1.70116
0.0 -0.237323
0.85 2.3354
1.05 0.971454
0.85 1.45479
0.0 -0.814057
0.0 -0.601967
0.75 1.1452
0.0 -0.274691
0.0 -0.855613
1.05 0.63512
1.05 0.747095
0.15 0.102125
0.0 -0.768877
0.35 0.611933
0.3 0.237436
0.65 0.598654
1.05 1.18611
1.05 6.41996
0.0 -0.160171
1.05 6.09956
0.65 0.842416
0.0 -0.826683
0.35 0.984084
0.3 0.681515
0.0 -0.387016
0.75 1.21853
0.0 -0.181663
0.0 -0.168521
1.05 6.28214
1.05 1.24815
1.05 3.04207
0.0 -0.754497
0.3 0.278533
0.0 -0.593796
0.1 0.529032
0.05 0.0626882
1.05 2.8307
0.5 0.676929
1.05 0.386135
0.0 -0.153965
0.3 0.697507
0.5 1.28377
0.0 -0.446055
1.05 4.91426
0.55 0.590089
0.928571 1.94492
0.0 -0.799515
0.666667 1.68379
1.05 0.700361
0.1 0.26401
0.85 5.9028
1.05 1.99989
0.0 -0.29904
0.7 0.87865
0.0 -0.0831186
0.0 -0.223181
1.08333 4.45195
1.0 1.89912
0.0 -0.844084
1.05 0.703015
1.05 4.56902
0.333333 0.620535
0.3 0.518592
0.0833333 0.10732
0.95 3.08622
0.7 1.07453
0.75 7.10927
0.3 0.320628
0.75 1.81968
1.05 3.88228
0.0 -0.713384
1.05 2.28887
0.75 2.42163
1.05 0.339999
0.05 0.204118
0.75 1.6436
0.357143 0.237961
0.0 -0.538043
0.0 -0.673538
0.0 -0.530888
1.05 0.874505
1.08333 1.09553
1.05 0.80268
0.65 0.604427
1.05 0.846429
1.05 2.53485
0.0 -0.930181
0.1 0.429303
0.0 -0.655023
0.0 -0.152484
0.0 -0.425634
0.0 -0.695221
0.285714 0.758882
1.05 2.66808
0.2 0.887933
0.0 -0.0392233
0.9 1.61355
0.85 2.44055
1.05 0.220488
0.75 3.49011
0.2 0.440301
0.5 1.68996
1.05 0.389279
1.05 3.96592
0.0 -0.913989
0.0 -0.753219
1.05 0.766184
0.4 0.714887
0.65 0.829358
1.05 3.10502
1.05 0.685923
1.07143 2.63065
0.75 2.21124
0.3 0.522606
1.05 5.37187
0.55 0.588598
0.55 0.240313
1.05 4.14425
0.1 0.00411793
1.05 3.33224
0.0 -0.555294
1.05 2.56084
1.05 3.80694
0.1 0.270881
0.3 0.581311
1.05 0.747699
0.0 -0.470895
0.0 -0.34215
0.95 0.0832154
0.0 -0.213339
0.0 -0.638656
0.0 -0.600981
0.0 -0.50869
0.4 0.68939
0.916667 1.31222
0.05 0.17251
0.0 -0.510878
0.35 0.321564
0.4 0.254684
1.05 1.01812
0.0 -0.402464
0.0 -0.00380549
1.05 5.56001
0.0 -0.1613
0.85 1.51258
0.3 0.112514
0.5 0.359364
0.0 -0.136815
0.3 0.567435
0.6 0.6966
1.05 1.93122
0.0 -0.506394
0.3 0.651845
0.95 6.71369
0.55 1.87471
1.05 0.627351
1.05 0.750387
0.65 0.668074
0.6 1.30119
1.05 1.7616
1.05 6.04586
0.0 -0.34443
0.3 0.761412
0.0 -0.182679
0.75 3.13757
0.85 2.29973
1.05 3.79605
0.0 -0.329243
0.7 2.15282
0.75 1.74584
0.75 4.48213
0.4 0.72115
1.05 3.98552
0.0 -0.0730687
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.