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

Riemann #128

Merged
merged 48 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c38342b
add riemann extractor. Fix mutations. Update result analysis. Update …
Mar 12, 2024
8981efc
exclude logdet and harmonic metrics
Mar 12, 2024
6b89059
eclude wassertein metric. Refactoring stratify split
Mar 12, 2024
b68a328
added shrinkage to riemann extractor
technocreep Mar 21, 2024
f5c7e1c
Merge remote-tracking branch 'origin/riemann' into riemann
technocreep Mar 21, 2024
0dddde4
add chonos decoder feature extractor. add channel filtration. minor a…
Mar 29, 2024
1837164
channel filtration, knee method to rsvd, update api examples
Apr 2, 2024
5af3b13
refactoring examples
Apr 5, 2024
2d04717
add forecasting composition
Apr 8, 2024
787135d
examples updates
Apr 8, 2024
27b42cd
examples updates part 2
Apr 9, 2024
44ee34f
api refactoring for compability with kernel and federated strategy
Apr 12, 2024
f962d6f
examples refactoring
Apr 12, 2024
b67c687
ts forecasting add strategy, data leak refactoring
Apr 15, 2024
fc49e56
mutation fixes, channel indpenedt fix
Apr 15, 2024
79f75bb
add opt histopy vis
Apr 16, 2024
e692c87
add monash example
Apr 16, 2024
5b837dc
few minor harmless improvements
technocreep Apr 17, 2024
fbd5e89
chronos off, req update
Apr 18, 2024
2926a5e
add exog forecasting
Apr 18, 2024
7e85e4a
example monash updated
Apr 18, 2024
d966442
fixed some tests
technocreep Apr 22, 2024
6523b1a
Merge remote-tracking branch 'origin/riemann' into riemann
technocreep Apr 22, 2024
10431fb
fixed requirements
technocreep Apr 22, 2024
fa19810
fixed requirements
technocreep Apr 22, 2024
85b4531
fixed requirements
technocreep Apr 22, 2024
ca2536f
added poetry config
technocreep Apr 23, 2024
5c75739
added poetry action
technocreep Apr 23, 2024
90bba17
fix poetry action
technocreep Apr 23, 2024
82dc427
rename poetry action
technocreep Apr 23, 2024
388f120
created release action and updated unit-test action
technocreep Apr 23, 2024
caaced7
add kernel ensemble strategy, topo features generation
Apr 23, 2024
403a839
Merge remote-tracking branch 'origin/riemann' into riemann
Apr 23, 2024
c5ed552
Merge branch 'main' into riemann
v1docq Apr 23, 2024
ffbb7eb
fixed TG link to support channel
technocreep Apr 24, 2024
937d645
kernel ensemble updates
Apr 25, 2024
b022445
Merge remote-tracking branch 'origin/riemann' into riemann
Apr 25, 2024
02a6dc4
applied autopep and base_nn_model refactoring
technocreep Apr 27, 2024
be7924e
Merge remote-tracking branch 'origin/riemann' into riemann
technocreep Apr 27, 2024
9f5a936
resolve conflicts
technocreep Apr 27, 2024
60e128b
fixed pep8 issues
technocreep Apr 27, 2024
adec8db
cleaned test/data directory; updated integration tests
technocreep Apr 27, 2024
a9ecb8e
updated intergration test workflow
technocreep Apr 27, 2024
8e55b93
updated intergration test workflow #2
technocreep Apr 27, 2024
c43113b
updated intergration test workflow #3
technocreep Apr 27, 2024
169e989
release commit
May 2, 2024
a9d4244
Merge remote-tracking branch 'origin/riemann' into riemann
May 2, 2024
2875026
minor fixes
May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
49 changes: 32 additions & 17 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
name: Integration Tests

on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
workflow_dispatch:

jobs:
build:
test:
runs-on: ubuntu-latest
timeout-minutes: 95
timeout-minutes: 30
strategy:
matrix:
python-version: [ 3.9 ]
python-version: [3.8, 3.9, '3.10']

steps:
- uses: actions/checkout@v2

