amphibian-dev / toad

ESC Team's credit scorecard tools.
https://toad.readthedocs.io
MIT License
491 stars 176 forks source link

toad.selection.select 可以处理字符串变量吗? #126

Open hailee8899 opened 1 year ago

hailee8899 commented 1 year ago

官方文档 https://toad.readthedocs.io/en/latest/tutorial.html 这里的例子并没有说明不支持处理字符串变量。

但是我用了同样的代码和数据,从代码的报错信息来看是不支持的,请大家帮忙解答一下疑惑。

Aryooo commented 1 year ago

同样的问题,甚至删掉所有字符串还是会报错

AnnaYang2223 commented 12 months ago

我也遇到了这个问题,官方文档上的展示数据中不就有字符串类型的数据吗,但是我运行时报错 数据 下面是报错内容: selected_data, drop_lst = toad.selection.select( data_tr,target = 'TARGET',empty = 0.5, iv=0.05, corr=0.7,return_drop=True ) Traceback (most recent call last):

Cell In[15], line 1 selected_data, drop_lst = toad.selection.select(

File D:\anaconda3\Lib\site-packages\toad\selection.py:517 in select frame, corr_drop = drop_corr(frame, target = target, threshold = corr, by = weights, return_drop = True, exclude = exclude)

File D:\anaconda3\Lib\site-packages\toad\selection.py:329 in drop_corr corr = f.corr().abs()

File D:\anaconda3\Lib\site-packages\pandas\core\frame.py:10054 in corr mat = data.to_numpy(dtype=float, na_value=np.nan, copy=False)

File D:\anaconda3\Lib\site-packages\pandas\core\frame.py:1838 in to_numpy result = self._mgr.as_array(dtype=dtype, copy=copy, na_value=na_value)

File D:\anaconda3\Lib\site-packages\pandas\core\internals\managers.py:1732 in as_array arr = self._interleave(dtype=dtype, na_value=na_value)

File D:\anaconda3\Lib\site-packages\pandas\core\internals\managers.py:1794 in _interleave result[rl.indexer] = arr

ValueError: could not convert string to float: 'F'

Secbone commented 11 months ago

@hailee8899 @Aryooo @AnnaYang2223 I think its same to #133 , the issue with pandas >=2.0.x, please upgrade toad to 0.1.3 and have a try. 😄

AnnaYang2223 commented 11 months ago

thanks