update
This commit is contained in:
@@ -153,13 +153,13 @@ print(x)
|
||||
or simply write them as double precision numbers (Python uses 64 bits as default for floating point type variables), that is
|
||||
!bc pycod
|
||||
import numpy as np
|
||||
x = np.log(np.array([4.0, 7.0, 8.0])
|
||||
x = np.log(np.array([4.0, 7.0, 8.0]))
|
||||
print(x)
|
||||
!ec
|
||||
To check the number of bytes (remember that one byte contains eight bits for double precision variables), you can use simple use the _itemsize_ functionality (the array $x$ is actually an object which inherits the functionalities defined in Numpy) as
|
||||
!bc pycod
|
||||
import numpy as np
|
||||
x = np.log(np.array([4.0, 7.0, 8.0])
|
||||
x = np.log(np.array([4.0, 7.0, 8.0]))
|
||||
print(x.itemsize)
|
||||
!ec
|
||||
|
||||
@@ -305,7 +305,10 @@ print(f"This is the mean for each column:{np.mean(a, axis=0, keepdims=True,dtype
|
||||
print(f"This is the mean value for each row:{np.mean(a, axis=1, keepdims=True,dtype=np.float64)}")
|
||||
# We print then the mean value for each row by setting keepdims=False
|
||||
print(f"This is the mean value for each row with keepdims false:{np.mean(a, axis=1, keepdims=False,dtype=np.float64)}")
|
||||
!ec
|
||||
|
||||
Another useful function is the _ravel_ function, which returns a flattened array as shown in the example here.
|
||||
!bc pycod
|
||||
# Ravel return a contiguous flattened array.
|
||||
print(f"Flatten the matrix:{np.ravel(a)}")
|
||||
# It is the same as reshaping the matrix into a one-dimensional array
|
||||
@@ -726,6 +729,11 @@ and continue till we have solved all $n$ sets of linear equations.
|
||||
|
||||
|
||||
|
||||
|
||||
The calculation of the inverse here assumes that it actually
|
||||
exists. In many machine learning applications there may be strong
|
||||
linear dependencies among the various columns and/or rows. In our
|
||||
discussions of linear regression we will dive into the mathematics of
|
||||
the singular value decomposition, an algorithm which will allow us to calculate the so-called pseudo-inverse.
|
||||
These details will be presented in our linear regression chapter.
|
||||
|
||||
|
||||
|
||||
+562
-152
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user