Sklearn中MLPClassifier中最重要的功能

时间:2017-06-09 14:57:01

标签: python-2.7 machine-learning scikit-learn classification multi-layer

我想知道在Sklearn中安装MLP分类器之后是否有任何方法可视化或找到最重要/最有贡献的特征。

简单示例:

import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import LeaveOneOut
from sklearn.neural_network import MLPClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import make_pipeline


data= pd.read_csv('All.csv', header=None)
X, y = data.iloc[0:, 0:249].values, data.iloc[0:,249].values

sc = StandardScaler()
mlc = MLPClassifier(activation = 'relu', random_state=1,nesterovs_momentum=True)
loo = LeaveOneOut()
pipe = make_pipeline(sc, mlc)

parameters = {"mlpclassifier__hidden_layer_sizes":[(168,),(126,),(498,),(166,)],"mlpclassifier__solver" : ('sgd','adam'), "mlpclassifier__alpha": [0.001,0.0001],"mlpclassifier__learning_rate_init":[0.005,0.001] }
clf = GridSearchCV(pipe, parameters,n_jobs= -1,cv = loo)
clf.fit(X, y)

model = clf.best_estimator_
print("the best model and parameters are the following: {} ".format(model))

1 个答案:

答案 0 :(得分:5)

好问题。 NN模型缺乏可解释性是ML / NN社区一直在努力解决的问题。

最近引起关注的一种方法是LIME paper(Ribeiro等,KDD' 16)。 这是抽象的相关摘录:

  • "在这项工作中,我们提出了LIME,这是一种新颖的解释技术,通过在预测周围学习可解释的模型来解释任何分类器以可解释和忠实的方式进行的预测"

还有一个GitHub repository(Python,yay!)。

(如果您尝试过LIME,请在问题评论中分享您的经验。)