srome / pykliep

A density ratio estimator package for python using the KLIEP algorithm.
MIT License
103 stars 22 forks source link

AttributeError: DensityRatioEstimator instance has no attribute '_sigma' #2

Open damhurmuller opened 6 years ago

damhurmuller commented 6 years ago

Traceback (most recent call last): File "challenge.py", line 187, in weights = kliep.predict(X)
File "challenge.py", line 180, in predict return np.dot(self._phi(X, sigma=sigma), self._alpha).reshape((X.shape[0],)) File "challenge.py", line 150, in _phi sigma = self._sigma AttributeError: DensityRatioEstimator instance has no attribute '_sigma'

xiaochenwang94 commented 5 years ago

I have same problem.

jonmart0304 commented 5 years ago

I think it needs to be initialized in the constructor first because it is out of scope?

usccolumbia commented 4 years ago

if the runnig does not converge, this code returns without setting the _sigma, so get the error.

        if len(sorted_scores) == 0:   
            warnings.warn('LCV failed to converge for all values of sigma.')
            return self
        self._sigma = sorted_scores[0][0][1]
ramdhan1989 commented 3 years ago

I have some problem

liaochen1988 commented 3 years ago

I have the same problem

atakanfilgoz commented 3 years ago

As @usccolumbia mentioned if the run does not converge, this code does not set _sigma variable and it throws exception. You can try larger sigmas based on your data to avoid.

SSMK-wq commented 1 year ago

What was done to solve this issue? I also get the same error. Is anyone here tried anything to fix this issue? and how did you fix it? I already tried changing the list of values (for sigma) in code to larger values such as 100