- name: Checkout branch
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Cache Poetry virtualenv
uses: actions/cache@v2
with:
path: ~/.local/share/poetry/virtualenvs/ # Cache Poetry virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('pyproject.toml') }} # Cache key based on project dependencies

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.2 # Specify your desired Poetry version (pin it for stability)
virtualenvs-create: true
virtualenvs-in-project: true # Create venv within project directory

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements.txt
pip install pytest-cov

- name: Test with pytest
run: |
pytest --cov=fedot -s tests/integration
run: poetry install

- name: Run tests with pytest
run: poetry run pytest --cov=fedot -s tests/integration

- name: Codecov-coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
10 changes: 5 additions & 5 deletions .github/workflows/poetry_unit_test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Poetry Unit Tests
name: Unit Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
# push:
# branches: [ main , release ]
# pull_request:
# branches: [ main , release ]

jobs:
test:
Expand Down
39 changes: 27 additions & 12 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
name: Build and publish package to PyPi
name: Build, publish, and deploy with Poetry (on release)

on:
workflow_dispatch:
workflow_dispatch: {}
release:
types: [published]

jobs:
build_and_publish:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.9 ]
python-version: [3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Build package
- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
python setup.py sdist bdist_wheel
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: poetry install
- name: Build package
run:
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry build

- name: Publish package to PyPI (if release)
if: github.event_name == 'release'
# env:
# PYPI_USERNAME: __token__
# PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: poetry publish

- name: Deploy source code
if: github.event_name == 'release'
uses: actions/upload-artifact@v2
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
repository_url: https://upload.pypi.org/legacy/
name: source-code-${{ matrix.python-version }}
path: .

41 changes: 0 additions & 41 deletions .github/workflows/unit_tests.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
:alt: Downloads

.. |support| image:: https://img.shields.io/badge/Telegram-Group-blue.svg
:target: https://t.me/fedotindustrial_support
:target: https://t.me/FEDOT_helpdesk
:alt: Support

.. |rus| image:: https://img.shields.io/badge/lang-ru-yellow.svg
Expand Down
2 changes: 1 addition & 1 deletion README_en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
:alt: Downloads

.. |support| image:: https://img.shields.io/badge/Telegram-Group-blue.svg
:target: https://t.me/fedotindustrial_support
:target: https://t.me/FEDOT_helpdesk
:alt: Support

.. |rus| image:: https://img.shields.io/badge/lang-ru-yellow.svg
Expand Down
31 changes: 18 additions & 13 deletions benchmark/benchmark_TSC.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,31 @@ def finetune(self):
self.logger.info('Benchmark finetune started')
dataset_result = {}
for dataset_name in self.custom_datasets:
path_to_results = PROJECT_PATH + self.path_to_save + f'/{dataset_name}'
path_to_results = PROJECT_PATH + \
self.path_to_save + f'/{dataset_name}'
composed_model_path = [path_to_results + f'/{x}' for x in os.listdir(path_to_results)
if x.__contains__('pipeline_saved')]
metric_result = {}
for p in composed_model_path:
if os.path.isdir(p):
try:
self.experiment_setup['output_folder'] = PROJECT_PATH + \
self.path_to_save
self.path_to_save
experiment_setup = deepcopy(self.experiment_setup)
prediction, model = self.finetune_loop(
dataset_name, experiment_setup, p)
metric_result.update({p:
{'metric': Accuracy(model.predict_data.target,
prediction.ravel()).metric(),
'tuned_model': model}})
{'metric': Accuracy(model.predict_data.target,
prediction.ravel()).metric(),
'tuned_model': model}})
except ModuleNotFoundError as ex:
print(f'{ex}.OLD VERSION OF PIPELINE. DELETE DIRECTORY')
if len(composed_model_path) != 1:
print(f'OLD VERSION OF PIPELINE. DELETE DIRECTORY')
shutil.rmtree(p)
else:
print(f'OLD VERSION OF PIPELINE. IT IS A LAST SAVED MODEL')
print(
f'OLD VERSION OF PIPELINE. IT IS A LAST SAVED MODEL')
else:
print(f"No composed model for dataset - {dataset_name}")
dataset_path = os.path.join(self.experiment_setup['output_folder'], f'{dataset_name}',
Expand All @@ -102,17 +104,20 @@ def finetune(self):
best_metric = 0
for _ in metric_result.keys():
if best_metric == 0:
best_metric, best_model, path = metric_result[_]['metric'], metric_result[_]['tuned_model'], _
best_metric, best_model, path = metric_result[_][
'metric'], metric_result[_]['tuned_model'], _
elif metric_result[_]['metric'] > best_metric:
best_metric, best_model, path = metric_result[_]['metric'], metric_result[_]['tuned_model'], _
fedot_results.loc[dataset_name, 'Fedot_Industrial_finetuned'] = best_metric
best_metric, best_model, path = metric_result[_][
'metric'], metric_result[_]['tuned_model'], _
fedot_results.loc[dataset_name,
'Fedot_Industrial_finetuned'] = best_metric
best_model.output_folder = f'{_}_tuned'
best_model.save_best_model()
fedot_results.to_csv(dataset_path)
else:
fedot_results.to_csv(dataset_path)
gc.collect()
dataset_result.update({dataset_name:metric_result})
dataset_result.update({dataset_name: metric_result})
self.logger.info("Benchmark finetune finished")

def load_local_basic_results(self, path: str = None):
Expand All @@ -125,7 +130,7 @@ def load_local_basic_results(self, path: str = None):
except Exception:
results = self.load_web_results()
self.experiment_setup['output_folder'] = PROJECT_PATH + \
self.path_to_save
self.path_to_save
return results
else:
return self.results_picker.run(get_metrics_df=True, add_info=True)
Expand All @@ -135,14 +140,14 @@ def create_report(self):
names = []
for dataset_name in self.custom_datasets:
model_result_path = PROJECT_PATH + self.path_to_save + \
f'/{dataset_name}' + '/metrics_report.csv'
f'/{dataset_name}' + '/metrics_report.csv'
if os.path.isfile(model_result_path):
df = pd.read_csv(model_result_path, index_col=0, sep=',')
df = df.fillna(0)
if 'Fedot_Industrial_finetuned' not in df.columns:
df['Fedot_Industrial_finetuned'] = 0
metrics = df.loc[dataset_name,
'Fedot_Industrial':'Fedot_Industrial_finetuned']
'Fedot_Industrial':'Fedot_Industrial_finetuned']
_.append(metrics.T.values)
names.append(dataset_name)
stacked_resutls = np.stack(_, axis=1).T
Expand Down
2 changes: 1 addition & 1 deletion benchmark/benchmark_TSER.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def finetune_loop(self, dataset, experiment_setup, composed_model_path):
model = FedotIndustrial(**experiment_setup)
model.load(path=composed_model_path)

