Patsy库查看使用公式语法建模后的输入特征X 与 预测Y

使用dmatrices函数:

import numpy as np
import pandas as pd

dataframe = pd.DataFrame(
    np.random.randint(0, 100, size=(100, 4)), columns=['col1', 'col2', 'col3', 'prep']
)
# 使用Patsy公示语法后的 X 与 Y 可以通过这个看:
from patsy import dmatrices
y, X = dmatrices('prep ~ col1 + col2 + col3', data=dataframe, return_type='dataframe')

猜你喜欢

转载自blog.csdn.net/weixin_35757704/article/details/114735709
y