Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] New transformation based pipeline classifiers #1721

Merged
merged 299 commits into from
Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
299 commits
Select commit Hold shift + click to select a range
1265493
typo
fkiraly Aug 30, 2021
f6cf85d
fitted logic in panel case
fkiraly Aug 30, 2021
f1891bc
boxcox refactored as example
fkiraly Aug 30, 2021
0549263
linting
fkiraly Aug 30, 2021
248b6e5
linting
fkiraly Aug 30, 2021
c17b714
added new tags
fkiraly Aug 31, 2021
7dc0812
added checks for object dtype in Series types
fkiraly Aug 31, 2021
b62408b
fixing if/else logic path 2 and 3
fkiraly Aug 31, 2021
c698da7
added nested_univ to df-list conversion
fkiraly Aug 31, 2021
cd1c882
and back
fkiraly Aug 31, 2021
9f658f7
changed fit-in-transform default to True
fkiraly Aug 31, 2021
37f3eb0
linting
fkiraly Aug 31, 2021
de490e8
linting
fkiraly Aug 31, 2021
f0ee949
improved informativity of estimator tags error message
fkiraly Aug 31, 2021
7181e6b
added more tags
fkiraly Aug 31, 2021
f03d6b2
fixed missing tag in boxcox refactor
fkiraly Aug 31, 2021
e1a04da
random interval transformer
MatthewMiddlehurst Aug 31, 2021
80fc514
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Aug 31, 2021
cc924eb
updated fit check with check_is_fitted
fkiraly Aug 31, 2021
459127d
removed superfluous comments
fkiraly Aug 31, 2021
674e674
Merge branch 'main' into transformers-refactor
fkiraly Aug 31, 2021
6340dd3
remove return_pred_int errors
fkiraly Aug 31, 2021
f88190d
Merge branch 'forecasters-fix-bad-treatment' into transformers-refactor
fkiraly Aug 31, 2021
4c6eabd
corrected data frame check
fkiraly Aug 31, 2021
03ddf51
added inner types for panel trafos
fkiraly Aug 31, 2021
43e8b2f
output conversion for Series/Primitives
fkiraly Sep 1, 2021
2d21de3
signature fixes
fkiraly Sep 1, 2021
b656536
linting signatures
fkiraly Sep 1, 2021
2eca7e3
linting
fkiraly Sep 1, 2021
3bbc53e
linting signatures
fkiraly Sep 1, 2021
d6573cb
stc transform saving
MatthewMiddlehurst Sep 1, 2021
3d4b524
signatures update
fkiraly Sep 1, 2021
3a991df
typo
fkiraly Sep 1, 2021
4396336
Merge pull request #2 from MatthewMiddlehurst/stc-mtsc-merge
a-pasos-ruiz Sep 1, 2021
d6ca6aa
coerce to pandas
MatthewMiddlehurst Sep 1, 2021
e463b2a
Merge branch 'mstc' of https://github.com/a-pasos-ruiz/sktime into mstc
MatthewMiddlehurst Sep 1, 2021
8ae5ff4
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Sep 1, 2021
aea1dbe
japanese vowels test
MatthewMiddlehurst Sep 1, 2021
dd90643
Fixing error on parameters for experiment
Sep 1, 2021
651f49e
Merge branch 'mstc' of https://github.com/a-pasos-ruiz/sktime into mstc
MatthewMiddlehurst Sep 1, 2021
e1d9bfd
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Sep 1, 2021
81951cd
relaxing numpy series mtype
fkiraly Sep 1, 2021
06b82f1
new rotation forest
MatthewMiddlehurst Sep 4, 2021
f54c689
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Sep 4, 2021
c13ce81
remove useless atts
MatthewMiddlehurst Sep 4, 2021
38a3cc0
rotf contracting, train estimate and comments
MatthewMiddlehurst Sep 5, 2021
a21b2b1
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Sep 5, 2021
3ea7aeb
doc fix
MatthewMiddlehurst Sep 5, 2021
9a0a588
rotf example fix
MatthewMiddlehurst Sep 5, 2021
8cd402c
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Sep 6, 2021
ad4eaa8
Merge branch 'main' into rotation_forest
MatthewMiddlehurst Sep 7, 2021
514f90d
stc comments p1
MatthewMiddlehurst Sep 7, 2021
3002ec1
Merge branch 'rotation_forest' of https://github.com/alan-turing-inst…
MatthewMiddlehurst Sep 7, 2021
9f8ebc1
include rotation forest
MatthewMiddlehurst Sep 7, 2021
b52140c
hc refactor p1
MatthewMiddlehurst Sep 7, 2021
4ed8f1a
hc1 test fix
MatthewMiddlehurst Sep 7, 2021
88c18d4
stc rotf fix
MatthewMiddlehurst Sep 7, 2021
501dc54
Merge branch 'mstc' of https://github.com/a-pasos-ruiz/sktime into hc2
MatthewMiddlehurst Sep 7, 2021
23a2264
cboss train probs
MatthewMiddlehurst Sep 7, 2021
ff0656f
use transformed data in stc
MatthewMiddlehurst Sep 7, 2021
5999d76
Merge branch 'mstc' of https://github.com/a-pasos-ruiz/sktime into hc2
MatthewMiddlehurst Sep 7, 2021
3008d6b
hc1 test outline
MatthewMiddlehurst Sep 8, 2021
b5b2e2d
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Sep 8, 2021
62a9521
config change
MatthewMiddlehurst Sep 8, 2021
de66422
Merge branch 'mstc' of https://github.com/a-pasos-ruiz/sktime into hc2
MatthewMiddlehurst Sep 8, 2021
8dd0df4
hc2.0
MatthewMiddlehurst Sep 8, 2021
16ec1ea
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Sep 17, 2021
29e938c
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Sep 20, 2021
a805c94
Merge branch 'mstc' of https://github.com/a-pasos-ruiz/sktime into hc2
MatthewMiddlehurst Sep 20, 2021
9b0666b
rotf seed fix
MatthewMiddlehurst Sep 20, 2021
df4fbf5
Merge branch 'mstc' of https://github.com/a-pasos-ruiz/sktime into hc2
MatthewMiddlehurst Sep 20, 2021
3e994c7
st
MatthewMiddlehurst Oct 3, 2021
5833f02
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Oct 3, 2021
4e2dc9c
st fix
MatthewMiddlehurst Oct 4, 2021
52ac3d3
stc and st tests and finishing touches
MatthewMiddlehurst Oct 5, 2021
a8df7d8
remove mstc dev
MatthewMiddlehurst Oct 5, 2021
5d5e33c
more st fixing
MatthewMiddlehurst Oct 5, 2021
af8a507
import code quality
MatthewMiddlehurst Oct 5, 2021
30e071b
rotf code quality
MatthewMiddlehurst Oct 5, 2021
10625ac
hc1 test code quality
MatthewMiddlehurst Oct 5, 2021
00e9891
Merge branch 'hc2-stc' of https://github.com/alan-turing-institute/sk…
MatthewMiddlehurst Oct 5, 2021
112ee3b
hc2 tests and contracting
MatthewMiddlehurst Oct 5, 2021
17e1753
hc2 stc default
MatthewMiddlehurst Oct 5, 2021
9221a45
hc2 stc default (fix)
MatthewMiddlehurst Oct 6, 2021
0b0620b
st rename and test fixes
MatthewMiddlehurst Oct 6, 2021
b553c54
Merge branch 'hc2-stc' of https://github.com/alan-turing-institute/sk…
MatthewMiddlehurst Oct 6, 2021
a2c58d8
hc2 train estimate fix
MatthewMiddlehurst Oct 6, 2021
12a5161
stc test fixes and codeowners
MatthewMiddlehurst Oct 6, 2021
d30037c
Merge branch 'hc2-stc' of https://github.com/alan-turing-institute/sk…
MatthewMiddlehurst Oct 6, 2021
ec2350e
rotf fix
MatthewMiddlehurst Oct 7, 2021
88856ab
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Oct 7, 2021
cc1305d
remove identical shapelets at end and transform n_jobs
MatthewMiddlehurst Oct 8, 2021
2634b64
Merge branch 'hc2-stc' of https://github.com/alan-turing-institute/sk…
MatthewMiddlehurst Oct 8, 2021
ac36c69
rounding ST ig to prevent differences between OS
MatthewMiddlehurst Oct 8, 2021
5a6d8a3
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Oct 8, 2021
a328706
rotf test fix
MatthewMiddlehurst Oct 8, 2021
0671f5c
Merge branch 'hc2-stc' of https://github.com/alan-turing-institute/sk…
MatthewMiddlehurst Oct 8, 2021
ecbcce0
st and stc docs
MatthewMiddlehurst Oct 8, 2021
f8551fd
Merge branch 'hc2-stc' of https://github.com/alan-turing-institute/sk…
MatthewMiddlehurst Oct 8, 2021
8c041c8
hc1 and hc2 test fixes
MatthewMiddlehurst Oct 9, 2021
7866e47
hc1 and hc2 examples fix
MatthewMiddlehurst Oct 9, 2021
befdf7f
higher max shapelets for tests
MatthewMiddlehurst Oct 9, 2021
3240f1a
more mv cases in tests
MatthewMiddlehurst Oct 9, 2021
911163c
hc test parameters
MatthewMiddlehurst Oct 9, 2021
e54442c
hc test parameters 2
MatthewMiddlehurst Oct 9, 2021
97f196e
hc test parameters 3
MatthewMiddlehurst Oct 9, 2021
9eacc5d
hc test parameters 4
MatthewMiddlehurst Oct 9, 2021
971249d
wrong probas
MatthewMiddlehurst Oct 9, 2021
22971cb
hopefully done
MatthewMiddlehurst Oct 9, 2021
2ec7dc9
dumb linalg packages ruin my week by causing differences between os
MatthewMiddlehurst Oct 9, 2021
2c493ea
experiments update and a couple of getattr bugfixes
MatthewMiddlehurst Oct 11, 2021
4c0534c
contrib experiments update
MatthewMiddlehurst Oct 11, 2021
a044ea9
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Oct 12, 2021
f5edc7c
set classifier hc2
MatthewMiddlehurst Oct 12, 2021
89265b2
Merge branch 'experiments_update' of https://github.com/alan-turing-i…
MatthewMiddlehurst Oct 12, 2021
10dad1d
Merge branch 'experiments_update' of https://github.com/alan-turing-i…
MatthewMiddlehurst Oct 12, 2021
52ac6a8
Merge branch 'hc2' of https://github.com/alan-turing-institute/sktime…
MatthewMiddlehurst Oct 12, 2021
f01b032
base
TonyBagnall Oct 13, 2021
3c14b91
enforce univariate in base class
TonyBagnall Oct 13, 2021
498b8dd
remove unnecessary classifier tags
TonyBagnall Oct 13, 2021
8b72f4d
predict and predict_proba
TonyBagnall Oct 13, 2021
b79f65b
tweaks to classifier base class
TonyBagnall Oct 13, 2021
9d36d91
formatting 1
TonyBagnall Oct 13, 2021
4ccd2df
formatting 3
TonyBagnall Oct 13, 2021
5503c54
formatting 4
TonyBagnall Oct 13, 2021
50ca231
formatting 6?
TonyBagnall Oct 13, 2021
f7dc729
blank lines or no blank lines?
TonyBagnall Oct 13, 2021
5919fbb
remove unnecessary argument to get_tag
TonyBagnall Oct 14, 2021
4bdb457
negate tag correctly, remove unnecessary get_tag argument
TonyBagnall Oct 14, 2021
721052f
Merge branch 'classifier_base_class' of https://github.com/alan-turin…
TonyBagnall Oct 14, 2021
6accbc6
correct tag negation
TonyBagnall Oct 14, 2021
aa1ca8e
Merge branch 'main' into classifier_base_class
TonyBagnall Oct 14, 2021
5734947
Merge branch 'main' into classifier_base_class
TonyBagnall Oct 15, 2021
cee784b
Merge branch 'main' into classifier_base_class
TonyBagnall Oct 15, 2021
d408408
_predict _predict_proba
TonyBagnall Oct 16, 2021
b17f9a7
formatting 1
TonyBagnall Oct 16, 2021
57347f7
formatting 2
TonyBagnall Oct 16, 2021
49eb1d2
Merge branch 'main' into transformers-refactor
fkiraly Oct 16, 2021
9c8e2de
renamed fitted_trafos to transformers
fkiraly Oct 16, 2021
e3c3254
deprecation warning category, bump version number
fkiraly Oct 16, 2021
859d7de
linting
fkiraly Oct 16, 2021
2b04842
linting
fkiraly Oct 16, 2021
e692a99
linting
fkiraly Oct 16, 2021
4eee5fa
linting
fkiraly Oct 16, 2021
4a32639
added defensive assert
fkiraly Oct 16, 2021
ef56dce
added error message to defensive assertion
fkiraly Oct 16, 2021
79fd157
added transform-input tag in docstring
fkiraly Oct 16, 2021
8a74a04
wrong tag used, now "univariate-only"
fkiraly Oct 16, 2021
40a8090
corrected reference in ForecastingPipeline
fkiraly Oct 16, 2021
bd0f5f7
clarified mtype in docstring
fkiraly Oct 16, 2021
f1ea7ee
linting
fkiraly Oct 16, 2021
5af98a0
Merge branch 'main' into classifier_base_class
TonyBagnall Oct 16, 2021
ad6877f
fixing transformer tests to correctly refer to create_test_instance
fkiraly Oct 17, 2021
3404703
Revert "fixing transformer tests to correctly refer to create_test_in…
fkiraly Oct 17, 2021
2145be7
transformer extension template
fkiraly Oct 17, 2021
8956a0c
Merge branch 'main' into transformers-refactor
fkiraly Oct 17, 2021
21ee5fe
extension template docstrings
fkiraly Oct 17, 2021
8b29a99
HC comments an experiments fixes
MatthewMiddlehurst Oct 17, 2021
ae873a9
added link to transformer extension template in README
fkiraly Oct 17, 2021
ced95df
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Oct 17, 2021
2e1b434
Merge branch 'classifier_base_class' of https://github.com/alan-turin…
MatthewMiddlehurst Oct 18, 2021
a7a7c64
remove deprecated versions and more feature based updates
MatthewMiddlehurst Oct 19, 2021
19a8dd9
test config
MatthewMiddlehurst Oct 19, 2021
6bf65d9
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Oct 19, 2021
5db8cc7
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Oct 20, 2021
81af2a6
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Oct 23, 2021
83f9c75
Merge branch 'main' into transformers-refactor
fkiraly Oct 23, 2021
8412bb4
feature based test tolerance
MatthewMiddlehurst Oct 23, 2021
1b6bf31
clearer mtype/scitype tracking logic
fkiraly Oct 24, 2021
ee5fd62
minor update to extension template
fkiraly Oct 24, 2021
33e6143
refactored input checks
fkiraly Oct 24, 2021
0ec2a0b
Merge branch 'main' into transformers-refactor
fkiraly Oct 24, 2021
c3a8bcc
bug in check_is function fixed
fkiraly Oct 24, 2021
7a0e175
linting
fkiraly Oct 24, 2021
ec91da6
linting
fkiraly Oct 24, 2021
d8a6f21
removing mtypes with unsupported checks
fkiraly Oct 24, 2021
9b7b179
fixed typo in signature method
fkiraly Oct 24, 2021
c93d19e
signature _fit should ignore y
fkiraly Oct 24, 2021
4236f45
added missing docstring in _series_as_panel/_convert
fkiraly Oct 24, 2021
8633afc
fixed docstring
fkiraly Oct 24, 2021
0ab2d28
corrected docstring
fkiraly Oct 24, 2021
78c773e
added valueerror message and capture for dim 1 np.ndarray in series/p…
fkiraly Oct 24, 2021
1667eae
scitypes condition
fkiraly Oct 24, 2021
a264928
linting
fkiraly Oct 24, 2021
2595ef1
changed variable names in fit
fkiraly Oct 24, 2021
b7a390b
bugfix in output conversion in transform
fkiraly Oct 24, 2021
0b96f48
added comments suggested by Lovkush
fkiraly Oct 24, 2021
e8fd2d9
Merge branch 'main' into transform-classifiers
TonyBagnall Oct 26, 2021
6173c46
Merge branch 'transform-classifiers' of https://github.com/alan-turin…
MatthewMiddlehurst Oct 28, 2021
c29f45d
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Oct 28, 2021
c7c7a6c
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Nov 2, 2021
181dbfd
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Nov 3, 2021
fbf1054
remove new transform classifiers
MatthewMiddlehurst Nov 4, 2021
086de28
Merge branch 'transformers-refactor' of https://github.com/alan-turin…
MatthewMiddlehurst Nov 4, 2021
e42622f
signature and mp tests
MatthewMiddlehurst Nov 4, 2021
98bb6f6
signature example
MatthewMiddlehurst Nov 4, 2021
67aef20
Merge branch 'transform-classifiers' of https://github.com/alan-turin…
MatthewMiddlehurst Nov 4, 2021
f737d05
reintroduce new transformers/transform classifiers
MatthewMiddlehurst Nov 5, 2021
3cd3048
only mv summarycls is broken now
MatthewMiddlehurst Nov 5, 2021
8d80060
replaced fit-copy with fit-reference
fkiraly Nov 9, 2021
b382c8b
Update extension_templates/transformer.py
fkiraly Nov 9, 2021
64c886d
clarify special case
fkiraly Nov 9, 2021
9acb549
clarified
fkiraly Nov 9, 2021
228b340
clarification on output type
fkiraly Nov 9, 2021
0d7bc2d
fixed test reference
fkiraly Nov 9, 2021
b5a57cc
Merge branch 'main' into transformers-refactor
fkiraly Nov 9, 2021
b1aaeb0
replaced transform(Z) reference by X reference in test_date
fkiraly Nov 9, 2021
cb3a774
moved comments before lines
fkiraly Nov 9, 2021
61ea4f4
Merge branch 'transformers-refactor' of https://github.com/alan-turin…
fkiraly Nov 9, 2021
ecb227b
numpydoc compliance in extension template
fkiraly Nov 9, 2021
746fc10
clarified imports
fkiraly Nov 9, 2021
c198887
added clarification on init
fkiraly Nov 9, 2021
34a4f85
est2 fixed
fkiraly Nov 9, 2021
260b8e0
removed fixed arg for transform testing
fkiraly Nov 9, 2021
68df4d6
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Nov 9, 2021
c2bca32
Merge branch 'transformers-refactor' of https://github.com/alan-turin…
MatthewMiddlehurst Nov 9, 2021
2433884
refactor summarizer and base class
fkiraly Nov 28, 2021
85bf58e
linting
fkiraly Nov 28, 2021
09f73be
wrong place
fkiraly Nov 28, 2021
37a632e
output for transformer fix
fkiraly Nov 28, 2021
4bbc26c
had wrong X_inner_mtype
fkiraly Dec 1, 2021
108570f
fixed test_raises_not_fitted_error test
fkiraly Dec 1, 2021
00d2442
Merge branch 'main' into transformers-primitives-fixes
fkiraly Dec 1, 2021
558885d
changed fit-in-transform behaviour to "fit must always be called even…
fkiraly Dec 4, 2021
67f25b7
Merge branch 'main' into transformers-primitives-fixes
fkiraly Dec 4, 2021
3848ed5
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Dec 5, 2021
2471b71
fresh prince
MatthewMiddlehurst Dec 5, 2021
ab8772a
fresh prince 2
MatthewMiddlehurst Dec 5, 2021
66ef346
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Dec 5, 2021
0e5afa6
i have to make this commit to swap branches and fix a bug
MatthewMiddlehurst Dec 6, 2021
2b7df0d
fix secondary error caused by changing fit-in-transform behaviour
fkiraly Dec 6, 2021
48567e6
Merge branch 'main' into transformers-primitives-fixes
fkiraly Dec 6, 2021
c3a2ca8
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Dec 6, 2021
14355af
testing changes, still some train estimate stuff to do
MatthewMiddlehurst Dec 7, 2021
86604e5
Merge branch 'transformers-primitives-fixes' of https://github.com/al…
MatthewMiddlehurst Dec 7, 2021
7c7d0a6
fresh prince test
MatthewMiddlehurst Dec 7, 2021
6363b51
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Dec 8, 2021
1736051
summary classifier fix and docs
MatthewMiddlehurst Dec 8, 2021
772cd68
pre-pr bug fix
MatthewMiddlehurst Dec 8, 2021
136b028
catch22 replace nans
MatthewMiddlehurst Dec 8, 2021
b359e39
catch22 single feature public
MatthewMiddlehurst Dec 8, 2021
fb04443
catch22 nan replacement change
MatthewMiddlehurst Dec 8, 2021
7c098e0
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Dec 8, 2021
e102bc9
Merge branch 'main' into summary-classifier
TonyBagnall Dec 10, 2021
0c484ed
Merge branch 'main' into summary-classifier
TonyBagnall Dec 11, 2021
1f96445
Merge branch 'main' into summary-classifier
TonyBagnall Dec 13, 2021
f0ccedd
Merge branch 'main' into summary-classifier
TonyBagnall Dec 14, 2021
24c9f84
Merge branch 'main' of https://github.com/alan-turing-institute/sktim…
MatthewMiddlehurst Dec 18, 2021
cc31960
tsfresh link
MatthewMiddlehurst Dec 18, 2021
bd21a45
Merge branch 'main' into summary-classifier
TonyBagnall Dec 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions sktime/classification/feature_based/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
__all__ = [
"Catch22Classifier",
"MatrixProfileClassifier",
"RandomIntervalClassifier",
"SignatureClassifier",
"SummaryClassifier",
"TSFreshClassifier",
"FreshPRINCE",
]

