Skip to content

The KNN trainers' metric and metric_params cannot be given a working value #7593

Description

@kz930

What happened?

SklearnAdvancedKNNParameters pairs each hyperparameter with the Python callable that converts the user's text. Two of the six name one that cannot produce what scikit-learn accepts, so choosing either fails the run whatever is typed. They sit in the same dropdown as the four that work.

metric is declared int, so the operator emits metric = int(value). Its values are words like minkowski, which raises:

metric = minkowski

A number converts cleanly and scikit-learn rejects the result:

metric = 3

What converts is not accepted and what is accepted does not convert. One word fixes it: str, as weights and algorithm beside it already are.

metric_params is a different problem. It wants a dict, and none of the converters on offer — int, float, str — returns one, so no naming choice helps. A well-formed {"p": 2} arrives as the string '{"p": 2}'. Either the field needs a way to carry structured input, or it should leave the dropdown.

Both affect the classifier and the regressor.

How to reproduce?

Add a KNN Classifier Trainer with a numeric table on its training port and any table on its parameter port, set the ground truth and features, then add one hyperparameter row and pick metric. Give it minkowski, then 3. Picking p, weights, algorithm or leaf_size instead runs fine on the same workflow.

Version/Branch

1.3.0-incubating-SNAPSHOT (main)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions