Skip to content

Commit

Permalink
Remote evaluation fixes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
nicl-nno committed Aug 7, 2023
1 parent bc2c138 commit e1f8f2f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
23 changes: 9 additions & 14 deletions examples/advanced/remote_execution/remote_fit_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

import numpy as np

from fedot.core.data.data import InputData
from fedot.core.pipelines.node import PipelineNode
from fedot.core.pipelines.pipeline import Pipeline
from examples.simple.classification.classification_pipelines import classification_three_depth_manual_pipeline
from fedot.core.utils import fedot_project_root
from fedot.remote.infrastructure.clients.test_client import TestClient
from fedot.remote.infrastructure.clients.datamall_client import DataMallClient, DEFAULT_CONNECT_PARAMS, \
DEFAULT_EXEC_PARAMS
from fedot.remote.remote_evaluator import RemoteEvaluator, RemoteTaskParams

random.seed(1)
Expand All @@ -22,16 +21,9 @@
folder = os.path.join(fedot_project_root(), 'cases', 'data', 'scoring')
path = os.path.join(folder, 'scoring_train.csv')

start = datetime.now()
model = 'rf'

for i in range(num_parallel):
data = InputData.from_csv(path)
data.subset_indices([1, 2, 3, 4, 5, 20])
pipeline = Pipeline(PipelineNode('rf'))
pipeline.fit_from_scratch(data)
end = datetime.now()

print('LOCAL EXECUTION TIME', end - start)

# REMOTE RUN

Expand All @@ -51,7 +43,10 @@
max_parallel=num_parallel
)

client = TestClient(connect_params, exec_params, output_path=os.path.join(folder, 'remote'))
# following client and params can be used with DataMall system
connect_params = DEFAULT_CONNECT_PARAMS
exec_params = DEFAULT_EXEC_PARAMS
client = DataMallClient(connect_params, exec_params, output_path=os.path.join(folder, 'remote'))

evaluator = RemoteEvaluator()
evaluator.init(
Expand All @@ -61,7 +56,7 @@

start = datetime.now()

pipelines = [Pipeline(PipelineNode('rf'))] * num_parallel
pipelines = [classification_three_depth_manual_pipeline()] * num_parallel
fitted_pipelines = evaluator.compute_graphs(pipelines)

[print(p.is_fitted) for p in fitted_pipelines]
Expand Down
18 changes: 14 additions & 4 deletions examples/simple/classification/classification_pipelines.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from copy import deepcopy

from fedot.core.pipelines.node import PipelineNode
from fedot.core.pipelines.pipeline import Pipeline

Expand Down Expand Up @@ -152,16 +154,24 @@ def classification_three_depth_manual_pipeline():
Where rf - xg boost classifier, logit - logistic regression, knn - K nearest neighbors classifier,
qda - discriminant analysis
"""
logit_node_primary = PipelineNode('logit')
logit_node_primary = PipelineNode('rf')
xgb_node_primary = PipelineNode('rf')
xgb_node_primary_second = PipelineNode('rf')

qda_node_third = PipelineNode('qda', nodes_from=[xgb_node_primary_second])
knn_node_third = PipelineNode('knn', nodes_from=[logit_node_primary, xgb_node_primary])
qda_node_third = PipelineNode('rf', nodes_from=[xgb_node_primary_second])
knn_node_third = PipelineNode('rf', nodes_from=[logit_node_primary, xgb_node_primary])

knn_root0 = PipelineNode('rf', nodes_from=[qda_node_third, knn_node_third])
knn_root1 = deepcopy(PipelineNode('rf', nodes_from=[qda_node_third, knn_node_third]))
knn_root2 = deepcopy(PipelineNode('rf', nodes_from=[qda_node_third, knn_node_third]))
knn_root3 = deepcopy(PipelineNode('rf', nodes_from=[qda_node_third, knn_node_third]))
knn_root4 = deepcopy(PipelineNode('rf', nodes_from=[qda_node_third, knn_node_third]))
knn_root5 = deepcopy(PipelineNode('rf', nodes_from=[qda_node_third, knn_node_third]))

knn_root = PipelineNode('knn', nodes_from=[qda_node_third, knn_node_third])
knn_root = PipelineNode('rf', nodes_from=[knn_root0, knn_root1, knn_root2, knn_root3, knn_root4, knn_root5])

pipeline = Pipeline(knn_root)
pipeline.show()

return pipeline

Expand Down
1 change: 0 additions & 1 deletion fedot/core/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ def is_column_name_suitable_for_index(column_name: str) -> bool:
defined_index = define_index_column(candidate_idx_cols)
if defined_index is not None:
index_col = defined_index
logger.message(f'Used the column as index: "{index_col}".')

if (index_col is not None) and (index_col not in columns_to_use):
columns_to_use.append(index_col)
Expand Down
4 changes: 2 additions & 2 deletions fedot/remote/infrastructure/clients/datamall_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'container_output_path': "/home/FEDOT/output_data_dir",
'container_config_path': "/home/FEDOT/.config",
'container_image': "fedot:dm-9",
'timeout': 360
'timeout': 3600
}

# example of connection params for DataMall
Expand All @@ -28,7 +28,7 @@
'AUTH_SERVER': 'http://10.32.0.51:30880/b',
'CONTR_SERVER': 'http://10.32.0.51:30880/models-controller',
'PROJECT_ID': '83',
'DATA_ID': '60'
'DATA_ID': '56'
}


Expand Down
2 changes: 1 addition & 1 deletion test/integration/api_params/test_main_api_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_timeout(case: TimeoutParams):
composer_params = {
'max_depth': 1,
'max_arity': 1,
'pop_size': 1,
'pop_size': 2,
'with_tuning': False,
'validation_blocks': 1,
'genetic_scheme': GeneticSchemeTypesEnum.generational,
Expand Down

0 comments on commit e1f8f2f

Please sign in to comment.