// Check types
if not isinstance(X, np.ndarray):
raise ValueError("X must be a 2D NumPy array")
if not isinstance(y, np.ndarray):
raise ValueError("y must be a 1D NumPy array")
if not np.issubdtype(y.dtype, np.integer):
raise ValueError("y must have be an integer array. "
"Try passing the array as y.astype(np.integer)")
if ax is None:
ax = plt.gca()
// check if test data is provided
plot_testdata = True
if not isinstance(X_highlight, np.ndarray):
if X_highlight is not None:
raise ValueError("X_highlight must be a NumPy array or None")
else:
plot_testdata = False
if len(X.shape) != 2:
raise ValueError("X must be a 2D array")
if X.shape[1] > 2:
raise ValueError("X cannot have more than 2 feature columns")
elif isinstance(X_highlight, np.ndarray) and len(X_highlight.shape) > 2:
raise ValueError("X_highlight must be a 2D array")
elif len(y.shape) > 1:
raise ValueError("y must be a 1D array")