-
Notifications
You must be signed in to change notification settings - Fork 122
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
[MNT] Tidy up classification and regression tests #2314
Open
MatthewMiddlehurst
wants to merge
11
commits into
main
Choose a base branch
from
mm/regression-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
563626f
clf
MatthewMiddlehurst d1f5912
classification and regression
MatthewMiddlehurst faead89
fixes
MatthewMiddlehurst 55876bb
interval fixes
MatthewMiddlehurst 497ba8a
Merge branch 'mm/clf-fixes' into mm/regression-tests
MatthewMiddlehurst 9d222db
check coverage change from interval tests
MatthewMiddlehurst 36d7115
tsf contract params
MatthewMiddlehurst 0134c2b
predict on test
MatthewMiddlehurst 74add5a
interval tests
MatthewMiddlehurst 4b67438
fixes
MatthewMiddlehurst 0a1a808
merge
MatthewMiddlehurst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"""Tests for interval based classifiers.""" | ||
"""Tests for interval-based classifiers.""" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
aeon/classification/interval_based/tests/test_interval_forests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
"""Test interval forest classifiers.""" | ||
|
||
import pytest | ||
|
||
from aeon.classification.interval_based import ( | ||
CanonicalIntervalForestClassifier, | ||
DrCIFClassifier, | ||
RandomIntervalSpectralEnsembleClassifier, | ||
SupervisedTimeSeriesForest, | ||
TimeSeriesForestClassifier, | ||
) | ||
from aeon.classification.sklearn import ContinuousIntervalTree | ||
from aeon.testing.testing_data import EQUAL_LENGTH_UNIVARIATE_CLASSIFICATION | ||
from aeon.testing.utils.estimator_checks import _assert_predict_probabilities | ||
from aeon.utils.validation._dependencies import _check_soft_dependencies | ||
from aeon.visualisation import plot_temporal_importance_curves | ||
|
||
|
||
@pytest.mark.skipif( | ||
not _check_soft_dependencies(["matplotlib", "seaborn"], severity="none"), | ||
reason="skip test if required soft dependency not available", | ||
) | ||
@pytest.mark.parametrize( | ||
"cls", | ||
[ | ||
CanonicalIntervalForestClassifier, | ||
DrCIFClassifier, | ||
SupervisedTimeSeriesForest, | ||
TimeSeriesForestClassifier, | ||
], | ||
) | ||
def test_tic_curves(cls): | ||
"""Test whether temporal_importance_curves runs without error.""" | ||
import matplotlib | ||
|
||
matplotlib.use("Agg") | ||
|
||
X_train, y_train = EQUAL_LENGTH_UNIVARIATE_CLASSIFICATION["numpy3D"]["train"] | ||
|
||
params = cls._get_test_params() | ||
if isinstance(params, list): | ||
params = params[0] | ||
params.update({"base_estimator": ContinuousIntervalTree()}) | ||
|
||
clf = cls(**params) | ||
clf.fit(X_train, y_train) | ||
|
||
names, curves = clf.temporal_importance_curves() | ||
plot_temporal_importance_curves(curves, names) | ||
|
||
|
||
@pytest.mark.parametrize("cls", [RandomIntervalSpectralEnsembleClassifier]) | ||
def test_tic_curves_invalid(cls): | ||
"""Test whether temporal_importance_curves raises an error.""" | ||
clf = cls() | ||
with pytest.raises( | ||
NotImplementedError, match="No temporal importance curves available." | ||
): | ||
clf.temporal_importance_curves() | ||
|
||
|
||
@pytest.mark.skipif( | ||
not _check_soft_dependencies(["pycatch22"], severity="none"), | ||
reason="skip test if required soft dependency not available", | ||
) | ||
@pytest.mark.parametrize("cls", [CanonicalIntervalForestClassifier, DrCIFClassifier]) | ||
def test_forest_pycatch22(cls): | ||
"""Test whether the forest classifiers with pycatch22 run without error.""" | ||
X_train, y_train = EQUAL_LENGTH_UNIVARIATE_CLASSIFICATION["numpy3D"]["train"] | ||
X_test, _ = EQUAL_LENGTH_UNIVARIATE_CLASSIFICATION["numpy3D"]["test"] | ||
|
||
params = cls._get_test_params() | ||
if isinstance(params, list): | ||
params = params[0] | ||
params.update({"use_pycatch22": True}) | ||
|
||
clf = cls(**params) | ||
clf.fit(X_train, y_train) | ||
prob = clf.predict_proba(X_test) | ||
_assert_predict_probabilities(prob, X_test, n_classes=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this covered in the tests? Would be good to increase the coverage on this class, its currently on 69% with 190 missed lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pr is the first step for doing this really, now that all the regressors are properly covered in general testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but yes it is covered here https://github.com/aeon-toolkit/aeon/pull/2314/files#diff-4d4e0a0a86dce2606c69a9f9e4dc24694b606a7db864eb1b1792c659fd9fa743R25