Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update iteritems() to python3 compatibility #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pykliep.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import warnings

from future.utils import iteritems
class DensityRatioEstimator:
"""
Class to accomplish direct density estimation implementing the original KLIEP
Expand Down Expand Up @@ -83,7 +83,7 @@ def fit(self, X_train, X_test, alpha_0=None):
sigma=sigma)
j_scores[(num_param,sigma)] = np.mean(j_scores[(num_param,sigma)])

sorted_scores = sorted([x for x in j_scores.iteritems() if np.isfinite(x[1])], key=lambda x :x[1], reverse=True)
sorted_scores = sorted([x for x in iteritems(j_scores) if np.isfinite(x[1])], key=lambda x :x[1], reverse=True)
if len(sorted_scores) == 0:
warnings.warn('LCV failed to converge for all values of sigma.')
return self
Expand Down