当前位置:网站首页>成功解决raise TypeError(‘Unexpected feature_names type‘)TypeError: Unexpected feature_names type
成功解决raise TypeError(‘Unexpected feature_names type‘)TypeError: Unexpected feature_names type
2022-08-11 00:34:00 【一个处女座的程序猿】
成功解决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 function
to 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 and
customize formatting in a single call.
Parameters
----------
estimator : object
Estimator instance. This argument must be positional.
top : int or (int, int) tuple, optional
Number of features to show. When ``top`` is int, ``top``
features with
a 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,
optional
Names of targets or classes. This argument can be used to
provide
human-readable class/target names for estimators which
don't expose
clss names themselves. It can be also used to rename
estimator-provided
classes before displaying them.
This argument may be supported or not, depending on
estimator type.
targets : list, optional
Order of class/target names to show. This argument can be
also used
to show information only for a subset of classes. It should
be a list
of class / target names which match either names provided
by
an estimator or names defined in ``target_names``
parameter.
This argument may be supported or not, depending on
estimator type.
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_re : str, optional
Only feature names which match ``feature_re`` regex are
shown
(more precisely, ``re.search(feature_re, x)`` is checked).
feature_filter : Callable[[str], bool], optional
Only feature names for which ``feature_filter`` function
returns True
are shown.
show : List[str], optional
List 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 or
an 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 : bool
When True, feature weight tables are printed horizontally
(left to right); when False, feature weight tables are printed
vertically (top to down). Default is True.
highlight_spaces : bool or None, optional
Whether to highlight spaces in feature names. This is useful
if
you work with text and have ngram features which may
include spaces
at left or right. Default is None, meaning that the value used
is set automatically based on vectorizer and feature values.
include_styles : bool
Most styles are inline, but some are included separately in
<style> tag;
you can omit them by passing ``include_styles=False``.
Default is True.
**kwargs: dict
Keyword arguments. All keyword arguments are passed to
concrete explain_weights... implementations.
Returns
-------
IPython.display.HTML
The result is printed in IPython notebook as an HTML
widget.
If you need to display several explanations as an output of
a single
cell, or if you want to display it from a function then use
IPython.display.display::
from IPython.display import display
display(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)边栏推荐
- 构建检测,无规矩不成方圆
- leetcode 前K个高频单词
- Mysql.慢Sql
- [21-day learning challenge - kernel notes] (5) - devmem read and write register debugging
- WebView2 通过 PuppeteerSharp 实现RPA获取壁纸 (案例版)
- “蔚来杯“2022牛客暑期多校训练营3 DF题解
- 异常:try catch finally throws throw
- Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
- word 设置标题前分页
- 【C语言】探索数据的存储(整形篇)
猜你喜欢

详解JDBC的实现与优化(万字详解)

英文文献阅读时,如何做笔记?

YOLOv5的Tricks | 【Trick13】YOLOv5的detect.py脚本的解析与简化

BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection Paper Notes

How to do patent mining, the key is to find patent points, in fact, it is not too difficult
![[Excel知识技能] 将文本型数字转换为数值格式](/img/7e/16a068025ec2639b343436c7f5b245.png)
[Excel知识技能] 将文本型数字转换为数值格式

EPro-PnP: Generalized End-to-End Probabilistic Perspective-n-Points for Monocular Object Pose Est...

Ali P7 bask in January payroll: hard to fill the, really sweet...

“蔚来杯“2022牛客暑期多校训练营2 DGHJKL题解

15. Interceptor - HandlerInterceptor
随机推荐
力扣------用栈操作构建数组
How to build speed, speed up again
Design and implementation of flower online sales management system
微信小程序强制更新版本
CF1286E-Fedya the Potter Strikes Back【KMP,RMQ】
PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
异常:try catch finally throws throw
只会懒汉式和饿汉式 你还不懂单例模式!
Navicat 16-数据库工具
如何做专利挖掘,关键是寻找专利点,其实并不太难
I caught a 10-year-old Ali test developer, and after talking about it, I made a lot of money...
详谈二叉搜索树
5. Lombok
word 设置标题前分页
WebView2 通过 PuppeteerSharp 实现RPA获取壁纸 (案例版)
如何便捷获取参考文献的引用格式?
③ 关系数据库标准语言SQL 数据查询(SELECT)
Kunpeng compilation and debugging and basic knowledge of native development tools
Web APIs BOM - A Comprehensive Case of Operating Browsers
input输入框超出部分用省略号表示以及判断内容是否有超出(PC端)