Error when I try to create plot in ML-Lesson 4

(ritika) #1

When I am trying to create plot I am getting error

TypeError: pdp_isolate() missing 1 required positional argument: ‘feature’

Anyone Please suggest how to fix this error?

Ritika Machine Learning lessons on Kaggle kernels Machine Learning lessons on Kaggle kernels
(shikun chen) #2

Hi, I have encountered the same problem, you should refer to pdp’s documentation.

def plot_pdp(feat_name, clusters=None):
#feat_name = feat_name or feat
    p = pdp.pdp_isolate(m, x, feature=feat_name, model_features=x.columns)
    return pdp.pdp_plot(p, feat_name, plot_lines=True,
                   cluster=clusters is not None, n_cluster_centers=clusters)

And then


(ritika) #3

Hi Chen.

I have referred pdp documentation.still i am facing the issue. Can you please share your steps to fix this error.


(shikun chen) #4

Hi, my code above doesn’t work?

It worked fine for me! you need to specify another argument model_features.

(ritika) #5

thanks @cican

(oxidising) #6

Hi Cican,

Could you submit a pull request for this to be changed? Or would you like me to submit the request?


(shikun chen) #7

yes, please do that. Actually I don’t know how to submit a pull request.


(Sonu) #8


(Y.G. Bae) #9

I understand I maybe talking about this late, but I went instead with below code:

def plot_pdp(feat, clusters = None, feat_name = None):
    feat_name = feat_name or feat
    p = pdp.pdp_isolate(m, x, feature = feat, model_features = x.columns)
    return pdp.pdp_plot(p, feat_name, plot_lines = True,
                        cluster = clusters is not None,
                        n_cluster_centers = clusters)