Spark之python版机器学习算法--ipython notebook配置及测试
2017-03-21 23:09
239 查看
先说明一下我的环境配置:
操作系统:ubuntu14.04 64bit
spark2.0.0
hadoop 2.7.1
scala-2.11.8
python 2.7.6
java1.7.0
1安装pip工具
2 安装ipython
3 安装ipython notebook
4 启动ipython notebook
2.安装numpy库
3.安装scipy库
为了使用ipython notebook,需要如下配置。
1. 方法1
2 方法2
修改~/.bashrc文件,添加以下内容:
然后source ~/.bashrc,就可以通过启动 pyspark 来启动 IPython Notebook 了.
解压:
具体每个文件下,每一列的意义可参见 README.
接着用matplotlib的hist函数来创建一个直方图,以分析用户年龄的分布情况:
操作系统:ubuntu14.04 64bit
spark2.0.0
hadoop 2.7.1
scala-2.11.8
python 2.7.6
java1.7.0
1. 安装 ipython notebook
安装步骤:1安装pip工具
sudo apt-get install python-pip
2 安装ipython
sudo apt-get install ipython
3 安装ipython notebook
sudo apt-get install ipython-notebook
4 启动ipython notebook
ipython notebook
2. 其他python环境配置
1.为了方便画图安装matplotlib库sudo apt-get install python-matplotlib
2.安装numpy库
sudo apt-get install python-numpy
3.安装scipy库
sudo apt-get install python-scipy sudo apt-get install python-nose
3. pyspark调用ipython notebook
当spark配置成功后,直接调用pyspark即可打开spark的python接口。为了使用ipython notebook,需要如下配置。
1. 方法1
PYSPARK_DRIVER_PYTHON=ipython PYSPARK_DRIVER_PYTHON_OPTS='notebook' ./bin/pyspark
2 方法2
修改~/.bashrc文件,添加以下内容:
export PYSPARK_DRIVER_PYTHON=ipython export PYSPARK_DRIVER_PYTHON_OPTS=”notebook” (去处此参数,可调用 ipython)
然后source ~/.bashrc,就可以通过启动 pyspark 来启动 IPython Notebook 了.
4. 环境测试
MovieLens 100k数据集
从http://files.grouplens.org/datasets/movielens/ml-100k.zip可下载测试数据,得到 ml-100k.zip解压:
unzip ml-100k.zip
具体每个文件下,每一列的意义可参见 README.
接着用matplotlib的hist函数来创建一个直方图,以分析用户年龄的分布情况:
import matplotlib.pyplot as plt ages = user_fields.map(lambda x: int(x[1])).collect() plt.hist(ages, bins=20, color='lightblue', normed=True) fig = matplotlib.pyplot.gcf() fig.set_size_inches(16, 10) plt.show() #显示图像
相关文章推荐
- spark2.0下实现IPYTHON3.5开发,兼配置jupyter,notebook降低python开发难度
- Spark中的python shell交互界面Ipython和jupyter notebook
- 大数据基础(八) Spark 2.0.0下IPython和Notebook的安装配置
- Spark MLlib Python Notebook配置
- jupyter notebook 配置 scala、spark、python等环境
- python spark 配置
- Linux环境安装IPython配置python开发环境
- 配置Apache2.x 支持shell脚本和Python编写CGI程序+测试程序
- 使用Ipython notebook 学习《Python for Data Analysis》 在win7下搭建注意事项
- xmpp 服务器配置 open fire for windows 及 spark 测试
- Python,Jupyter Notebook,IPython快速安装教程
- [pySpark][笔记]spark tutorial from spark official site在ipython notebook 下学习pySpark
- 32位win7命令行创建SSL证书,配置IPython notebook服务器
- Python在云端编程之IPython notebook
- Eclipse配置Spark Python开发环境
- ipythonnotebook + spark
- IPython notebook的安装配置
- python IPYTHON nOTEbOOK
- 32位win7命令行创建SSL证书,配置IPython notebook服务器
- WIN7- selenium-python 自动化测试工具配置环境