Skip to content
Snippets Groups Projects
Commit e9e9c186 authored by GILSON Matthieu's avatar GILSON Matthieu
Browse files

Upload New File

parent 2649c616
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:7f795133 tags:
``` python
import numpy as np
from scipy.io import arff
from sktime.datasets import load_from_arff_to_dataframe, load_basic_motions
from sktime.transformations.panel.rocket import Rocket
from sklearn.linear_model import RidgeClassifierCV
import matplotlib.pyplot as plt
```
%% Cell type:code id:04f19b56 tags:
``` python
# load time series and labels
X_train, y_train = load_from_arff_to_dataframe('FordA/FordA_TRAIN.arff')
X_test, y_test = load_from_arff_to_dataframe('FordA/FordA_TEST.arff')
#X, y = load_from_arff_to_dataframe('Ford/FordA_TRAIN.arff')
```
%% Cell type:code id:f9a0b4f5 tags:
``` python
plt.plot(X_train.iloc[0,0])
```
%% Output
[<matplotlib.lines.Line2D at 0x7febcab82d40>]
%% Cell type:code id:b23b1bbb tags:
``` python
# train rocket
rocket = Rocket() # by default, ROCKET uses 10,000 kernels
rocket.fit(X_train)
X_train_transform = rocket.transform(X_train)
```
%% Cell type:code id:586f11ee tags:
``` python
classifier = RidgeClassifierCV(alphas=np.logspace(-3, 3, 10))
classifier.fit(X_train_transform, y_train)
```
%% Output
RidgeClassifierCV(alphas=array([1.00000000e-03, 4.64158883e-03, 2.15443469e-02, 1.00000000e-01,
4.64158883e-01, 2.15443469e+00, 1.00000000e+01, 4.64158883e+01,
2.15443469e+02, 1.00000000e+03]))
%% Cell type:code id:b609e648 tags:
``` python
# load test data
X_test_transform = rocket.transform(X_test)
```
%% Cell type:code id:3872292c tags:
``` python
classifier.score(X_test_transform, y_test)
```
%% Output
0.9083333333333333
%% Cell type:code id:958c012c tags:
``` python
np.unique(y_test)
```
%% Output
array(['-1', '1'], dtype='<U2')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment