Python3 安装 numpy 科学库 简单线性回归
2018-01-11 16:38
531 查看
[root@Singapore numpy]# wget https://pypi.python.org/packages/ee/66/7c2690141c520db08b6a6f852fa768f421b0b50683b7bbcd88ef51f33170/numpy-1.14.0.zip [root@Singapore numpy]# md5sum numpy-1.14.0.zip c12d4bf380ac925fcdc8a59ada6c3298 numpy-1.14.0.zip [root@Singapore numpy]# unzip numpy-1.14.0.zip [root@Singapore numpy]# cd numpy-1.14.0 [root@Singapore numpy-1.14.0]# cat INSTALL.rst.txt #安装说明 [root@Singapore numpy-1.14.0]# python3 setup.py build install --prefix /root/python/numpy #注意安装路径 [root@Singapore numpy-1.14.0]# echo "export PYTHONPATH=/root/python/numpy/lib/python3.6/site-packages" >> ~/.bashrc #注意安装路径 [root@Singapore numpy-1.14.0]# . ~/.bashrc [root@Singapore numpy-1.14.0]# echo $? 0 [root@Singapore numpy-1.14.0]#
写一个线性回归 试一试
[root@Singapore work.dir]# cat SimpleLineRegression.py #!/usr/bin/python3 import numpy as np def fitSLR(x,y): n = len(x) dinominator = 0 numerator = 0 for i in range(0, n): numerator += (x[i] - np.mean(x)) * (y[i] - np.mean(y)) dinominator +=(x[i] - np.mean(x)) ** 2 print ("numerator:", numerator) print ("dinominator", dinominator) b1 = numerator/float(dinominator) b0 = np.mean(y)/float(np.mean(x)) return b0, b1 def predict(x, b0, b1): return b0 + x*b1 x = [1,3,2,1,3] y = [14,24,18,17,27] b0, b1 = fitSLR(x,y) print ("intercept:", b0, " slope:", b1) x_test = 6 y_test = predict(6, b0, b1) print("y_test", y_test) [root@Singapore work.dir]# ./SimpleLineRegression.py numerator: 20.0 dinominator 4.0 intercept: 10.0 slope: 5.0 y_test 40.0 [root@Singapore work.dir]#
相关文章推荐
- python实现简单线性回归
- 7.1简单线性回归--python机器学习
- python下numpy不成功,请问有没有简单的安装方法?
- 简单线性回归的Python实现
- python数据分析——安装numpy,生成正态分布并简单分析
- [置顶] 【算法 机器学习】MATLAB、R、python三种编程语言实现简单线性回归算法比较
- 机器学习-线性回归python简单实现
- python的numpy模块安装不成功简单解决方法总结
- 用python实现简单线性回归
- Python3模块numpy的安装过程
- Python中安装numpy
- Ubuntu-Python2.7安装 scipy,numpy,matplotlib
- python安装numpy、scripy失败总结
- 关于python扩展库numpy_mkl和scipy的安装
- windows利用pip安装python包(numpy为例)
- Windows64 系统下Python、NumPy与matplotlib 安装方法
- 基于tensorflow的简单线性回归实例
- python 如何安装Numpy Scipy pandas等扩展库
- windows 安装python3.6(numpy,scipy,pandas,matplotlib,scikit-learn)
- 深度学习框架搭建之最新版Python及最新版numpy安装