-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework search space for wavelet_basis, rework dask multithread, add b…
…asic variance feature filtration to extractors
- Loading branch information
v1docq
committed
Oct 22, 2024
1 parent
ec69b4d
commit c85d28d
Showing
13 changed files
with
842 additions
and
1,190 deletions.
There are no files selected for viewing
745 changes: 71 additions & 674 deletions
745
examples/tutorial/time_series/ts_classification/classification_example_advanced.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
1,025 changes: 588 additions & 437 deletions
1,025
examples/tutorial/time_series/ts_classification/classification_example_basic.ipynb
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import pandas as pd | ||
from hyperopt import hp | ||
|
||
from fedot_ind.core.architecture.pipelines.abstract_pipeline import AbstractPipeline, ApiTemplate | ||
|
||
|
||
def plot_mean_sample(X, y, labels: list = [], n_channel: int = 1): | ||
mean_sample = [] | ||
if len(labels) == 0: | ||
labels = list(np.unique(y)) | ||
for label in labels: | ||
mean_sample.append(np.mean(X[y == label], axis=0)) # Данные класса 1 | ||
# ax = plt.gca() | ||
channels = [f'Channel {x}' for x in range(n_channel)] | ||
df = pd.DataFrame(mean_sample).T | ||
df.columns = labels | ||
df.plot(kind='line', subplots=True, layout=(1, len(labels)), figsize=(20, 10)) | ||
plt.legend(fontsize='small') | ||
plt.legend(loc='upper left', bbox_to_anchor=(1, 1)) | ||
plt.show() | ||
|
||
|
||
# %% | ||
def plot_mean_sample_multi(X, y, labels: list = [], n_channel: int = None): | ||
mean_sample = {} | ||
if len(labels) == 0: | ||
labels = list(np.unique(y)) | ||
if n_channel is None: | ||
n_channel = X.shape[1] | ||
channels = [f'Channel {x}' for x in range(n_channel)] | ||
for label in labels: | ||
mask = y == label | ||
for chn in range(n_channel): | ||
mean_sample.update( | ||
{f'Label_{label}_channel_{chn}': np.mean(X[mask.flatten(), chn, :], axis=0)}) # Данные класса 1 | ||
# ax = plt.gca() | ||
df = pd.DataFrame(mean_sample) | ||
df.plot(kind='line') | ||
plt.suptitle('Усреднённые семплы по классам') | ||
plt.legend(fontsize='small') | ||
plt.legend(loc='upper left', bbox_to_anchor=(1, 1)) | ||
plt.show() | ||
|
||
|
||
# %% md | ||
### Topo Hyperparams | ||
# %% | ||
topological_params = {'window_size': {'hyperopt-dist': hp.choice, 'sampling-scope': [[x for x in range(5, 50, 5)]]}, | ||
'stride': {'hyperopt-dist': hp.choice, 'sampling-scope': [[x for x in range(1, 10, 1)]]}}, | ||
# %% | ||
stat_params = {'window_size': {'hyperopt-dist': hp.choice, 'sampling-scope': [[x for x in range(5, 50, 5)]]}, | ||
'stride': {'hyperopt-dist': hp.choice, 'sampling-scope': [[x for x in range(1, 10, 1)]]}, | ||
'add_global_features': {'hyperopt-dist': hp.choice, 'sampling-scope': [[True, False]]}} | ||
# %% | ||
recurrence_params = {'window_size': {'hyperopt-dist': hp.choice, 'sampling-scope': [[x for x in range(5, 50, 5)]]}, | ||
'stride': {'hyperopt-dist': hp.choice, 'sampling-scope': [[x for x in range(1, 10, 1)]]}, | ||
'rec_metric': (hp.choice, [['cosine', 'euclidean']]), | ||
'image_mode': {'hyperopt-dist': hp.choice, 'sampling-scope': [[True, False]]}}, | ||
# %% | ||
rec_metric = 'cosine' | ||
image_mode = True | ||
window_size = 10 | ||
stride = 1 | ||
# %% | ||
topological_node_dict = {'topological_extractor': {'window_size': window_size, | ||
'stride': stride}} | ||
# %% | ||
recurrence_node_dict = {'recurrence_extractor': {'window_size': window_size, | ||
'stride': stride, | ||
'rec_metric': rec_metric, | ||
'image_mode': image_mode}} | ||
|
||
finetune = False | ||
metric_names = ('f1', 'accuracy', 'precision', 'roc_auc') | ||
api_config = dict(problem='classification', | ||
metric='accuracy', | ||
timeout=15, | ||
pop_size=20, | ||
with_tunig=False, | ||
n_jobs=-1, | ||
logging_level=10) | ||
pipeline_creator = AbstractPipeline(task='classification') | ||
ECG = 'ECG200' | ||
topological_model = ['topological_extractor', 'rf'] | ||
recurrence_model = ['recurrence_extractor', 'quantile_extractor', 'rf'] | ||
# %% | ||
ecg_dataset = pipeline_creator.create_input_data(ECG) | ||
|
||
if __name__ == "__main__": | ||
topo_list_model = { | ||
'topological_extractor': {'window_size': 10}, | ||
'logit': {}} | ||
result_dict_topo = ApiTemplate(api_config=api_config, | ||
metric_list=metric_names).eval(dataset=ECG, | ||
finetune=finetune, | ||
initial_assumption=topo_list_model) | ||
_ = 1 |
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
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.