from sktime.classification.feature_based._catch22_classifier import Catch22Classifier
from sktime.classification.feature_based._fresh_prince import FreshPRINCE
from sktime.classification.feature_based._matrix_profile_classifier import (
MatrixProfileClassifier,
)
from sktime.classification.feature_based._random_interval_classifier import (
RandomIntervalClassifier,
)
from sktime.classification.feature_based._signature_classifier import (
SignatureClassifier,
)
from sktime.classification.feature_based._summary_classifier import SummaryClassifier
from sktime.classification.feature_based._tsfresh_classifier import TSFreshClassifier
21 changes: 11 additions & 10 deletions sktime/classification/feature_based/_catch22_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Catch22Classifier(BaseClassifier):
outlier_norm : bool, default=False
Normalise each series during the two outlier catch22 features, which can take a
while to process for large values
replace_nans : bool, default=True
Replace NaN or inf values from the catch22 transform with 0.
estimator : sklearn classifier, default=None
An sklearn estimator to be built using the transformed data. Defaults to a
Random Forest with 200 trees.
Expand Down Expand Up @@ -83,11 +85,13 @@ class Catch22Classifier(BaseClassifier):
def __init__(
self,
outlier_norm=False,
replace_nans=True,
estimator=None,
n_jobs=1,
random_state=None,
):
self.outlier_norm = outlier_norm
self.replace_nans = replace_nans
self.estimator = estimator

