Skip to content

dict object has no attribute iteritems #9

Description

@SSMK-wq

I am trying to follow the example and fit the model but keep getting the below error

My code looks like below

kliep = DensityRatioEstimator()
kliep.fit(X_train.values, X_test.values) # keyword arguments are X_train and X_test
weights = kliep.predict(X_train.values)

So, I went to the code file and replaced iteritems with items for python 3 but that still doesn't solve the error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [83], in <cell line: 2>()
      1 kliep = DensityRatioEstimator()
----> 2 kliep.fit(X_train.values, X_test.values) # keyword arguments are X_train and X_test
      3 weights = kliep.predict(X_train.values)

File ~\Downloads\pykliep.py:85, in DensityRatioEstimator.fit(self, X_train, X_test, alpha_0)
     79             j_scores[(num_param,sigma)][k-1] = self._fit(X_train=X_train, 
     80                                              X_test=X_test_fold,
     81                                              num_parameters = num_param,
     82                                              sigma=sigma)
     83         j_scores[(num_param,sigma)] = np.mean(j_scores[(num_param,sigma)])
---> 85 sorted_scores = sorted([x for x in j_scores.iteritems() if np.isfinite(x[1])], key=lambda x :x[1], reverse=True)
     86 if len(sorted_scores) == 0:
     87     warnings.warn('LCV failed to converge for all values of sigma.')

AttributeError: 'dict' object has no attribute 'iteritems'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions