class MyRegressor:
    """uses different regressors internally"""

def __init__(self):
    self.randomForest = initializeRandomForest()
self.kNN = initializekNN()

def fit(self, X, y):
    """calls the appropriate regressors"""
X1 = X[X[:, (0)] == 1]
y1 = y[X[:, (0)] == 1]
X2 = X[X[:, (0)] != 1]
y2 = y[X[:, (0)] != 1]
self.randomForest.fit(X1, y1)
self.kNN.fit(X2, y2)

def predict(self, X):
    """predicts values using regressors internally"""
results = np.zeros(X.shape[0])
results[X[:, (0)] == 1] = self.randomForest.predict(X[X[:, (0)] == 1])
results[X[:, (0)] != 1] = self.kNN.predict(X[X[:, (0)] != 1])
return results
Используйте другой оценщик на основе значения