首页 > 解决方案 > 我如何使用 Python 来识别导致趋势增加和减少的因素(类似于 Power BI 的 Insights 功能)

问题描述

Power BI 的最佳功能之一是能够识别对趋势增加和减少最有影响的因素。据我了解,机器学习方法用于产生结果。更多信息:https ://docs.microsoft.com/en-us/power-bi/desktop-insights

使用 Python 识别对数据集中趋势增加和减少最有贡献的因素的最佳方法是什么?

标签: pythonmachine-learningtime-seriesanalyticspowerbi

解决方案


您的问题可能有很多答案,因为您可以使用线性和非线性方法来探索自变量变化与目标变量之间的依赖关系。具有高解释能力的最简单方法之一是基于决策树分类器的 python 包 scikit-learn 中的函数 .feature_importances_。一旦有了自变量 X 和目标 y,语法就非常简单:

    forest = ExtraTreesClassifier(n_estimators=250,
                                  random_state=0)

    forest.fit(X, y)
    importances = forest.feature_importances_

您可以在 http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html查看更多详细信息


推荐阅读