当前位置:网站首页>Successfully resolved raise TypeError('Unexpected feature_names type')TypeError: Unexpected feature_names type
Successfully resolved raise TypeError('Unexpected feature_names type')TypeError: Unexpected feature_names type
2022-08-11 00:58:00 【A Virgo programmer】
成功解决raise TypeError('Unexpected feature_names type')TypeError: Unexpected feature_names type
目录
解决问题
raise TypeError('Unexpected feature_names type')TypeError: Unexpected feature_names type
解决思路
类型错误:意外的 feature_names 类型
解决方法
经过分析发现,
The original function parameter expects the type to be list类型,
And the current error code is providedpandas.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 名称列表. It allows to specify feature names when the estimator object does not provide them. According to estimator type,This parameter may or may not be supported.
源代码解析
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)边栏推荐
- 嵌入式软件打log的一些心得
- 【服务器数据恢复】raid5崩溃导致lvm信息和VXFS文件系统损坏的数据恢复案例
- J9数字论:DAO治理更像一种生态过程:治理原生于网络,不断演变
- How to determine the size of the version number
- 双机热备综合实验(VRRP+OSPF+VTP+NAT+DHCP+PVSTP+单臂路由)
- Exceptions and exception handling mechanisms
- Elastic scaling of construction resources
- networkmanager无法打开
- SQL statement--get database table information, table name, column name, description comment, etc.
- 【redis】发布和订阅消息
猜你喜欢

【爬虫】scrapy创建运行爬虫、解析页面(嵌套url)、自定义中间件(设置UserAgent和代理IP)、自定义管道(保存到mysql)

#yyds干货盘点#【愚公系列】2022年08月 Go教学课程 008-数据类型之整型

MSTP - Multiple Spanning Tree (Case + Configuration)

ABP中的数据过滤器

Go项目配置管理神器之viper使用详解

C#使用计时器

地下管廊可视化管理系统搭建

How to do patent mining, the key is to find patent points, in fact, it is not too difficult

Only lazy and hungry. You still don't understand the singleton pattern!

Introduction to Qt (6) - Implementation of the lottery system
随机推荐
How to determine the size of the version number
How to check if the online query suddenly slows down
22/8/9 贪心问题合集
[21 Days Learning Challenge] Half Insertion Sort
More parameter exposure of Pico 4: Pancake + color perspective, and Pro version
数据分析面试手册《SQL篇》
【C语言】探索数据的存储(整形篇)
EN 12467纤维水泥平板产品—CE认证
apache+PHP+MySQL+word press,安装word press时页面报错?
Where can I download IEEE papers?
WinForm(五)控件和它的成员
SQL语句--获取数据库表信息,表名、列名、描述注释等
@Autowired注入RedisCache报错空指针
Shell 文本三剑客 Sed
20张图,全面掌握MVCC原理!
YOLOv5的Tricks | 【Trick13】YOLOv5的detect.py脚本的解析与简化
微信小程序获取当前页面的url和参数
【21天学习挑战赛】折半插入排序
BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection 论文笔记
【openpyxl】过滤和排序