溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Python算法庫的安裝過程

發(fā)布時間:2021-08-27 09:05:17 來源:億速云 閱讀:223 作者:chen 欄目:網(wǎng)絡(luò)安全

這篇文章主要講解了“Python算法庫的安裝過程”,文中的講解內(nèi)容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“Python算法庫的安裝過程”吧!

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,就可以很自然地使用數(shù)組和矩陣。NumPy包含很多實用的數(shù)學函數(shù),涵蓋線性代數(shù)運算、傅里葉變換和隨機數(shù)生成等功能。NumPy通常與SciPy和Matplotlib一起使用,這種組合廣泛用于替代MatLab(一個流行的技術(shù)計算平臺),Python作為MatLab的替代方案,現(xiàn)在被視為一種更加現(xiàn)代和完整的編程語言。

安裝:
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之上。它增加的功能包括數(shù)值積分、最優(yōu)化、統(tǒng)計和一些專用函數(shù)。SciPy函數(shù)庫在NumPy庫的基礎(chǔ)上增加了眾多的數(shù)學、科學以及工程計算中常用的庫函數(shù)。例如插值運算、線性代數(shù)、常微分方程數(shù)值求解、信號處理、圖像處理、稀疏矩陣等等。

安裝:
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繪圖庫,它可以在各種平臺上以各種硬拷貝格式和交互式環(huán)境生成具有出版品質(zhì)的圖形。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實現(xiàn)的機器學習算法庫。sklearn可以實現(xiàn)數(shù)據(jù)預處理、分類、回歸、降維、模型選擇等常用的機器學習算法。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
#定義序列端點和樣本數(shù)
x = np.linspace(-math.pi, math.pi, 100)
#定義函數(shù)
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算法庫的安裝過程”的內(nèi)容了,經(jīng)過本文的學習后,相信大家對Python算法庫的安裝過程這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI