Skip to content

Commit

Permalink
Fix random list elements order in case of set -> list transform
Browse files Browse the repository at this point in the history
Model become less random but it is not full solution
  • Loading branch information
kasyanovse committed Jul 28, 2023
1 parent 07edf3e commit 6ae6c98
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fedot/api/api_utils/presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def filter_operations_by_preset(self, data_type: Optional[DataTypesEnum] = None)
filtered_operations = set(available_operations).difference(set(excluded_tree))
available_operations = list(filtered_operations)

return available_operations
return sorted(available_operations)

@staticmethod
def new_operations_without_heavy(excluded_operations, available_operations) -> list:
Expand Down
2 changes: 1 addition & 1 deletion fedot/core/data/multi_modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def from_csv_time_series(cls,
df = get_df_from_csv(file_path, delimiter, index_col, possible_idx_keywords, columns_to_use=columns_to_use)
idx = df.index.to_numpy()
if not columns_to_use:
columns_to_use = list(set(df.columns) - {index_col})
columns_to_use = sorted(list(set(df.columns) - {index_col}))

if is_predict:
raise NotImplementedError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _apply_label_encoder(self, categorical_column: np.array, categorical_id: int
encoder_classes = list(column_encoder.classes_)

# If the column contains categories not previously encountered
for label in list(set(categorical_column)):
for label in sorted(list(set(categorical_column))):
if label not in encoder_classes:
encoder_classes.append(label)

Expand Down
2 changes: 1 addition & 1 deletion fedot/core/operations/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _eval_strategy_for_task(operation_type: str, current_task_type: TaskTypesEnu
globally_compatible_task_types = compatible_task_types(current_task_type)
globally_set = set(globally_compatible_task_types)

comp_types_acceptable_for_operation = list(set_acceptable_types.intersection(globally_set))
comp_types_acceptable_for_operation = sorted(list(set_acceptable_types.intersection(globally_set)))
if len(comp_types_acceptable_for_operation) == 0:
raise ValueError(f'Operation {operation_type} can not be used as a part of {current_task_type}.')
current_task_type = comp_types_acceptable_for_operation[0]
Expand Down
4 changes: 2 additions & 2 deletions fedot/core/pipelines/pipeline_node_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def get_node(self,
def _return_node(candidates) -> Optional[OptNode]:
if not candidates:
return None
return OptNode(content={'name': choice(candidates)})
return OptNode(content={'name': choice(sorted(candidates))})

@staticmethod
def filter_specific_candidates(candidates: list):
return list(filter(lambda x: not check_for_specific_operations(x), candidates))
return sorted(list(filter(lambda x: not check_for_specific_operations(x), candidates)))
2 changes: 1 addition & 1 deletion fedot/core/pipelines/verification_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def has_no_data_flow_conflicts_in_ts_pipeline(pipeline: Pipeline):
""" Function checks the correctness of connection between nodes """
task = Task(TaskTypesEnum.ts_forecasting)
ts_models = get_operations_for_task(task=task, mode='model', tags=["non_lagged"])
non_ts_models = list(set(get_operations_for_task(task=task, mode='model')).difference(set(ts_models)))
non_ts_models = sorted(list(set(get_operations_for_task(task=task, mode='model')).difference(set(ts_models))))

# Preprocessing not only for time series
non_ts_data_operations = get_operations_for_task(task=task,
Expand Down
6 changes: 3 additions & 3 deletions fedot/core/repository/pipeline_operation_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def from_available_operations(self, task: Task, preset: str,
available_operations: List[str]):
""" Initialize repository from available operations, task and preset """
operations_by_task_preset = OperationsPreset(task, preset).filter_operations_by_preset()
all_operations = list(set.intersection(set(operations_by_task_preset), set(available_operations)))
all_operations = sorted(list(set.intersection(set(operations_by_task_preset), set(available_operations))))
primary_operations, secondary_operations = \
self.divide_operations(all_operations, task)
self.operations_by_keys = {'primary': primary_operations, 'secondary': secondary_operations}
Expand All @@ -40,7 +40,7 @@ def get_operations(self, is_primary: bool) -> List[str]:

def get_all_operations(self) -> List[str]:
""" Get all pipeline operations with all keys """
return list(itertools.chain(*self.operations_by_keys.values()))
return sorted(list(itertools.chain(*self.operations_by_keys.values())))

@staticmethod
def divide_operations(available_operations, task):
Expand All @@ -61,7 +61,7 @@ def divide_operations(available_operations, task):
ts_primary_operations = ts_data_operations + ts_primary_models

# Filter - remain only operations, which were in available ones
primary_operations = list(set(ts_primary_operations).intersection(available_operations))
primary_operations = sorted(list(set(ts_primary_operations).intersection(available_operations)))
secondary_operations = available_operations
else:
primary_operations = available_operations
Expand Down

0 comments on commit 6ae6c98

Please sign in to comment.