I'm following this SVM classifier example code from a book that I'm reading.
I'm new to Python and have hard time understanding/visualizing all these arrays syntax [:,1] [:,:-1]
. Could someone please explain what are the last 3 lines of code supposed to mean/do. I will greatly appreciate it.
Convert string data to numerical data
label_encoder = []
X_encoded = np.empty(X.shape)
for i,item in enumerate(X[0]):
if item.isdigit():
X_encoded[:, i] = X[:, i]
else:
label_encoder.append(preprocessing.LabelEncoder())
X_encoded[:, i] = label_encoder[-1].fit_transform(X[:, i])
X = X_encoded[:, :-1].astype(int)
y = X_encoded[:, -1].astype(int)