I'm compiling the exact same code in PyCharm and in CMD, but they're giving me two different outputs: PyCharm output - [np.float64(1.6000000000000003), -1] CMD output - [1.6000000000000003, -1]
I was expecting the same output as CMD gives me in PyCharm, but it gives me "np.float64".
import numpy as np
x_train = np.array([[10, 50], [20, 30], [25, 30], [20, 60], [15, 70], [40, 40], [30, 45], [20, 45], [40, 30], [7, 35]])
y_train = np.array([-1, 1, 1, -1, -1, 1, 1, -1, 1, -1])
n_train = len(x_train)
w = [0, -1]
a = lambda x: np.sign(x[0]*w[0] + x[1]*w[1])
N = 50
L = 0.1
e = 0.1
last_error_index = -1
for n in range(N):
for i in range(n_train):
if y_train[i]*a(x_train[i]) < 0:
w[0] = w[0] + L * y_train[i]
last_error_index = i
Q = sum([1 for i in range(n_train) if y_train[i]*a(x_train[i]) < 0])
if Q == 0:
break
if last_error_index > -1:
w[0] = w[0] + e * y_train[last_error_index]
print(w)
I tried reinstalling numpy in PyCharm but it didn't help. I guess it's PyCharm issue, because in CMD and online compiler i have the same expected output.
print(np.__version__)
give different results in pycharm and cmd?__repr__
presentation for a floating point scalar has changed. So your PyCharm and CMD versions do not use the same NumPy version; they are either different virtual environments, or even completely different Python interpreters.print(type(w[0]), w[0].dtype)
, you'll find the same in both cases: w[0] is a NumPy float64. Version 2.x just makes this clearer.