【问题标题】:Standardize features to calculate variance inflation factors标准化特征以计算方差膨胀因子
【发布时间】:2021-03-29 09:24:33
【问题描述】:

我正在计算方差膨胀因子

from patsy import dmatrices
from statsmodels.stats.outliers_influence import variance_inflation_factor
y, X = dmatrices('A ~ B + C + D + E + F + G, data=df, return_type='dataframe')

vif = pd.DataFrame()
vif['VIF'] = [variance_inflation_factor(X.values, i) for i in range(X.shape[1])]
vif['variable'] = X.columns
vif

我现在如何使用 StandardScaler() 对特征进行标准化,然后重新计算标准化特征的方差膨胀因子?

【问题讨论】:

    标签: python statsmodels sklearn-pandas standardized


    【解决方案1】:

    使用“patsy import dmatrices”已经可以扩展和标准化功能。因此不需要对 StandardScaler() 做第二步

    【讨论】:

      【解决方案2】:

      查看 patsy 的 stateful transformsstandardize

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-12-26
        • 2017-07-28
        • 1970-01-01
        • 2021-01-11
        • 1970-01-01
        • 2014-07-02
        • 2020-01-28
        • 1970-01-01
        相关资源
        最近更新 更多