python机器学习包mlxtend的安装和配置
来源:互联网 发布:px4飞控源码 百度云 编辑:程序博客网 时间:2024/06/05 19:22
今天看到了mlxtend的包,看了下example集成得非常简洁。还有一个吸引我的地方是自带了一些data直接可以用,省去了自己造数据或者找数据的处理过程,所以决定安装体验一下。
依赖环境
首先,sudo pip install mlxtend 得到基础环境。
然后开始看看系统依赖问题的解决。大致看了下基本都是python科学计算用的那几个经典的包,主要是numpy,scipy,matplotlib,sklearn这些。
LINUX环境下的话,一般这些都比较好装pip一般都能搞定。
这里要说的一点是matplotlib的话,pip装的时候提示我的几个问题是png和一个叫Freetype的包被需要,但是装的时候又出现问题。所以matplotlib最后选择用
sudo apt-get install python-matplotlib
直接解决依赖问题。
同样的情况对于scipy也是一样,用
sudo apt-get install python-scipy
解决。
示例代码
import numpy as npimport matplotlib.pyplot as pltimport matplotlib.gridspec as gridspecimport itertoolsfrom sklearn.linear_model import LogisticRegressionfrom sklearn.svm import SVCfrom sklearn.ensemble import RandomForestClassifierfrom mlxtend.classifier import EnsembleVoteClassifierfrom mlxtend.data import iris_datafrom mlxtend.evaluate import plot_decision_regions# Initializing Classifiersclf1 = 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')# Loading some example dataX, y = iris_data()X = X[:,[0, 2]]# Plotting Decision Regionsgs = gridspec.GridSpec(2, 2)fig = plt.figure(figsize=(10, 8))for clf, lab, grd in zip([clf1, clf2, clf3, eclf], ['Logistic Regression', 'Random Forest', 'Naive Bayes', '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()
之后就可以来跑一下这个示例代码。
matplot结果如图:
之后就可以开始玩了~!
附:linux下python科学计算的经典的包的一个总和的命令:
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
1 0
- python机器学习包mlxtend的安装和配置
- 在win7 32位系统中安装配置Python的机器学习包scikit-learn
- 安装python,python下的机器学习包
- python中安装机器学习(sklearn)必要的包和模块
- 安装Python的机器学习包Sklearn 出错解决方法
- python与机器学习(1)--python的安装配置
- Ubuntu安装Python机器学习包
- 机器学习之Python安装和numpy配置
- ubuntu中安装机器学习包(python)和安装pycharm
- win7/win10 64位系统中安装python中有关机器学习对应的包和库
- Python机器学习开发环境安装配置
- 【机器学习】高斯过程python包安装过程
- windows7 32位如何安装python 的scikiet-learn机器学习包问题
- linux下python的机器学习包scikit-learn(包含numpy、scipy等)安装
- Python机器学习包scikit-learn安装步骤,包含了各种可能遇到的错误!!!
- window下安装Python的机器学习包numpy+scipy+matplotlib+scikit-learn
- 在windows上安装python的机器学习包numpy scipy scikit_learn matplotlib
- window下安装Python的机器学习包numpy+scipy+matplotlib+scikit-learn
- epoll详细工作原理
- 使用python创建数据库表空间
- machine-learning第七周 上机作业
- freemarker assign 声明变量,boolean,date,date日期格式转换
- JSP的结构和生命周期
- python机器学习包mlxtend的安装和配置
- 数组中只出现一次的数字
- PAT1002.写出这个数
- 快速掌握Lua 5.3 —— 环境
- atomic提供原子操作的类
- hdu 2078
- 一个资深iOS开发者对于React Native的看法
- Mongo中上传下载图片
- web.xml配置详解