Skip to content

[FIX] : Add substring fallback for tag suggestions in list_estimators#366

Open
Rohitstwt wants to merge 1 commit into
sktime:mainfrom
Rohitstwt:fix/tag-suggestion-substring-fallback
Open

[FIX] : Add substring fallback for tag suggestions in list_estimators#366
Rohitstwt wants to merge 1 commit into
sktime:mainfrom
Rohitstwt:fix/tag-suggestion-substring-fallback

Conversation

@Rohitstwt

Copy link
Copy Markdown

Reference Issues/PRs

Related to #35 (early adopter feedback - tag suggestion returning None for partial key matches)

What does this implement/fix?

When an invalid tag key like pred_int is passed to list_estimators_tool, the existing code returns suggestions: None even though capability:pred_int exists in the registry.

Root cause: difflib.get_close_matches scores pred_int vs capability:pred_int below the 0.6 cutoff because the capability: prefix makes them too dissimilar.

Before:

list_estimators_tool(tags={"pred_int": True})
# {'success': False, 'suggestions': {'pred_int': None}}

After:

list_estimators_tool(tags={"pred_int": True})
# {'success': False, 'suggestions': {'pred_int': ['capability:pred_int', 'capability:pred_int:insample']}}

Fix: adds a _suggest_tag helper that first tries difflib, then falls back to substring matching when difflib finds nothing.

Also fixes the docstring which listed only 6 of 9 valid task types (missing parameter_estimation, splitting, network).

Does your contribution introduce a new dependency? If yes, which one?

No. Uses only difflib from the Python standard library, which was already imported.

What should a reviewer concentrate their feedback on?

  • The _suggest_tag helper in src/sktime_mcp/tools/list_estimators.py and whether the substring fallback logic is sound
  • The 7 new tests in tests/test_list_estimators.py covering invalid task errors, invalid tag errors, substring suggestions, and valid inputs passing cleanly

Any other comments?

Discovered while doing early adopter testing as part of #35.

PR checklist

For all contributions
  • I've added myself to the list of contributors.
  • Optionally, I've updated sktime's CODEOWNERS to receive notifications about future changes to these files.
  • I've added unit tests and made sure they pass locally.

When an invalid tag key like 'pred_int' is passed, difflib alone fails
to suggest 'capability:pred_int' because the prefix changes similarity
score below the cutoff threshold.

Adds _suggest_tag helper that first tries difflib, then falls back to
substring matching so 'pred_int' correctly suggests
['capability:pred_int', 'capability:pred_int:insample'].

Also fixes docstring listing only 6 of 9 valid task types.

Adds tests/test_list_estimators.py with 7 tests covering invalid task
errors, invalid tag errors, substring suggestions, and valid inputs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant