Skip to content

[DOC] Add usage examples to core function docstrings (Fixes #1538)#1689

Open
Abhishek9639 wants to merge 5 commits intoopenml:mainfrom
Abhishek9639:doc/add-usage-examples-to-core-docstrings
Open

[DOC] Add usage examples to core function docstrings (Fixes #1538)#1689
Abhishek9639 wants to merge 5 commits intoopenml:mainfrom
Abhishek9639:doc/add-usage-examples-to-core-docstrings

Conversation

@Abhishek9639
Copy link

@Abhishek9639 Abhishek9639 commented Feb 23, 2026

[DOC] Add usage examples to core function docstrings. Closes #1538

Metadata

Details

This PR adds usage examples to selected public core functions in the project
to improve developer experience and documentation clarity.

The following functions were updated with example usage sections:

  • get_dataset()
  • get_datasets()
  • get_task()
  • run_model_on_task()
  • get_suite()
  • get_study()
  • create_study()

Why this change is necessary:
Examples in docstrings help users understand how to use the functions directly
from IDE hover tooltips and improve auto-generated documentation.

Reproduction:
No bug reproduction is required. This is a documentation enhancement.

Additional Notes:
Only docstrings were modified. No functional code changes were made.

@Abhishek9639 Abhishek9639 force-pushed the doc/add-usage-examples-to-core-docstrings branch 2 times, most recently from 66b3fc9 to 7126344 Compare February 23, 2026 17:45
@Abhishek9639
Copy link
Author

Screenshot

Copy link
Collaborator

@geetu040 geetu040 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Abhishek9639 Abhishek9639 force-pushed the doc/add-usage-examples-to-core-docstrings branch from c93d964 to 2e455d1 Compare February 23, 2026 18:17
@Abhishek9639
Copy link
Author

Abhishek9639 commented Feb 23, 2026

Hii @geetu040 and @fkiraly,
Fixed the code quality checks. All pre-commit checks are now passing.
Please review it.

Copy link
Collaborator

@geetu040 geetu040 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice. Left comment for one example, otherwise looks all good and it covers all the mentioned functions in the issue.

>>> from sklearn.tree import DecisionTreeClassifier # doctest: +SKIP
>>> clf = DecisionTreeClassifier() # doctest: +SKIP
>>> task = openml.tasks.get_task(1) # doctest: +SKIP
>>> run = openml.runs.run_model_on_task(clf, task) # doctest: +SKIP
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this currently raises the following error, can you look into it?

ValueError: could not convert string to float: '?'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I’ll take a look.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say a better example would be to use a task with a more suitable dataset, may be openml.tasks.get_task(6) and keep using DecisionTreeClassifier, since it's more common as an example

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion.
That makes sense using openml.tasks.get_task(6) with DecisionTreeClassifier will make the example clearer and more standard.
I’ll update the example accordingly and push the changes shortly.
Thanks

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

.DS_Store Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

- Use HistGradientBoostingClassifier instead of DecisionTreeClassifier
  (fixes ValueError with missing values in task 1)
- Remove .DS_Store
- Remove tests/files/misc/features_with_whitespaces.xml.pkl
@Abhishek9639 Abhishek9639 force-pushed the doc/add-usage-examples-to-core-docstrings branch from 5a8956d to c155709 Compare March 1, 2026 16:53
@Abhishek9639
Copy link
Author

@geetu040,
Addressed all feedback,
Fixed run_model_on_task example using HistGradientBoostingClassifier instead of DecisionTreeClassifier (it handles missing values natively, so no more ValueError: could not convert string to float) Removed .DS_Store and features_with_whitespaces.xml.pkl
If any further changes are needed, please let me know.
Please review

Copy link
Collaborator

@geetu040 geetu040 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Abhishek9639
Copy link
Author

Abhishek9639 commented Mar 1, 2026

@geetu040,
Updated as suggested now using openml.tasks.get_task(6) with DecisionTreeClassifier. Also removed .DS_Store and features_with_whitespaces.xml.pkl as requested. All pre-commit checks are passing. Please review
If any other changes are needed. please let me know.
Thanks

Copy link
Collaborator

@geetu040 geetu040 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@fkiraly please merge.

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.

[DOC] Add Usage Examples to Core Function Docstrings

3 participants