机器学习sklearn库的使用--部署环境(python2.7 windows7 64bit)
2017-07-03 18:14
661 查看
最近在学习机器学习的内容,难免地,要用到Scikit-learn(sklearn,下同)这一机器学习包。为了使用sklearn库,我们需要安装python2.7,pip install工具,numpy+mkl、scipy、pandas、sklearn等开源包。其中numpy+mkl和scipy安装比较费劲,不能通过pip install工具直接安装。
各文件下载链接:
Python2.7.13 : Python2.7.13
numpy+mkl : numpy‑1.11.3+mkl‑cp27‑cp27m‑win_amd64.whl
Scipy:scipy‑0.19.1‑cp27‑cp27m‑win_amd64.whl
下载上述文件之后首先按照步骤安装Python27。重点来了,安装numpy+mkl,下面介绍两种方法:
进入到Python27安装目录,比如我的是:G:\Python\Scripts,在cmd界面进入到该目录下。转3
在环境变量path中加分号添加pip所在目录G:\Python\Scripts,保存后退出。转3
然后输入以下指令安装pip工具:
此时很可能出现如下提示信息:
numpy‑1.11.3+mkl‑cp27‑cp27m‑win_amd64.whl is not a supported wheel on this platform
Storing debug log for failure in C:\Users\Administrator\pip\pip.log网上研究后发现是由于pip安装工具没有更新的原因,所以使用pip指令更新:
然后输入在命令行下输入控制指令:
然后在Python27的Shell中输入
如果输出没有错误,说明安装没有问题,继续安装Scipy。
在命令行输入指令:
继续安装sklearn和panda,在命令行输入指令:
安装完成后在Shell中输入指令:
如果输出没有错误,至此,sklearn库安装完成。
下面以简单的鸢尾花数据集做一个简单的测试,代码如下:
运行结果:
测试成功,整个安装过程结束。
各文件下载链接:
Python2.7.13 : Python2.7.13
numpy+mkl : numpy‑1.11.3+mkl‑cp27‑cp27m‑win_amd64.whl
Scipy:scipy‑0.19.1‑cp27‑cp27m‑win_amd64.whl
下载上述文件之后首先按照步骤安装Python27。重点来了,安装numpy+mkl,下面介绍两种方法:
进入到Python27安装目录,比如我的是:G:\Python\Scripts,在cmd界面进入到该目录下。转3
在环境变量path中加分号添加pip所在目录G:\Python\Scripts,保存后退出。转3
然后输入以下指令安装pip工具:
easy_install.exe pip pip install wheel pip install [numpy+mkl目录]
此时很可能出现如下提示信息:
numpy‑1.11.3+mkl‑cp27‑cp27m‑win_amd64.whl is not a supported wheel on this platform
Storing debug log for failure in C:\Users\Administrator\pip\pip.log网上研究后发现是由于pip安装工具没有更新的原因,所以使用pip指令更新:
pip install --upgrade setuptools pip install --upgrade pip
然后输入在命令行下输入控制指令:
pip install wheel pip install [numpy+m [Scipy目录]kl目录]
然后在Python27的Shell中输入
import numpy
如果输出没有错误,说明安装没有问题,继续安装Scipy。
在命令行输入指令:
pip install [scipy目录],在Shell中输入指令
import scipy,如果输出没有错误,说明安装没有问题。
继续安装sklearn和panda,在命令行输入指令:
pip install sklearn pip install pandas
安装完成后在Shell中输入指令:
import sklearn import pandas
如果输出没有错误,至此,sklearn库安装完成。
下面以简单的鸢尾花数据集做一个简单的测试,代码如下:
from sklearn.datasets import load_iris from sklearn.preprocessing import Normalizer from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score iris = load_iris() data = Normalizer().fit_transform(iris.data) #normalize the data labels = iris.target clf = DecisionTreeClassifier() X_train,X_test,y_train,y_test = train_test_split(data,labels,test_size=0.2) clf.fit(X_train,y_train) y_pred = clf.predict(X_test) accuracy = accuracy_score(y_test,y_pred) print accuracy
运行结果:
>>> 0.866666666667
测试成功,整个安装过程结束。
相关文章推荐
- 【Android】【FAQ】解决windows7 64bit系统下部署android开发环境使用Android SDK Manager的failed to fetch问题
- 使用Anaconda3建立虚拟独立的python2.7环境
- win10 64位系统下 python2.7环境 scrapy的部署
- python之Scrapyd部署爬虫项目(使用虚拟环境)
- win10下caffe环境搭建: win10 + vs2013 + caffe + CUDA 7.5 + cudnn v4 + Anaconda2 (python 2.7) 目前未使用GPU
- Ubuntu14.04安装pycharm用于Python开发环境部署,并且支持pycharm使用中文输入
- 使用Vagrant在Windows7下部署开发环境
- 使用Docker搭建Django,Nginx,R,Python部署环境
- 使用Anaconda3建立虚拟独立的python2.7环境方法
- python2.7虚拟环境virtualenv安装及使用
- 使用Docker搭建Django,Nginx,R,Python部署环境
- pycharm中使用anaconda部署python环境
- Python web框架Django学习(1)——在win7 64bit下配置开发环境Django:一个可以使Web开发工作愉快并且高效的Web开发框架。 使用Django,使你能够以最小的代价构建和
- Windows7下搭建Python2.7环境
- 使用python脚本代码本地测试环境部署和启动 V0.1
- 使用Docker搭建Django,Nginx,R,Python部署环境的方法
- Windows(64bit)下Python2.7环境安装paramiko模块
- Python使用wxPython、py2exe编写桌面程序-部署环境
- Ubuntu14.04安装pycharm用于Python开发环境部署,并且支持pycharm使用中文输入
- Python2.7环境部署和pip安装以及模块安装