skoot.utils.profile_estimator

skoot.utils.profile_estimator(estimator)[source][source]

Profile the timed functions of an estimator.

Get a list of runtimes for estimators that have used the timed_instance_method decorator. This is useful for diagnosing bottlenecks in a pipeline.

Parameters:

estimator : BaseEstimator

The estimator to profile.

Returns:

method_times : list or tuple

The list of method times.

Notes

This will only work if the attribute names provided for profiling end with “_time_”. All skoot estimators, for instance, save the attribute for the fit method as “fit_time_”, but a custom transformer that uses a different suffix may not be captured in the profiling process.

Examples

>>> from skoot.datasets import load_iris_df
>>> from skoot.preprocessing import SelectiveStandardScaler
>>> iris = load_iris_df(include_tgt=False)
>>> scl = SelectiveStandardScaler().fit(iris)
>>> profile_estimator(scl)  
(('fit_time_', 0.001055002212524414),)

Profiling also works on pipelines: >>> from sklearn.pipeline import Pipeline >>> from skoot.preprocessing.skewness import YeoJohnsonTransformer >>> from skoot.feature_selection import MultiCorrFilter >>> pipe = Pipeline([(‘scl’, SelectiveStandardScaler()), … (‘yj’, YeoJohnsonTransformer()), … (‘mcf’, MultiCorrFilter()) … ]).fit(iris) >>> profile_estimator(pipe) # doctest: +SKIP [(‘scl’, ((‘fit_time_’, 0.0016548633575439453),)),

(‘yj’, ((‘fit_time_’, 0.0282437801361084),))]

Examples using skoot.utils.profile_estimator