v0.4.0
Modernizes lofo-importance with PEP 621 packaging, leaner core dependencies, joblib-based parallelism, Rich table output, full type annotations, and improved default model inference (#67).
Highlights & New Features
- Rich summary table in
plot_importance: Addedkind="table"to render a color-coded Rich table with mean ± std importance and per-foldmin / med / maxsummaries.plot_importancenow also returns the created MatplotlibAxesor RichTable. joblibparallelism: Replaced the custommultiprocessing.Pool/Queueimplementation withjoblib.Parallel, adding support forn_jobs=-1(all CPUs) in bothLOFOImportanceandFLOFOImportance.- Deterministic parallel FLOFO:
FLOFOImportance.get_importancenow derives per-feature random seeds fromrandom_stateand avoids shared DataFrame mutation, making parallel and sequential runs produce matching results. - Improved default model inference:
infer_modelnow usessklearn.utils.multiclass.type_of_targetto detect both binary and multiclass classification targets (string/categorical targets and low-cardinality integer targets) while keeping high-cardinality integer targets as regression. Default LightGBM models now useverbose=-1and guardmin_child_samplesto be at least1. - Full type annotations (PEP 561): Added type hints across the codebase, exported
__all__andlofo.__version__, and includedlofo/py.typed.
Packaging & Dependencies
- Migrated to
pyproject.toml: Replacedsetup.py,requirements.txt, andMANIFEST.inwith PEP 621 metadata inpyproject.toml. - Removed
networkxdependency: Replacednetworkxconnected components inDatasetauto-grouping withscipy.sparse.csgraph.connected_components. - Optional extras (
[all]and[dev]): Movedlightgbm,matplotlib, andrichto optional dependencies with clearImportErrormessages if missing:pip install lofo-importance # core dependencies only pip install "lofo-importance[all]" # includes lightgbm, matplotlib, rich
Improvements & Fixes
- Matplotlib compatibility: Updated
plot_importance(..., kind="box")to adapt to newer Matplotlibboxplotparameter names (orientation/tick_labelsvsvert/labels). - Deterministic feature ordering:
Datasetnow preserves input order for ungrouped features and returns sorted lists whenauto_group_threshold=0.0. - Consistent sparse output:
Dataset.getXconverts horizontally stacked sparse feature groups tocsr_matrix(.tocsr()). - More specific exceptions: Replaced generic
Exceptionraises withTypeErrorandValueErrorinDatasetandFLOFOImportance. - Docs & tests: Updated
README.md,LOFOImportance Example.ipynb, and CI workflow; added test coverage for plotting, multiclass inference, missing LightGBM errors,n_jobs=-1, and parallel FLOFO equivalence.
Migration Notes
- Python 3.9+ required: Minimum supported Python version is now
3.9(tested up to3.13). lightgbmis no longer installed by default: If you rely on the default LightGBM model (model=None) orplot_importance, installpip install "lofo-importance[all]"(or installlightgbm/matplotlib/richindividually).