model.finetune(train_data,tuning_params)
model.finetune(train_data, tuning_params)
prediction = model.predict(test_data)
return prediction, model

Expand Down
39 changes: 26 additions & 13 deletions benchmark/benchmark_TSF.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ def __init__(self,
def evaluate_loop(self, dataset, experiment_setup: dict = None):
matplotlib.use('TkAgg')
train_data = DataLoader(dataset_name=dataset).load_forecast_data()
experiment_setup['task_params'] = TsForecastingParams(forecast_length=M4_FORECASTING_LENGTH[dataset[0]])
target = train_data.iloc[-experiment_setup['task_params'].forecast_length:, :].values.ravel()
train_data = train_data.iloc[:-experiment_setup['task_params'].forecast_length, :]
experiment_setup['task_params'] = TsForecastingParams(
forecast_length=M4_FORECASTING_LENGTH[dataset[0]])
target = train_data.iloc[-experiment_setup['task_params']
.forecast_length:, :].values.ravel()
train_data = train_data.iloc[:-
experiment_setup['task_params'].forecast_length, :]
model = FedotIndustrial(**experiment_setup)
model.fit(train_data)
prediction = model.predict(train_data)
Expand All @@ -68,29 +71,35 @@ def run(self):
metric_dict = {}
for dataset_name in self.custom_datasets:
experiment_setup = deepcopy(self.experiment_setup)
prediction, target, model = self.evaluate_loop(dataset_name, experiment_setup)
prediction, target, model = self.evaluate_loop(
dataset_name, experiment_setup)
metric = SMAPE(prediction, target).metric()
metric_dict.update({dataset_name: metric})
dataset_path = os.path.join(self.experiment_setup['output_folder'], f'{dataset_name}')
dataset_path = os.path.join(
self.experiment_setup['output_folder'], f'{dataset_name}')
if not os.path.exists(dataset_path):
os.makedirs(dataset_path)
basic_results.loc[dataset_name, 'Fedot_Industrial'] = metric
basic_results.to_csv(os.path.join(dataset_path, 'metrics_report.csv'))
basic_results.to_csv(os.path.join(
dataset_path, 'metrics_report.csv'))
pred_df = pd.DataFrame([target, prediction]).T
pred_df.columns = ['label', 'prediction']
pred_df.to_csv(os.path.join(dataset_path, 'prediction.csv'))
model.solver.save(dataset_path)
gc.collect()
basic_path = os.path.join(self.experiment_setup['output_folder'], 'comprasion_metrics_report.csv')
basic_path = os.path.join(
self.experiment_setup['output_folder'], 'comprasion_metrics_report.csv')
basic_results.to_csv(basic_path)
self.logger.info("Benchmark test finished")

def finetune(self):
self.logger.info('Benchmark finetune started')
for dataset_name in self.custom_datasets:
composed_model_path = PROJECT_PATH + self.path_to_save + f'/{dataset_name}' + '/0_pipeline_saved'
composed_model_path = PROJECT_PATH + self.path_to_save + \
f'/{dataset_name}' + '/0_pipeline_saved'
if os.path.isdir(composed_model_path):
self.experiment_setup['output_folder'] = PROJECT_PATH + self.path_to_save
self.experiment_setup['output_folder'] = PROJECT_PATH + \
self.path_to_save
experiment_setup = deepcopy(self.experiment_setup)
prediction, target = self.finetune_loop(
dataset_name, experiment_setup)
Expand All @@ -99,7 +108,8 @@ def finetune(self):
f'{dataset_name}',
'metrics_report.csv')
fedot_results = pd.read_csv(dataset_path, index_col=0)
fedot_results.loc[dataset_name, 'Fedot_Industrial_finetuned'] = metric
fedot_results.loc[dataset_name,
'Fedot_Industrial_finetuned'] = metric

