{"id":4634,"library":"mlxtend","title":"Machine Learning Library Extensions (mlxtend)","description":"mlxtend is a Python library of useful tools for machine learning tasks, offering a diverse range of functionality including feature selection, frequent pattern mining, model stacking, and plotting utilities. It builds upon popular libraries like scikit-learn, NumPy, and pandas. The current version is 0.24.0, and it maintains an active release cadence, frequently pushing updates for bug fixes and compatibility with its core dependencies.","status":"active","version":"0.24.0","language":"en","source_language":"en","source_url":"https://github.com/rasbt/mlxtend","tags":["machine learning","feature engineering","model stacking","ensemble learning","pattern mining","data preprocessing","visualization"],"install":[{"cmd":"pip install mlxtend","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core numerical operations, array handling.","package":"numpy","optional":false},{"reason":"Scientific computing, statistical functions.","package":"scipy","optional":false},{"reason":"Machine learning algorithms, core API compatibility.","package":"scikit-learn","optional":false},{"reason":"Data manipulation, DataFrame handling.","package":"pandas","optional":false},{"reason":"Plotting and visualization utilities.","package":"matplotlib","optional":false},{"reason":"Parallel computing for feature selectors.","package":"joblib","optional":false}],"imports":[{"symbol":"StackingClassifier","correct":"from mlxtend.classifier import StackingClassifier"},{"symbol":"SequentialFeatureSelector","correct":"from mlxtend.feature_selection import SequentialFeatureSelector"},{"symbol":"plot_decision_regions","correct":"from mlxtend.plotting import plot_decision_regions"},{"symbol":"TransactionEncoder","correct":"from mlxtend.preprocessing import TransactionEncoder"},{"symbol":"apriori","correct":"from mlxtend.frequent_patterns import apriori"},{"symbol":"association_rules","correct":"from mlxtend.frequent_patterns import association_rules"}],"quickstart":{"code":"import numpy as np\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.tree import DecisionTreeClassifier\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.datasets import make_classification\nfrom mlxtend.classifier import StackingClassifier\n\n# Generate a synthetic dataset\nX, y = make_classification(n_samples=1000, n_features=20, n_informative=10, n_redundant=10, random_state=42)\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)\n\n# Initialize base classifiers\nclf1 = DecisionTreeClassifier(random_state=42)\nclf2 = LogisticRegression(random_state=42, solver='liblinear')\n\n# Initialize meta-classifier\nlr = LogisticRegression(random_state=42, solver='liblinear')\n\n# Initialize StackingClassifier\nsclf = StackingClassifier(classifiers=[clf1, clf2], meta_classifier=lr, use_probas=True, verbose=0)\n\n# Train and evaluate\nsclf.fit(X_train, y_train)\nscore = sclf.score(X_test, y_test)\nprint(f\"Stacking Classifier Test Accuracy: {score:.4f}\")","lang":"python","description":"This quickstart demonstrates how to use the `StackingClassifier` to combine multiple base models (Decision Tree, Logistic Regression) with a meta-classifier (Logistic Regression) to improve prediction accuracy. It uses a synthetic dataset from scikit-learn for illustration."},"warnings":[{"fix":"Always check mlxtend's release notes for compatibility updates before upgrading `scikit-learn` or `pandas`. Upgrade `mlxtend` to the latest version to ensure full compatibility, or pin dependency versions carefully.","message":"mlxtend frequently updates to maintain compatibility with newer versions of `scikit-learn` and `pandas`. Older mlxtend versions may not work correctly with the latest releases of these core dependencies, leading to API errors or unexpected behavior. For example, `scikit-learn`'s `set_output` method integration and changes to `LinearRegression`'s `normalize` parameter required updates.","severity":"breaking","affected_versions":"<0.24.0"},{"fix":"Upgrade mlxtend to version 0.23.4 or newer to ensure compatibility with recent NumPy versions that have removed these aliases.","message":"NumPy's deprecated type aliases like `np.float_`, `np.int_`, `np.bool_` were removed in recent NumPy versions. mlxtend versions prior to v0.23.4 might use these aliases, causing `AttributeError` in newer NumPy environments.","severity":"breaking","affected_versions":"<0.23.4"},{"fix":"Upgrade mlxtend to version 0.23.1 or newer. This version specifically addresses the `distutils` dependency issue for Python 3.12+.","message":"Python 3.12+ removed the `distutils` package. Older mlxtend versions depending on `distutils` might fail to install or run on Python 3.12 and above.","severity":"breaking","affected_versions":"<0.23.1"},{"fix":"If using `StackingCVClassification` or `StackingCVRegression` with `scikit-learn >= 1.4`, ensure mlxtend is at least v0.24.0 to correctly pass `meta_features`.","message":"The `meta_features` handling in `StackingCVClassification` and `StackingCVRegression` was modified to ensure compatibility with `scikit-learn` versions 1.4 and above.","severity":"breaking","affected_versions":"<0.24.0"},{"fix":"Upgrade to mlxtend v0.23.4 or newer if you are using `mlxtend.frequent_patterns.association_rules`. Test your code to ensure the updated logic aligns with expected results.","message":"The behavior and internal workings of `association_rules` underwent fixes and improvements in recent versions. Code relying on specific older behaviors or encountering issues with rule generation should be re-evaluated.","severity":"gotcha","affected_versions":"All versions <0.23.4"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}