这篇文章主要讲解了“Python算法库的安装过程”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Python算法库的安装过程”吧!
专注于为中小企业提供成都网站设计、做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业吉木乃免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上1000家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。Python算法库包含以下几个程序包,官方下载地址:
https://pypi.python.org/pypi
下载的算法库要与安装的Python版本一致,比如安装的是Python3.7-64位版本,下载的算法库要为cp37...win_amd64,否则安装时会报错。Python算法库的安装顺序为:NumPy->SciPy->Matplotlib->Scikit-Learn。
NumPy:
array processing for numbers, strings, records, and objects.
NumPy是一个开源的Python科学计算库。使用NumPy,就可以很自然地使用数组和矩阵。NumPy包含很多实用的数学函数,涵盖线性代数运算、傅里叶变换和随机数生成等功能。NumPy通常与SciPy和Matplotlib一起使用,这种组合广泛用于替代MatLab(一个流行的技术计算平台),Python作为MatLab的替代方案,现在被视为一种更加现代和完整的编程语言。
安装:
C:\Program Files\Python37\Scripts>pip install d:\numpy-1.15.2-cp37-none-win_amd64.whl
Processing d:\numpy-1.15.2-cp37-none-win_amd64.whl
Installing collected packages: numpy
Successfully installed numpy-1.15.2
SciPy:
Scientific Library for Python.
SciPy是一个开源的Python科学计算库,建立在Numpy之上。它增加的功能包括数值积分、最优化、统计和一些专用函数。SciPy函数库在NumPy库的基础上增加了众多的数学、科学以及工程计算中常用的库函数。例如插值运算、线性代数、常微分方程数值求解、信号处理、图像处理、稀疏矩阵等等。
安装:
C:\Program Files\Python37\Scripts>pip install d:\scipy-1.1.0-cp37-none-win_amd64.whl
Processing d:\scipy-1.1.0-cp37-none-win_amd64.whl
Requirement already satisfied: numpy>=1.8.2 in c:\program files\python37\lib\site-packages (from scipy==1.1.0) (1.15.2)
Installing collected packages: scipy
Successfully installed scipy-1.1.0
Matplotlib:
Python plotting package.
Matplotlib是一个Python 2D绘图库,它可以在各种平台上以各种硬拷贝格式和交互式环境生成具有出版品质的图形。Matplotlib只需几行代码即可生成曲线图、直方图、曲饼图、散点图等。
安装:
C:\Program Files\Python37\Scripts>pip install d:\matplotlib-3.0.0-cp37-cp37m-win_amd64.whl
Processing d:\matplotlib-3.0.0-cp37-cp37m-win_amd64.whl
Collecting kiwisolver>=1.0.1 (from matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/7c/be/7ae355b45699460e369ebf88d86058fca26827933974cc3f6b6b7800a324/kiwisolver-1.0.1-cp37-none-win_amd64.whl (57kB)
100% |████████████████████████████████| 61kB 55kB/s
Collecting python-dateutil>=2.1 (from matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
100% |████████████████████████████████| 215kB 74kB/s
Collecting cycler>=0.10 (from matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/2b/4a/f06b45ab9690d4c37641ec776f7ad691974f4cf6943a73267475b05cbfca/pyparsing-2.2.2-py2.py3-none-any.whl (57kB)
100% |████████████████████████████████| 61kB 131kB/s
Requirement already satisfied: numpy>=1.10.0 in c:\program files\python37\lib\site-packages (from matplotlib==3.0.0) (1.15.2)
Requirement already satisfied: setuptools in c:\program files\python37\lib\site-packages (from kiwisolver>=1.0.1->matplotlib==3.0.0) (39.0.1)
Collecting six>=1.5 (from python-dateutil>=2.1->matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Installing collected packages: kiwisolver, six, python-dateutil, cycler, pyparsing, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.0.1 matplotlib-3.0.0 pyparsing-2.2.2 python-dateutil-2.7.3 six-1.11.0
Scikit-Learn:
A set of python modules for machine learning and data mining.
scikit-learn(简记sklearn)是用python实现的机器学习算法库。sklearn可以实现数据预处理、分类、回归、降维、模型选择等常用的机器学习算法。sklearn是基于NumPy, SciPy, matplotlib的。
安装:
C:\Program Files\Python37\Scripts>pip install d:\scikit_learn-0.20.0-cp37-cp37m-win_amd64.whl
Processing d:\scikit_learn-0.20.0-cp37-cp37m-win_amd64.whl
Requirement already satisfied: scipy>=0.13.3 in c:\program files\python37\lib\site-packages (from scikit-learn==0.20.0) (1.1.0)
Requirement already satisfied: numpy>=1.8.2 in c:\program files\python37\lib\site-packages (from scikit-learn==0.20.0) (1.15.2)
Installing collected packages: scikit-learn
Successfully installed scikit-learn-0.20.0
可以简单测试一下算法库安装后的效果,代码如下:
#导入NumPy库 import numpy as np #导入Matplotlib库 import matplotlib.pyplot as plt import math #定义序列端点和样本数 x = np.linspace(-math.pi, math.pi, 100) #定义函数 y0 = x / x - 1 y1 = np.sin(x) y2 = np.cos(x) y3 = x**2 - 2 * x - 1 #绘制曲线 plt.plot(x, y0, color = 'black', linewidth = 0.5) plt.plot(x, y1, label = '$y=sin(x)$', color = 'red', linewidth = 0.5) plt.plot(x, y2, label = '$y=cos(x)$', color = 'green', linewidth = 0.5) plt.plot(x, y3, label = '$y=x^2-2x+1$', color = 'blue', linewidth = 0.5) #定义坐标 plt.xlabel('Time(s)') plt.ylabel('Volt') plt.xlim(-4, 4) plt.ylim(-2, 2) #标题和图示 plt.title('PyPlot') plt.legend() #显示绘图 plt.show()
感谢各位的阅读,以上就是“Python算法库的安装过程”的内容了,经过本文的学习后,相信大家对Python算法库的安装过程这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!
网站题目:Python算法库的安装过程-创新互联
转载注明:http://lswzjz.com/article/dijgoi.html