fedot_results.to_csv(dataset_path)
else:
Expand All @@ -112,20 +122,23 @@ def load_local_basic_results(self, path: str = None):
results = pd.read_csv(path, sep=',', index_col=0).T
results = results.dropna(axis=1, how='all')
results = results.dropna(axis=0, how='all')
self.experiment_setup['output_folder'] = PROJECT_PATH + self.path_to_save
self.experiment_setup['output_folder'] = PROJECT_PATH + \
self.path_to_save
return results

def create_report(self):
_ = []
names = []
for dataset_name in self.custom_datasets:
model_result_path = PROJECT_PATH + self.path_to_save + f'/{dataset_name}' + '/metrics_report.csv'
model_result_path = PROJECT_PATH + self.path_to_save + \
f'/{dataset_name}' + '/metrics_report.csv'
if os.path.isfile(model_result_path):
df = pd.read_csv(model_result_path, index_col=0, sep=',')
df = df.fillna(0)
if 'Fedot_Industrial_finetuned' not in df.columns:
df['Fedot_Industrial_finetuned'] = 0
metrics = df.loc[dataset_name, 'Fedot_Industrial':'Fedot_Industrial_finetuned']
metrics = df.loc[dataset_name,
'Fedot_Industrial':'Fedot_Industrial_finetuned']
_.append(metrics.T.values)
names.append(dataset_name)
stacked_results = np.stack(_, axis=1).T
Expand Down
Loading
Loading