Skip to content

Commit 2f29f96

Browse files
committed
restructured and addition of ROCKET and MINIROCKET
1 parent b9e650e commit 2f29f96

32 files changed

+470
-79
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Getting Started
5353
source/NSW_Demo/NSWClassifier_Demo.rst
5454
source/kNNClassifier_Demo/kNNClassifier_Demo.rst
5555
source/MACFAC_Demo/MACFAC_Demo.rst
56+
source/MINIROCKET_Demo/MINIROCKET_Demo.rst
5657

5758

5859
Models

docs/source/AnnoyClassifier_Demo/AnnoyClassifier_Demo.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Importing Packages
66

77
.. code:: ipython3
88
9-
from mlots import AnnoyClassifier
9+
from mlots.models import AnnoyClassifier
1010
from sklearn.model_selection import GridSearchCV
1111
from scipy.io import arff
1212
import matplotlib.pyplot as plt

docs/source/MACFAC_Demo/MACFAC_Demo.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Importing Packages
66

77
.. code:: ipython3
88
9-
from mlots import kNNClassifier
9+
from mlots.models import kNNClassifier
1010
from sklearn.model_selection import GridSearchCV
1111
from scipy.io import arff
1212
import matplotlib.pyplot as plt
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
MINIROCKET
2+
==========
3+
4+
Dempster et al. https://arxiv.org/abs/2012.08791
5+
6+
Importing Packages
7+
------------------
8+
9+
.. code:: ipython3
10+
11+
from mlots.models import RidgeClassifierCV
12+
from mlots.transformation import MINIROCKET
13+
from scipy.io import arff
14+
import numpy as np
15+
import warnings
16+
warnings.filterwarnings("ignore")
17+
from sklearn.metrics import accuracy_score
18+
19+
Loading Data
20+
------------
21+
22+
| Here we are loading the ``SmoothSubspace`` dataset.
23+
| The datasets are in two ``.arff`` files with pre-defined train and
24+
test splits.
25+
| The following code reads the two files stores the ``X`` (time-series
26+
data) and ``y`` (labels), into their specific train and test sets.
27+
\**\*
28+
29+
.. code:: ipython3
30+
31+
name = "SmoothSubspace"
32+
33+
dataset = arff.loadarff(f'input/{name}/{name}_TRAIN.arff'.format(name=name))[0]
34+
X_train = np.array(dataset.tolist(), dtype=np.float32)
35+
y_train = X_train[: , -1]
36+
X_train = X_train[:, :-1]
37+
38+
dataset = arff.loadarff(f'input/{name}/{name}_TEST.arff'.format(name=name))[0]
39+
X_test = np.array(dataset.tolist(), dtype=np.float32)
40+
y_test = X_test[: , -1]
41+
X_test = X_test[:, :-1]
42+
43+
#Converting target from bytes to integer
44+
y_train = [int.from_bytes(el, "little") for el in y_train]
45+
y_test = [int.from_bytes(el, "little") for el in y_test]
46+
X_train.shape, X_test.shape
47+
48+
49+
50+
51+
.. parsed-literal::
52+
53+
((150, 15), (150, 15))
54+
55+
56+
57+
===== =========== =========
58+
Set Sample size TS length
59+
===== =========== =========
60+
Train 150 15
61+
Test 150 15
62+
===== =========== =========
63+
64+
Transforming Data using ``MINIROCKET``
65+
--------------------------------------
66+
67+
.. code:: ipython3
68+
69+
print("Shape of X_train and X_test before transformation: ",X_train.shape,", ",X_test.shape)
70+
71+
72+
.. parsed-literal::
73+
74+
Shape of X_train and X_test before transformation: (150, 15) , (150, 15)
75+
76+
77+
.. code:: ipython3
78+
79+
minirocket = MINIROCKET()
80+
minirocket.fit(X_train)
81+
X_train = minirocket.transform(X_train)
82+
X_test = minirocket.transform(X_test)
83+
84+
.. code:: ipython3
85+
86+
print("Shape of X_train and X_test before transformation: ",X_train.shape,", ",X_test.shape)
87+
88+
89+
.. parsed-literal::
90+
91+
Shape of X_train and X_test before transformation: (150, 9996) , (150, 9996)
92+
93+
94+
Classification
95+
--------------
96+
97+
| We can employ ``RidgeClassifierCV`` as our linear model for the
98+
classification task.
99+
| \**\*
100+
101+
.. code:: ipython3
102+
103+
model = RidgeClassifierCV(alphas=np.logspace(-3, 3, 10), normalize=True)
104+
model = model.fit(X_train, y_train)
105+
106+
.. code:: ipython3
107+
108+
acc = model.score(X_test, y_test)
109+
print(f"Model accuracy: {acc:.2f}%")
110+
111+
112+
.. parsed-literal::
113+
114+
Model accuracy: 0.95%
115+

docs/source/NSW_Demo/NSWClassifier_Demo.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Importing Packages
66

77
.. code:: ipython3
88
9-
from mlots import NSWClassifier
9+
from mlots.models import NSWClassifier
1010
from sklearn.model_selection import GridSearchCV
1111
from scipy.io import arff
1212
import matplotlib.pyplot as plt

docs/source/kNNClassifier_Demo/kNNClassifier_Demo.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Importing Packages
66

77
.. code:: ipython3
88
9-
from mlots import kNNClassifier
9+
from mlots.models import kNNClassifier
1010
from sklearn.model_selection import GridSearchCV
1111
from scipy.io import arff
1212
import matplotlib.pyplot as plt

docs/source/mlots.models.rst

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,10 @@
11
mlots.models package
22
====================
33

4-
mlots.models.annoy module
5-
-------------------------
4+
Module contents
5+
---------------
66

7-
.. automodule:: mlots.models.annoy
7+
.. automodule:: mlots.models
88
:members:
99
:undoc-members:
1010
:show-inheritance:
11-
12-
mlots.models.hnsw module
13-
------------------------
14-
15-
.. automodule:: mlots.models.hnsw
16-
:members:
17-
:undoc-members:
18-
:show-inheritance:
19-
20-
mlots.models.knn module
21-
-----------------------
22-
23-
.. automodule:: mlots.models.knn
24-
:members:
25-
:undoc-members:
26-
:show-inheritance:
27-
28-
mlots.models.nsw module
29-
-----------------------
30-
31-
.. automodule:: mlots.models.nsw
32-
:members:
33-
:undoc-members:
34-
:show-inheritance:
35-

docs/source/mlots.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,21 @@ Subpackages
1010
mlots.models
1111
mlots.transformation
1212

13+
Submodules
14+
----------
15+
1316
mlots.utilities module
1417
----------------------
1518

1619
.. automodule:: mlots.utilities
1720
:members:
1821
:undoc-members:
1922
:show-inheritance:
23+
24+
Module contents
25+
---------------
26+
27+
.. automodule:: mlots
28+
:members:
29+
:undoc-members:
30+
:show-inheritance:

docs/source/mlots.transformation.rst

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
mlots.transformation package
22
============================
33

4-
mlots.transformation.MINIROCKET module
5-
--------------------------------------
4+
Module contents
5+
---------------
66

7-
.. automodule:: mlots.transformation.MINIROCKET
8-
:members:
9-
:undoc-members:
10-
:show-inheritance:
11-
12-
mlots.transformation.ROCKET module
13-
----------------------------------
14-
15-
.. automodule:: mlots.transformation.ROCKET
7+
.. automodule:: mlots.transformation
168
:members:
179
:undoc-members:
1810
:show-inheritance:

mlots/__init__.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
from mlots.models.nsw import NSWClassifier
2-
from mlots.models.annoy import AnnoyClassifier
3-
from mlots.models.hnsw import HNSWClassifier
4-
from mlots.models.knn import kNNClassifier
5-
from mlots.models.knn import kNNClassifier_CustomDist
6-
from mlots.transformation.rocket import ROCKET
7-
from mlots.transformation.minirocket import MINIROCKET
8-
from sklearn.linear_model import RidgeClassifier, RidgeClassifierCV
9-
from mlots.utilities import from_pandas_dataframe
10-
11-
__all__ = [
12-
"AnnoyClassifier", "HNSWClassifier", "kNNClassifier",
13-
"kNNClassifier_CustomDist", "NSWClassifier", "RidgeClassifier", "RidgeClassifierCV",
14-
"ROCKET", "MINIROCKET", "from_pandas_dataframe"]
1+
from .utilities import from_pandas_dataframe

mlots/models/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from .annoy import AnnoyClassifier
2-
from .hnsw import HNSWClassifier
3-
from .knn import kNNClassifier
4-
from .knn import kNNClassifier_CustomDist
5-
from .nsw import NSWClassifier
1+
from mlots.models._annoy import AnnoyClassifier
2+
from mlots.models._hnsw import HNSWClassifier
3+
from mlots.models._knn import kNNClassifier, kNNClassifier_CustomDist
4+
from mlots.models._nsw import NSWClassifier
65
from sklearn.linear_model import RidgeClassifier, RidgeClassifierCV
76

87
__all__ = [
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mlots/setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
3+
4+
def configuration(parent_package='', top_path=None):
5+
from numpy.distutils.misc_util import Configuration
6+
libraries = []
7+
if os.name == 'posix':
8+
libraries.append('m')
9+
10+
config = Configuration('mlots', parent_package, top_path)
11+
config.add_subpackage('models')
12+
config.add_subpackage('transformation')
13+
14+
return config
15+
16+
17+
if __name__ == '__main__':
18+
from numpy.distutils.core import setup
19+
setup(**configuration(top_path='').todict())

mlots/transformation/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .minirocket import MINIROCKET
2-
from .rocket import ROCKET
1+
from ._minirocket import MINIROCKET
2+
from ._rocket import ROCKET
33

44
__all__ = ["MINIROCKET", "ROCKET"]
File renamed without changes.

notebooks/AnnoyClassifier_Demo.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"outputs": [],
2727
"source": [
28-
"from mlots import AnnoyClassifier\n",
28+
"from mlots.models import AnnoyClassifier\n",
2929
"from sklearn.model_selection import GridSearchCV\n",
3030
"from scipy.io import arff\n",
3131
"import matplotlib.pyplot as plt\n",

notebooks/MACFAC_Demo.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"outputs": [],
2727
"source": [
28-
"from mlots import kNNClassifier\n",
28+
"from mlots.models import kNNClassifier\n",
2929
"from sklearn.model_selection import GridSearchCV\n",
3030
"from scipy.io import arff\n",
3131
"import matplotlib.pyplot as plt\n",

0 commit comments

Comments
 (0)