self.n_jobs = n_jobs
Expand Down Expand Up @@ -118,7 +122,9 @@ def _fit(self, X, y):
Changes state by creating a fitted model that updates attributes
ending in "_" and sets is_fitted flag to True.
"""
self._transformer = Catch22(outlier_norm=self.outlier_norm)
self._transformer = Catch22(
outlier_norm=self.outlier_norm, replace_nans=self.replace_nans
)

self._estimator = _clone_estimator(
RandomForestClassifier(n_estimators=200)
Expand All @@ -132,7 +138,7 @@ def _fit(self, X, y):
self._estimator.n_jobs = self._threads_to_use

X_t = self._transformer.fit_transform(X, y)
X_t = np.nan_to_num(X_t, False, 0, 0, 0)

self._estimator.fit(X_t, y)

return self
Expand All @@ -150,9 +156,7 @@ def _predict(self, X):
y : array-like, shape = [n_instances]
Predicted class labels.
"""
X_t = self._transformer.transform(X)
X_t = np.nan_to_num(X_t, False, 0, 0, 0)
return self._estimator.predict(X_t)
return self._estimator.predict(self._transformer.transform(X))

def _predict_proba(self, X):
"""Predict class probabilities for n instances in X.
Expand All @@ -167,15 +171,12 @@ def _predict_proba(self, X):
y : array-like, shape = [n_instances, n_classes_]
Predicted probabilities using the ordering in classes_.
"""
X_t = self._transformer.transform(X)
X_t = np.nan_to_num(X_t, False, 0, 0, 0)

