由于pycaret的设置功能导致文件结束错误

时间:2021-04-25 11:51:59

标签: python data-science ipywidgets pycaret

我正在制作 Automl 的对象,我正在调用显示文本小部件的函数初始设置,当提交文本时,它调用 target_submit_handler,后者在内部调用 classification_setup,后者调用 pycaret 的 setup() library 但是,当调用 setup 函数时,我收到了文件结尾错误:

enter image description here

from pycaret.classification import *

class AutoMl():
    def __init__(self):
        self.dataframe=pd.DataFrame()
        self.w=None
        self.setup=None
            
    def classification_setup(self,data,target):
        x=setup(self.dataframe, "Species")     //this fucntion is of pycaret library which displays the end of file er
        
    def target_submit_handler(self,text):
#         print(self.dataframe,self.target.value) I am geting the correct dataframe and target column name 
        self.classification_setup(data=self.dataframe,target="Species")
        
    def initial_setup(self,dataframe=None,target=None):
        if(dataframe==None and target==None):
            if(self.dataframe.empty!=True):
                self.target = widgets.Text(description = 'Enter the target column')
                self.target.on_submit(self.target_submit_handler)
                display(self.target)

f=AutoMl()
f.initial_setup() //end of file error 

这是文件结尾错误:

enter image description here

1 个答案:

答案 0 :(得分:0)

只需将 classfication_setup 函数中的代码替换为以下代码即可。

x=setup(self.dataframe, "Species", silent=True)

阅读文档 https://pycaret.org/setup/