成功解决raise TypeError(‘Unexpected feature_names type‘)TypeError: Unexpected feature_names type
成功解决raise TypeError('Unexpected feature_names type')TypeError: Unexpected feature_names type
目录
解决问题
解决思路
解决方法
源代码解析
解决问题
raise TypeError('Unexpected feature_names type')TypeError: Unexpected feature_names type
解决思路
类型错误:意外的 feature_names 类型
解决方法
经过分析发现,
原函数参数要求类型是list类型,
而当前出错的代码却提供了pandas.core.indexes.base.Index类型
feature_names : list, optional. A list of feature names. It allows to specify feature names when they are not provided by an estimator object. This argument may be supported or not, depending on estimator type.
feature_names :列表,可选。 feature 名称列表。 它允许在估算器对象未提供特征名称时指定它们。 根据估算器类型,可能支持或不支持此参数。
源代码解析
def show_weights(estimator, **kwargs):""" Return an explanation of estimator parameters (weights)as an IPython.display.HTML object. Use this functionto show classifier weights in IPython.:func:`show_weights` accepts all:func:`eli5.explain_weights` arguments and all:func:`eli5.formatters.html.format_as_html`keyword arguments, so it is possible to get explanation andcustomize formatting in a single call.Parameters----------estimator : objectEstimator instance. This argument must be positional.top : int or (int, int) tuple, optionalNumber of features to show. When ``top`` is int, ``top`` features witha highest absolute values are shown. When it is (pos, neg) tuple,no more than ``pos`` positive features and no more than ``neg``negative features is shown. ``None`` value means no limit.This argument may be supported or not, depending on estimator type.target_names : list[str] or {'old_name': 'new_name'} dict, optionalNames of targets or classes. This argument can be used to providehuman-readable class/target names for estimators which don't exposeclss names themselves. It can be also used to rename estimator-providedclasses before displaying them.This argument may be supported or not, depending on estimator type.targets : list, optionalOrder of class/target names to show. This argument can be also usedto show information only for a subset of classes. It should be a listof class / target names which match either names provided byan estimator or names defined in ``target_names`` parameter.This argument may be supported or not, depending on estimator type.feature_names : list, optionalA list of feature names. It allows to specify featurenames when they are not provided by an estimator object.This argument may be supported or not, depending on estimator type.feature_re : str, optionalOnly feature names which match ``feature_re`` regex are shown(more precisely, ``re.search(feature_re, x)`` is checked).feature_filter : Callable[[str], bool], optionalOnly feature names for which ``feature_filter`` function returns Trueare shown.show : List[str], optionalList of sections to show. Allowed values:* 'targets' - per-target feature weights;* 'transition_features' - transition features of a CRF model;* 'feature_importances' - feature importances of a decision tree oran ensemble-based estimator;* 'decision_tree' - decision tree in a graphical form;* 'method' - a string with explanation method;* 'description' - description of explanation method and its caveats.``eli5.formatters.fields`` provides constants that cover common cases:``INFO`` (method and description), ``WEIGHTS`` (all the rest),and ``ALL`` (all).horizontal_layout : boolWhen True, feature weight tables are printed horizontally(left to right); when False, feature weight tables are printedvertically (top to down). Default is True.highlight_spaces : bool or None, optionalWhether to highlight spaces in feature names. This is useful ifyou work with text and have ngram features which may include spacesat left or right. Default is None, meaning that the value usedis set automatically based on vectorizer and feature values.include_styles : boolMost styles are inline, but some are included separately in <style> tag;you can omit them by passing ``include_styles=False``. Default is True.**kwargs: dictKeyword arguments. All keyword arguments are passed toconcrete explain_weights... implementations.Returns-------IPython.display.HTMLThe result is printed in IPython notebook as an HTML widget.If you need to display several explanations as an output of a singlecell, or if you want to display it from a function then useIPython.display.display::from IPython.display import displaydisplay(eli5.show_weights(clf1))display(eli5.show_weights(clf2))"""format_kwargs, explain_kwargs = _split_kwargs(kwargs)expl = explain_weights(estimator, **explain_kwargs)_set_html_kwargs_defaults(format_kwargs)html = format_as_html(expl, **format_kwargs)return HTML(html)
成功解决raise TypeError(‘Unexpected feature_names type‘)TypeError: Unexpected feature_names type相关推荐
- 成功解决ForkingPickler(file, protocol).dump(obj) TypeError: can‘t pickle Environment objects
成功解决ForkingPickler(file, protocol).dump(obj) TypeError: can't pickle Environment objects 目录 解决问题 解决思 ...
- 成功解决raise ValueError(“Unknown label type: %s“ % repr(ys))ValueError: Unknown label type: (array([24
成功解决raise ValueError("Unknown label type: %s" % repr(ys))ValueError: Unknown label type: ( ...
- 成功解决lightgbm.basic.LightGBMError: Parameter max_depth should be of type int, got “0.02“
成功解决lightgbm.basic.LightGBMError: Parameter max_depth should be of type int, got "0.02" 目录 ...
- 成功解决raise Py4JError py4j.protocol.Py4JError: py4j.protocol.Py4JError: Could not find py4j jar at
成功解决raise Py4JError("Could not find py4j jar at {0}".format(jarpath)) py4j.protocol.Py4JEr ...
- 成功解决raise ValueError(‘No model found in config file.‘) ValueError: No model found in config file.
成功解决raise ValueError('No model found in config file.') ValueError: No model found in config file. 目录 ...
- 成功解决.sh: line 6: syntax error near unexpected token `do
成功解决.sh: line 6: syntax error near unexpected token `do 目录 解决问题 解决思路 解决方法 T1.修改格式系统间不兼容的格式
- 成功解决 raise RuntimeError(“The JPMML-SkLearn conversion application has failed. The Java executable
成功解决 raise RuntimeError("The JPMML-SkLearn conversion application has failed. The Java execu ...
- 成功解决raise XGBoostError(_LIB.XGBGetLastError()) xgboost.core.XGBoostError: b'[22:08:00] C:\\Users\\Ad
成功解决raise XGBoostError(_LIB.XGBGetLastError()) xgboost.core.XGBoostError: b'[22:08:00] C:\\Users\\Ad ...
- 成功解决 raise XGBoostError(_LIB.XGBGetLastError()) xgboost.core.DMatrix/Booster has not been intialized
成功解决 raise XGBoostError(_LIB.XGBGetLastError()) xgboost.core.DMatrix/Booster has not been intialized ...
最新文章
- 使用Docker快速搭建PHP开发环境
- 将.gitignore应用于已提交的文件
- 快速识别Hash加密方式hashid
- 【Android 热修复】热修复原理 ( 修复包 Dex 文件准备 | Dex 优化为 Odex | Dex 文件拷贝 | 源码资源 )
- 跨站请求伪造(CSRF/XSRF)
- XCode、Objective-C、Cocoa 说的是几样东西
- Golang笔记-面向对象编程-多态/类型断言
- python gui 选择
- 张小龙向来痴,微信从此醉,复盘8年,2大初心驱动至今 | 2019实录
- JavaScript学习笔记(三)——从简单模仿到创作
- QQ新版表情序号及对应
- 计算机培训校本研修心得,关于校本研修培训心得体会(精选10篇)
- 2014十佳IDC评选-专访联动天下CEO饶华明
- 妄想性仮想人格障害 汉化补丁(BUG修正)
- LC振荡电路设计原理
- centos6.5 ifconfig 显示为eth2,配置文件只有eth0
- 最近公共先祖 C++ 牛客网
- Linux Signal 信号查询
- 树莓派 电脑 网线对联 桥接及ssh
- MySQL的定时任务详解