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

[Bug]: sporadic multiobj optimization failure on boosting pipelines #1337

Closed
Lopa10ko opened this issue Sep 25, 2024 · 0 comments · Fixed by #1320
Closed

[Bug]: sporadic multiobj optimization failure on boosting pipelines #1337

Lopa10ko opened this issue Sep 25, 2024 · 0 comments · Fixed by #1320
Assignees
Labels
bug Something isn't working

Comments

@Lopa10ko
Copy link
Collaborator

Lopa10ko commented Sep 25, 2024

Current Behavior

Getting ValueError: Length of values (0) does not match length of index (606) on boosting pipelines predict stage in run_classification_multiobj_example

Steps to Reproduce

2024-09-24_21-25-09_pipeline_saved.zip

import pandas as pd

from fedot import Fedot
from fedot.core.pipelines.pipeline import Pipeline
from fedot.core.utils import fedot_project_root


def run_classification_multiobj_example(visualization=False, timeout=1, with_tuning=True):
    train_data = pd.read_csv(f'{fedot_project_root()}/examples/data/Hill_Valley_with_noise_Training.data')
    test_data = pd.read_csv(f'{fedot_project_root()}/examples/data/Hill_Valley_with_noise_Testing.data')
    target = test_data['class']
    del test_data['class']
    problem = 'classification'

    metric_names = ['f1', 'node_number']
    initial_assumption = Pipeline().load('./2024-09-24_21-25-09_pipeline_saved')
    auto_model = Fedot(problem=problem, timeout=timeout, preset='best_quality',
                       metric=metric_names,
                       with_tuning=with_tuning,
                       initial_assumption=initial_assumption)
    auto_model.fit(features=train_data, target='class')
    prediction = auto_model.predict_proba(features=test_data)
    print(auto_model.get_metrics(target))

    if visualization:
        auto_model.plot_prediction()
        auto_model.plot_pareto()

    return prediction


if __name__ == '__main__':
    run_classification_multiobj_example(timeout=0.1, with_tuning=False)

Possible solution

Check whether data.target is set to an empty sequence:

@staticmethod
def convert_to_dataframe(data: Optional[InputData], identify_cats: bool):
dataframe = pd.DataFrame(data=data.features, columns=data.features_names)
if data.target is not None:
dataframe['target'] = np.ravel(data.target)
else:
# TODO: temp workaround in case data.target is set to None intentionally
# for test.integration.models.test_model.check_predict_correct
dataframe['target'] = np.zeros(len(data.features))
if identify_cats and data.categorical_idx is not None:
for col in dataframe.columns[data.categorical_idx]:
dataframe[col] = dataframe[col].astype('category')
if data.numerical_idx is not None:
for col in dataframe.columns[data.numerical_idx]:
dataframe[col] = dataframe[col].astype('float')
return dataframe.drop(columns=['target']), dataframe['target']

Context

failed integration tests run https://github.com/aimclub/FEDOT/actions/runs/11013973383
related to #1316

@Lopa10ko Lopa10ko added the bug Something isn't working label Sep 25, 2024
@Lopa10ko Lopa10ko self-assigned this Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant