MCPcopy
hub / github.com/ddbourgin/numpy-ml / fit

Method fit

numpy_ml/nonparametric/knn.py:47–60  ·  view source on GitHub ↗

r""" Fit the model to the data and targets in `X` and `y` Parameters ---------- X : numpy array of shape `(N, M)` An array of `N` examples to generate predictions on. y : numpy array of shape `(N, *)` Targets for the `N` rows in `X`.

(self, X, y)

Source from the content-addressed store, hash-verified

45 }
46
47 def fit(self, X, y):
48 r"""
49 Fit the model to the data and targets in `X` and `y`
50
51 Parameters
52 ----------
53 X : numpy array of shape `(N, M)`
54 An array of `N` examples to generate predictions on.
55 y : numpy array of shape `(N, *)`
56 Targets for the `N` rows in `X`.
57 """
58 if X.ndim != 2:
59 raise Exception("X must be two-dimensional")
60 self._ball_tree.fit(X, y)
61
62 def predict(self, X):
63 r"""

Callers 4

plot_knnFunction · 0.95
test_knn_regressionFunction · 0.95
test_knn_clfFunction · 0.95
_fit_count_modelsMethod · 0.45

Calls

no outgoing calls

Tested by 2

test_knn_regressionFunction · 0.76
test_knn_clfFunction · 0.76