我做了一个逻辑回归,并添加了StandardScalar()-用于归一化模型。我得到了系数,和原来的系数有什么不同。(这是一个我看到结果WO Standardscalar()的例子)
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
# Create LogisticRegression model
log_model = make_pipeline(StandardScaler(), LogisticRegression())
# Fit our data
log_model.fit(X,Y)
# Check our accuracy
print(log_model.score(X,Y))
# Check percentage of women that had affairs
print(Y.mean())
# Use zip to bring the column names and the np.transpose function to bring together the coefficients from the model
coeff_df = pd.DataFrame(zip(X.columns, np.transpose(log_model.steps[1][1].coef_)))
我想得到原始的系数:我尝试了以下操作:
print(log_model.steps[0][1].inverse_transform(log_model.steps[1][1].coef_, copy=None))
我试过逆变换,但完全错误。你能帮我吗,先谢了
1条答案
按热度按时间2skhul331#
不能使用
inverse_transform
:这意味着将转换后的 * 数据 * 返回到原始比例,而不是系数。关于系数变换,参见my answer to another question。