pykliep icon indicating copy to clipboard operation
pykliep copied to clipboard

AttributeError: DensityRatioEstimator instance has no attribute '_sigma'

Open damhurmuller opened this issue 6 years ago • 7 comments

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'

damhurmuller avatar Sep 06 '18 01:09 damhurmuller

I have same problem.

xiaochenwang94 avatar Oct 23 '18 06:10 xiaochenwang94

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

jonmart0304 avatar Nov 21 '18 05:11 jonmart0304

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]

usccolumbia avatar Apr 01 '20 01:04 usccolumbia

I have some problem

ramdhan1989 avatar Dec 21 '20 11:12 ramdhan1989

I have the same problem

liaochen1988 avatar Jan 19 '21 15:01 liaochen1988

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.

atakanfilgoz avatar Mar 01 '21 12:03 atakanfilgoz

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

SSMK-wq avatar Nov 24 '22 08:11 SSMK-wq