from xverse.transformer import MonotonicBinning
clf = MonotonicBinning()
X = df[['x1','x2']]
y = df[['y']]
if not isinstance(X, pd.DataFrame):
print("Not a dataframe")
else:
print("Is a DataFrame")
clf.fit(X, y)
ValueError Traceback (most recent call last)
in
10 print("Is a DataFrame")
11
---> 12 clf.fit(X, y)
~/opt/anaconda3/lib/python3.7/site-packages/xverse/transformer/_binning.py in fit(self, X, y)
76
77 #check datatype of X
---> 78 self.check_datatype(X)
79
80 #The length of X and Y should be equal
~/opt/anaconda3/lib/python3.7/site-packages/xverse/transformer/_binning.py in check_datatype(self, X)
62
63 if not isinstance(X, pd.DataFrame):
---> 64 raise ValueError("The input data must be pandas dataframe. But the input provided is " + str(type(X)))
65 return self
66
ValueError: The input data must be pandas dataframe. But the input provided is
ValueError: The input data must be pandas dataframe. But the input provided is <class 'str'>
I tried to debug but have been unable to figure out the reasoning behind this. Here's some sample code that recreates it:
df = pd.DataFrame({'x1': list(range(100)), 'x2': list(range(100)), 'y': list(range(100))})
df['y'] = np.where(df['x1']>50,1,0)
from xverse.transformer import MonotonicBinning clf = MonotonicBinning()
X = df[['x1','x2']] y = df[['y']]
if not isinstance(X, pd.DataFrame): print("Not a dataframe") else: print("Is a DataFrame")
clf.fit(X, y)
ValueError Traceback (most recent call last)