Hay textos parecidos al vino o la dinamita: con los años no envejecen, sino que, por el contrario, adquieren peso y significado. Hoy, para el inicio del curso insignia de Data Science, decidimos compartir la traducción del tutorial visual sobre NumPy en 2019, después de leer que incluso una persona que no esté demasiado cerca de las matemáticas entenderá cómo funciona esta biblioteca de Python. Si no quieres explicar NumPy durante mucho tiempo, pero aún tienes que hacerlo, marca el artículo como favorito y te ahorrará tiempo.
NumPy — , Python. . Python (, scikit-learn, SciPy, pandas tensorflow) NumPy . NumPy .
NumPy, (, , .) .
[. . — , ]:
pip install numpy
Python, :
import numpy as np
NumPy (ndarray) NumPy Python np.array(). Python , :
, NumPy . NumPy , ones(), zeros() random.random(). , :
.
NumPy . data ones:
(. . ) : data + ones:
? , . , . :
, ( -). , , . data * 1.6:
NumPy , ! , .
NumPy [ " ", Python ] , Python:
— :
, (min, max sum) , mean ( ), prod ( ), std ( ), .
?
. NumPy .
NumPy Python, :
np.array([[1,2],[3,4]])
(ones(), zeros() random.random()) , , , :
, (+-*/). NumPy :
, , (, ), NumPy :
, , "" . :
:
, :
, axis:
. () , . NumPy T:
. , , . NumPy reshape(). . -1, NumPy :
?
NumPy . NumPy n- (ndarray, N-Dimensional Array).
NumPy:
: , NumPy , . n- NumPy , , — . , np.ones((4,3,2)) :
array([[[1., 1.],
[1., 1.],
[1., 1.]],
[[1., 1.],
[1., 1.],
[1., 1.]],
[[1., 1.],
[1., 1.],
[1., 1.]],
[[1., 1.],
[1., 1.],
[1., 1.]]])
, ? NumPy.
NumPy , . NumPy Python. , , , :
NumPy :
, NumPy , predictions labels (, ). , :
predictions labels . , n 3. :
:
:
.
, , , ( , , ... . .). n- :
, , . . Python pandas dataframe, NumPy .
— . — , . CD- 44 100 , -32767 32768. , WAVE- CD-, NumPy 10 * 44100 = 441000 . ? NumPy ( audio) audio[:44100]. :
NumPy (, ).
— ( x ).
- ( ), ( 0 () 255 ()). 10 x 10 ? NumPy : image[:10,:10].
:
, , . ( ). , : ( x x 3).
“Have the bards who preceded me left any theme unsung?” ( - ?)
( , ):
:
. / ( 50- word2vec):
, NumPy [embedding_dimension x sequence_length]. , . , , ( ). reshape(). BERT, , : [batch_size, sequence_length, embedding_size].
, . , , ( ).
Data Science . , , — , , . , , , , Data Science.