m = getattr(self._estimator, "predict_proba", None)
if callable(m):
return self._estimator.predict_proba(X_t)
return self._estimator.predict_proba(self._transformer.transform(X))
else:
dists = np.zeros((X.shape[0], self.n_classes_))
preds = self._estimator.predict(X_t)
preds = self._estimator.predict(self._transformer.transform(X))
for i in range(0, X.shape[0]):
dists[i, self._class_dictionary[preds[i]]] = 1
return dists
206 changes: 206 additions & 0 deletions sktime/classification/feature_based/_fresh_prince.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# -*- coding: utf-8 -*-
"""FreshPRINCE Classifier.

Pipeline classifier using the full set of TSFresh features and a RotationForest
classifier.
"""

__author__ = ["MatthewMiddlehurst"]
__all__ = ["FreshPRINCE"]


from sktime.classification.base import BaseClassifier
from sktime.contrib.vector_classifiers._rotation_forest import RotationForest
from sktime.transformations.panel.tsfresh import TSFreshFeatureExtractor
from sktime.utils.validation.panel import check_X_y


class FreshPRINCE(BaseClassifier):
"""Fresh Pipeline with RotatIoN forest Classifier.

This classifier simply transforms the input data using the TSFresh [1]_
transformer with comprehensive features and builds a RotationForest estimator using
the transformed data.

Parameters
----------
default_fc_parameters : str, default="comprehensive"
Set of TSFresh features to be extracted, options are "minimal", "efficient" or
"comprehensive".
n_estimators : int, default=200
Number of estimators for the RotationForest ensemble.
verbose : int, default=0
Level of output printed to the console (for information only)
n_jobs : int, default=1
The number of jobs to run in parallel for both `fit` and `predict`.
``-1`` means using all processors.
chunksize : int or None, default=None
Number of series processed in each parallel TSFresh job, should be optimised
for efficient parallelisation.
random_state : int or None, default=None
Seed for random, integer.

Attributes
----------
n_classes_ : int
Number of classes. Extracted from the data.
classes_ : ndarray of shape (n_classes_)
Holds the label for each class.

See Also
--------
TSFreshFeatureExtractor, TSFreshClassifier, RotationForest

References
----------
.. [1] Christ, Maximilian, et al. "Time series feature extraction on basis of
scalable hypothesis tests (tsfresh–a python package)." Neurocomputing 307
(2018): 72-77.
https://www.sciencedirect.com/science/article/pii/S0925231218304843

Examples
--------
>>> from sktime.classification.feature_based import FreshPRINCE
>>> from sktime.contrib.vector_classifiers._rotation_forest import RotationForest
>>> from sktime.datasets import load_unit_test
>>> X_train, y_train = load_unit_test(split="train", return_X_y=True)
>>> X_test, y_test = load_unit_test(split="test", return_X_y=True)
>>> clf = FreshPRINCE(
... default_fc_parameters="minimal",
... n_estimators=10,
... )
>>> clf.fit(X_train, y_train)
FreshPRINCE(...)
>>> y_pred = clf.predict(X_test)
"""

