mock.py

Home   »   mock.py

class MyEstimator(BaseEstimator):
  def fit(self, X, y = None):
    self._isfitted = True
    return self
  
  def predict(self, X):
    try:
      getattr(self, "isfitted")
    except AttributeError:
      raise RuntimeError("My estimator should be fitted before predict.")
    
    predictions = np.random.randint(0, 2, len(X))
    return predictions

Leave a Reply

Your email address will not be published. Required fields are marked *