ibis-project / ibis-ml

IbisML is a library for building scalable ML pipelines using Ibis.
https://ibis-project.github.io/ibis-ml/
Apache License 2.0
96 stars 13 forks source link

feat(core): implement `Recipe` and `Step` printing #101

Closed deepyaman closed 6 months ago

deepyaman commented 6 months ago

To test:

>>> # Create test pipeline
>>> from sklearn.feature_selection import SelectKBest
>>> from sklearn.pipeline import Pipeline
>>> from sklearn.svm import SVC
>>> import ibis_ml as ml
>>> 
>>> imputer = ml.ImputeMean(ml.numeric())
>>> scaler = ml.ScaleStandard(ml.numeric())
>>> rec = ml.Recipe(imputer, scaler)
>>> subpipe = Pipeline(steps=[("select", SelectKBest(k=2)), ("svc", SVC())])
>>> pipe = Pipeline([("rec", rec), ("sub", subpipe)])
>>> 
>>> # Pretty-print pipeline
>>> from sklearn.utils._pprint import _EstimatorPrettyPrinter
>>> 
>>> # Default behavior (indent at name) looks OK
>>> pp = _EstimatorPrettyPrinter(compact=False, indent=1, indent_at_name=True)
>>> print(pp.pformat(pipe))
Pipeline(steps=[('rec',
                 Recipe(ImputeMean(numeric()), ScaleStandard(numeric()))),
                ('sub',
                 Pipeline(steps=[('select', SelectKBest(k=2)),
                                 ('svc', SVC())]))])
>>>
>>> # `indent_at_name=False` looks like it also works
>>> pp = _EstimatorPrettyPrinter(compact=False, indent=1, indent_at_name=False)
>>> print(pp.pformat(pipe))
Pipeline(steps=[('rec', Recipe(ImputeMean(numeric()), ScaleStandard(numeric()))),
        ('sub',
         Pipeline(steps=[('select', SelectKBest(k=2)), ('svc', SVC())]))])
codecov-commenter commented 6 months ago

Codecov Report

Attention: Patch coverage is 65.97938% with 66 lines in your changes are missing coverage. Please review.

Project coverage is 84.61%. Comparing base (fabc3c4) to head (1379e3c).

Files Patch % Lines
ibis_ml/utils/_pprint.py 58.49% 66 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #101 +/- ## ========================================== - Coverage 86.36% 84.61% -1.76% ========================================== Files 23 25 +2 Lines 1658 1852 +194 ========================================== + Hits 1432 1567 +135 - Misses 226 285 +59 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.