当前位置: 首页>>代码示例>>Python>>正文


Python Earth.summary_feature_importances方法代码示例

本文整理汇总了Python中pyearth.Earth.summary_feature_importances方法的典型用法代码示例。如果您正苦于以下问题:Python Earth.summary_feature_importances方法的具体用法?Python Earth.summary_feature_importances怎么用?Python Earth.summary_feature_importances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyearth.Earth的用法示例。


在下文中一共展示了Earth.summary_feature_importances方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Earth

# 需要导入模块: from pyearth import Earth [as 别名]
# 或者: from pyearth.Earth import summary_feature_importances [as 别名]
     10 * X[:, 3] +
     5 * X[:, 4] + numpy.random.uniform(size=m))
# Fit an Earth model
criteria = ('rss', 'gcv', 'nb_subsets')
model = Earth(max_degree=3,
              max_terms=10,
              minspan_alpha=.5,
              feature_importance_type=criteria,
              verbose=True)
model.fit(X, y)
rf = RandomForestRegressor()
rf.fit(X, y)
# Print the model
print(model.trace())
print(model.summary())
print(model.summary_feature_importances(sort_by='gcv'))

# Plot the feature importances
importances = model.feature_importances_
importances['random_forest'] = rf.feature_importances_
criteria = criteria + ('random_forest',)
idx = 1

fig = plt.figure(figsize=(20, 10))
labels = ['$x_{}$'.format(i) for i in range(n)]
for crit in criteria:
    plt.subplot(2, 2, idx)
    plt.bar(numpy.arange(len(labels)),
            importances[crit],
            align='center',
            color='red')
开发者ID:mehdidc,项目名称:py-earth,代码行数:33,代码来源:plot_feature_importance.py


注:本文中的pyearth.Earth.summary_feature_importances方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。