diff --git a/nonconformist/__init__.py b/nonconformist/__init__.py index 32ca439..c5e4551 100644 --- a/nonconformist/__init__.py +++ b/nonconformist/__init__.py @@ -6,6 +6,6 @@ # Authors: Henrik Linusson -__version__ = '1.2.0' +__version__ = '1.2.1' __all__ = ['icp', 'nc', 'acp'] \ No newline at end of file diff --git a/nonconformist/nc.py b/nonconformist/nc.py index b25ff9e..dd3410d 100644 --- a/nonconformist/nc.py +++ b/nonconformist/nc.py @@ -446,7 +446,9 @@ def __init__(self, def fit(self, x, y): super(NormalizedRegressorNc, self).fit(x, y) - log_err = np.log(np.abs(self._underlying_predict(x) - y)) + err = np.abs(self._underlying_predict(x) - y) + err += 0.00001 # Add a small error to each sample to avoid log(0) + log_err = np.log(err) self.normalizer.fit(x, log_err) def calc_nc(self, x, y): @@ -464,6 +466,8 @@ def calc_nc(self, x, y): else: self.beta_ = self.beta + print(norm) + return self.err_func(prediction, y, norm, self.beta_) def predict(self, x, nc, significance=None):