0

I'm a beginner in DataScience and this is my first project. So what I want to do is quite simple, just a 0-1 classification.

X= ['neighbourhood_code','room_type_code','price','minimum_nights','calculated_host_listings_count','score']
y=['pop_index']
X_train, X_test, y_train, y_test=train_test_split(
   df[X], df[y],random_state=3)

rf=RandomForestClassifier(n_estimators=500, oob_score=True, random_state=666, n_jobs=-1,max_depth=10)
rf.fit(X_train,y_train.values.ravel())
result2=rf.predict(X_test)
score2=accuracy_score(result2,y_test)


    import matplotlib as plt
    plt.rc('font',family='SimHei',size=13)
    from lime.lime_tabular import LimeTabularExplainer
    explainer = LimeTabularExplainer(np.array(X_train),feature_names=X,class_names=[0,1])
    exp = explainer.explain_instance(X_train.iloc[200,:],et.predict)
    fig = exp.as_pypplot_figure()

I first used random forest to predict, when I tried to apply lime to explain, the error occured on the explainer. In reference to another post, I think there's something wrong with the sum of the probability (maybe less than 1). Since this is not a RNN, so I can't change the activation, looking forward to your help, thanks~

李雅譞
  • 1
  • 1

0 Answers0