You can round values using NumPy with the following code. If you want to learn Python, I highly recommend reading This Book.
Example 1: If the next value is less than 5
import numpy as np a = 12.11242 x = np.round(a, decimals = 3) print(x)
12.112
Example 2: If the next value is greater than 5
import numpy as np a = 12.6786 x = np.round(a, decimals = 3) print(x)
12.679
Example 3: If the next value is 5 and the number before 5 is even
import numpy as np a = 12.6785 x = np.round(a, decimals = 3) print(x)
12.678
Case 2: If the next value is 5 and the number before 5 is odd
import numpy as np a = 12.6775 x = np.round(a, decimals = 3) print(x)
12.678
People are also reading:
What is Computer Vision? Examples, Applications, Techniques
Books for Machine Learning (ML)