Skip to content

[BUG] Benchmarking collapses multiple estimators of the same class into one result row #297

Description

@ashum9

Describe the bug

Benchmarking.run() stores results in a dict keyed only by estimator.__class__.__name__, so benchmarking two estimators of the same class silently overwrites the first result with the second.

This means hyperparameter comparisons within the same estimator family are not represented correctly in the summary table.

Relevant code:

  • pyaptamer/benchmarking/_base.py (est_name = estimator.__class__.__name__ and results[est_name] = est_scores)

Minimal reproduction

import numpy as np
from sklearn.dummy import DummyClassifier
from sklearn.metrics import accuracy_score
from pyaptamer.benchmarking import Benchmarking

X = np.array([[0], [1], [0], [1], [0], [1], [0], [1]])
y = np.array([0, 1, 0, 1, 0, 1, 0, 1])

bench = Benchmarking(
    estimators=[
        DummyClassifier(strategy="most_frequent"),
        DummyClassifier(strategy="stratified", random_state=0),
    ],
    metrics=[accuracy_score],
    X=X,
    y=y,
    cv=2,
)

print(bench.run())

Current behavior:

  • only one DummyClassifier row is returned

Expected behavior:

  • both estimators should appear in the results under distinct labels
  • distinct estimator classes should keep their original class-name labels

Proposed fix

Generate stable display names for estimators before running CV, and disambiguate duplicate class names with a deterministic suffix such as [1], [2], etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions