心慈面善健哥哥 2021-03-25 09:44 采纳率: 100%
浏览 17
已结题

问一下,如何设置估计器返回显示

输入:

from sklearn.ensemble import RandomForestClassifier

rf = RandomForestClassifier(oob_score=True)
rf.fit(x_train,y_train)

输出:

RandomForestClassifier(oob_score=True)

我想请问一下,如何设置才能使它的输出,显示随机森林的具体参数信息呢???

  • 写回答

1条回答 默认 最新

  • 天元浪子 Python领域优质创作者 2021-03-25 09:54
    关注

    模型的参数,都对应一个属性,你可以显示所有属性。

    >>> from sklearn.ensemble import RandomForestClassifier
    >>> rf = RandomForestClassifier(oob_score=True)
    >>> rf
    RandomForestClassifier(bootstrap=True, ccp_alpha=0.0, class_weight=None,
                           criterion='gini', max_depth=None, max_features='auto',
                           max_leaf_nodes=None, max_samples=None,
                           min_impurity_decrease=0.0, min_impurity_split=None,
                           min_samples_leaf=1, min_samples_split=2,
                           min_weight_fraction_leaf=0.0, n_estimators=100,
                           n_jobs=None, oob_score=True, random_state=None,
                           verbose=0, warm_start=False)
    >>> rf.bootstrap
    True
    >>> for item in dir(rf):
    	print(item)
    
    	
    __abstractmethods__
    __class__
    __delattr__
    __dict__
    __dir__
    __doc__
    __eq__
    __format__
    __ge__
    __getattribute__
    __getitem__
    __getstate__
    __gt__
    __hash__
    __init__
    __init_subclass__
    __iter__
    __le__
    __len__
    __lt__
    __module__
    __ne__
    __new__
    __reduce__
    __reduce_ex__
    __repr__
    __setattr__
    __setstate__
    __sizeof__
    __str__
    __subclasshook__
    __weakref__
    _abc_impl
    _estimator_type
    _get_param_names
    _get_tags
    _make_estimator
    _more_tags
    _required_parameters
    _set_oob_score
    _validate_X_predict
    _validate_estimator
    _validate_y_class_weight
    apply
    base_estimator
    bootstrap
    ccp_alpha
    class_weight
    criterion
    decision_path
    estimator_params
    feature_importances_
    fit
    get_params
    max_depth
    max_features
    max_leaf_nodes
    max_samples
    min_impurity_decrease
    min_impurity_split
    min_samples_leaf
    min_samples_split
    min_weight_fraction_leaf
    n_estimators
    n_jobs
    oob_score
    predict
    predict_log_proba
    predict_proba
    random_state
    score
    set_params
    verbose
    warm_start
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 1月7日
  • 已采纳回答 12月30日

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决