_tags = {
"capability:multivariate": True,
"capability:multithreading": True,
"capability:train_estimate": True,
}

def __init__(
self,
default_fc_parameters="comprehensive",
n_estimators=200,
save_transformed_data=False,
verbose=0,
n_jobs=1,
chunksize=None,
random_state=None,
):
self.default_fc_parameters = default_fc_parameters
self.n_estimators = n_estimators

self.save_transformed_data = save_transformed_data
self.verbose = verbose
self.n_jobs = n_jobs
self.chunksize = chunksize
self.random_state = random_state

self.n_instances_ = 0
self.n_dims_ = 0
self.series_length_ = 0
self.transformed_data_ = []

self._rotf = None
self._tsfresh = None

super(FreshPRINCE, self).__init__()

def _fit(self, X, y):
"""Fit a pipeline on cases (X,y), where y is the target variable.

Parameters
----------
X : 3D np.array of shape = [n_instances, n_dimensions, series_length]
The training data.
y : array-like, shape = [n_instances]
The class labels.

Returns
-------
self :
Reference to self.

Notes
-----
Changes state by creating a fitted model that updates attributes
ending in "_" and sets is_fitted flag to True.
"""
self.n_instances_, self.n_dims_, self.series_length_ = X.shape

self._rotf = RotationForest(
n_estimators=self.n_estimators,
save_transformed_data=self.save_transformed_data,
n_jobs=self._threads_to_use,
random_state=self.random_state,
)
self._tsfresh = TSFreshFeatureExtractor(
default_fc_parameters=self.default_fc_parameters,
n_jobs=self._threads_to_use,
chunksize=self.chunksize,
show_warnings=self.verbose > 1,
disable_progressbar=self.verbose < 1,
)

