-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathParzenWindowModel.py
More file actions
29 lines (26 loc) · 1008 Bytes
/
ParzenWindowModel.py
File metadata and controls
29 lines (26 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.neighbors import KNeighborsRegressor
class ParzenWindowRegressor(BaseEstimator, RegressorMixin):
def __init__(self, n_neighbors=5, weights='uniform', algorithm='auto',
leaf_size=30, p=2, metric='minkowski', metric_params=None):
self.n_neighbors = n_neighbors
self.weights = weights
self.algorithm = algorithm
self.leaf_size = leaf_size
self.p = p
self.metric = metric
self.metric_params = metric_params
self.model = KNeighborsRegressor(
n_neighbors=self.n_neighbors,
weights=self.weights,
algorithm=self.algorithm,
leaf_size=self.leaf_size,
p=self.p,
metric=self.metric,
metric_params=self.metric_params
)
def fit(self, X, y):
self.model.fit(X, y)
return self
def predict(self, X):
return self.model.predict(X)