gpt4 book ai didi

python-2.7 - Sklearn 中 MLPClassifier 最重要的功能

转载 作者:行者123 更新时间:2023-11-30 08:28:08 27 4
gpt4 key购买 nike

我想知道在 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))

最佳答案

好问题。神经网络模型缺乏可解释性是 ML/NN 社区一直面临的难题之一。

最近受到关注的一种方法是 LIME paper (Ribeiro 等人,KDD'16)。以下是摘要的相关摘录:

  • “在这项工作中,我们提出了 LIME,这是一种新颖的解释技术,通过围绕预测本地学习可解释的模型,以可解释且忠实的方式解释任何分类器的预测”

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

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

关于python-2.7 - Sklearn 中 MLPClassifier 最重要的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44460937/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com