def _as_numpy_arrs(self, X, y=None, **kw):
'''Convert X, y for a scikit-learn method numpy.ndarrays
'''
if isinstance(X, np.ndarray):
return X, y, None
if isinstance(X, xr.Dataset):
X = MLDataset(X)
if hasattr(X, 'has_features'):
if X.has_features(raise_err=False):
pass
else:
X = X.to_features()
row_idx = get_row_index(X)
if hasattr(X, 'to_array') and not isinstance(X, np.ndarray):
X, y = X.to_array(y=y)
# TODO what about row_idx now?
# TODO - if y is not numpy array, then the above lines are needed for y
return X, y, row_idx
评论列表
文章目录