0

我创建了以下功能 -

def Vectorize(df):
    for column in df.select_dtypes(include = "O").columns: # It will selects only Object type columns
        val = df[column].value_counts().to_dict() # 1st it takes value counts and then convert that to dictionary
        df[column] = df[column].map(val) # Here I mapped above function to  Each Column

    return df

应用上述功能后,我有以下输出,

6315 # No
35375 # Yes

以同样的方式,我也有其他分类列的输出。

但我想inverse_transform在部署中应用上述功能。所以我可以获得原始值,例如,

No # 6315
Yes # 35375

不幸的是,我无法做到这一点。

如果有人在这方面帮助我,将非常支持。

提前致谢

4

0 回答 0