这个项目能做什么

Mlxtend(机器学习扩展)是一个 Python 库,为日常数据科学任务提供实用工具。它主要用于: - 集成方法,如堆叠和投票分类器 - 特征选择和特征提取技术 - 可视化功能(如决策区域、混淆矩阵) - 模型分析的绘图辅助工具 - 频繁模式挖掘,包括用于关联规则挖掘的 Apriori 算法 Sebastian Raschka 2014-2026 ## 链接 - **文档:** [https://rasbt.github.io/mlxtend](https://rasbt.github.io/mlxtend) - PyPI:[https://pypi.python.org/pypi/mlxtend](https://pypi.python.org/pypi/mlxtend) - 更新日志:[https://rasbt.github.io/mlxtend/CHANGELOG](https://rasbt.github.io/mlxtend/CHANGELOG) - 贡献指南:[https://rasbt.github.io/mlxtend/CONTRIBUTING](https://rasbt.github.io/mlxtend/CONTRIBUTING) - 问题?请参阅 [GitHub Discussions 板块](https://github.com/rasbt/mlxtend/discussions) ## 安装 mlxtend #### 使用 uv 要将 mlxtend 添加到 uv 管理的项目中,请运行 ```bash uv add mlxtend ``` 如果只需一次性使用而不影响当前项目,可运行 ```bash uv run --with mlxtend python -c "import mlxtend; print(mlxtend.__version__)" ``` #### 开发版本 PyPI 上的 mlxtend 版本可能总是滞后一步;您可以通过执行以下命令从 GitHub 仓库安装最新的开发版本 ```bash uv add "mlxtend @ git+https://github.com/rasbt/mlxtend.git" ``` 或者,您可以从 https://github.com/rasbt/mlxtend fork 仓库,并通过本地签出运行 mlxtend: ```bash git clone https://github.com/<your_username>/mlxtend.git cd mlxtend uv sync --group dev uv run python -c "import mlxtend; print(mlxtend.__version__)" ``` ## 示例 ```python import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec import itertools from sklearn.linear_model import LogisticRegression from sklearn.svm import SVC from sklearn.ensemble import RandomForestClassifier from mlxtend.classifier import EnsembleVoteClassifier from mlxtend.data import iris_data from mlxtend.plotting import plot_decision_regions # 初始化分类器 clf1 = LogisticRegression(random_state=0) clf2 = RandomForestClassifier(random_state=0) clf3 = SVC(random_state=0, probability=True) eclf = EnsembleVoteClassifier(clfs=[clf1, clf2, clf3], weights=[2, 1, 1], voting='soft') # 加载示例数据 X, y = iris_data() X = X[:,[0, 2]] # 绘制决策区域 gs = gridspec.GridSpec(2, 2) fig = plt.figure(figsize=(10, 8)) for clf, lab, grd in zip([clf1, clf2, clf3, eclf], ['Logistic Regression', 'Random Forest', 'RBF kernel SVM', 'Ensemble'], itertools.product([0, 1], repeat=2)): clf.fit(X, y) ax = plt.subplot(gs[grd[0], grd[1]]) fig = plot_decision_regions(X=X, y=y, clf=clf, legend=2) plt.title(lab) plt.show() ``` 如果您在科学研究中使用了 mlxtend,请考虑引用以下 DOI: ``` @article{raschkas_2018_mlxtend, author = {Sebastian Raschka}, title = {MLxtend: Providing machine learning and data science utilities and extensions to Python’s scientific computing stack}, journal = {The Journal of Open Source Software}, volume = {3}, number = {24}, month = apr, year = 2018, publisher = {The Open Journal}, doi = {10.21105/joss.00638}, url = {https://joss.theoj.org/papers/10.21105/joss.00638} } ``` - Raschka, Sebastian (2018) MLxtend: Providing machine learning and data science utilities and extensions to Python's scientific computing stack. J Open Source Softw 3(24). ## 许可证 - 本项目采用宽松的 BSD 新开源许可证发布([LICENSE-BSD3.txt](https://github.com/rasbt/mlxtend/blob/master/LICENSE-BSD3.txt)),可用于商业目的。不提供任何担保,包括适销性或特定用途适用性的担保。 - 此外,您可以根据知识共享署名 4.0 国际许可协议的条款和条件,使用、复制、修改和重新分发本发行版中包含的所有艺术创意作品(图表和图片)。详见 [LICENSE-CC-BY.txt](https://github.com/rasbt/mlxtend/blob/master/LICENSE-CC-BY.txt) 文件。(由 matplotlib 生成的计算机图形等受上述 BSD 许可证约束)。 ## 联系 通过 [GitHub Discussions 频道](https://github.com/rasbt/mlxtend/discussions)提问是最佳方式。如果遇到使用 bug,请直接使用 [GitHub Issue 追踪器](https://github.com/rasbt/mlxtend/issues)。