X_t = self._tsfresh.fit_transform(X, y)
self._rotf.fit(X_t, y)

if self.save_transformed_data:
self.transformed_data_ = X_t

return self

def _predict(self, X):
"""Predict class values of n instances in X.

Parameters
----------
X : 3D np.array of shape = [n_instances, n_dimensions, series_length]
The data to make predictions for.

Returns
-------
y : array-like, shape = [n_instances]
Predicted class labels.
"""
return self._rotf.predict(self._tsfresh.transform(X))

def _predict_proba(self, X):
"""Predict class probabilities for n instances in X.

Parameters
----------
X : 3D np.array of shape = [n_instances, n_dimensions, series_length]
The data to make predict probabilities for.

Returns
-------
y : array-like, shape = [n_instances, n_classes_]
Predicted probabilities using the ordering in classes_.
"""
return self._rotf.predict_proba(self._tsfresh.transform(X))

def _get_train_probs(self, X, y):
self.check_is_fitted()
X, y = check_X_y(X, y, coerce_to_numpy=True)

n_instances, n_dims, series_length = X.shape

if (
n_instances != self.n_instances_
or n_dims != self.n_dims_
or series_length != self.series_length_
):
raise ValueError(
"n_instances, n_dims, series_length mismatch. X should be "
"the same as the training data used in fit for generating train "
"probabilities."
)

if not self.save_transformed_data:
raise ValueError("Currently only works with saved transform data from fit.")

return self._rotf._get_train_probs(self.transformed_data_, y)