Hellow! How can I calculate Optimal Binning in Python for the list of variables, not only for one variable ?
I havce example DataFrame like below:
df = pd.DataFrame({"var1" : ["a", "b"], "var2" : ["c", "d"], "var3" : ["e", "f"]})
For instance I have function like below:
def OBin(df, target, rest_variabls, dtypes):
#Data
x = df_abt[rest_variabls].values
y = df_abt[target]
#WoE
optb = OptimalBinning(name=df, dtype=dtypes, solver="cp")
optb.fit(x, y)
optb.binning_table.build()
And when I want to use this function like below:
OBin(df, "target", ["var1", "var2"], "categorical")
Neverteless I have type error like below in optb.fit(x, y)
, how can I do ? Types of var1 and var2 is object.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…