sberbank-ai-lab / LightAutoML

LAMA - automatic model creation framework
Apache License 2.0
887 stars 92 forks source link

TabularAutoML object has no attribute 'reader' #93

Closed AlexanderLavelle closed 2 years ago

AlexanderLavelle commented 2 years ago

I am currently having an issue where I have replicated another project. After finishing the model, when trying to predict, I get:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:\Users\ALEXAN~1\AppData\Local\Temp/ipykernel_21260/2512481675.py in <module>
----> 1 testPreds = automl_rd.predict(test)

~\.conda\envs\threeNine2\lib\site-packages\lightautoml\report\report_deco.py in predict(self, *args, **kwargs)
    729         self._n_test_sample += 1
    730         # get predictions
--> 731         test_preds = self._model.predict(*args, **kwargs)
    732 
    733         test_data = kwargs["test"] if "test" in kwargs else args[0]

~\.conda\envs\threeNine2\lib\site-packages\lightautoml\automl\presets\tabular_presets.py in predict(self, data, features_names, batch_size, n_jobs, return_all_predictions)
    543         if batch_size is None and n_jobs == 1:
    544             data, _ = read_data(data, features_names, self.cpu_limit, read_csv_params)
--> 545             pred = super().predict(data, features_names, return_all_predictions)
    546             return cast(NumpyDataset, pred)
    547 

~\.conda\envs\threeNine2\lib\site-packages\lightautoml\automl\base.py in predict(self, data, features_names, return_all_predictions)
    290 
    291         """
--> 292         dataset = self.reader.read(data, features_names=features_names, add_array_attrs=False)
    293 
    294         for n, level in enumerate(self.levels, 1):

AttributeError: 'TabularAutoML' object has no attribute 'reader'

I'm not sure how this error occurs as the TabularModel was instantiated with reader?

Thank you in advance

alexmryzhkov commented 2 years ago

@AlexanderLavelle sounds interesting - you are right that each TabularAutoML model has the reader by default. From your code I can see that you are using the ReportDeco decorated TabularAutoML object, but this should not change the situation.

Could you please provide us with the code for the task, roles and model creation+training code? It can help us to find the key.

Alex

AlexanderLavelle commented 2 years ago

Task:

task = Task('binary', )

roles:

roles = {
    'target': TARGET_NAME,
    #'drop': ['id']

}

model:

RD = ReportDeco(output_path = 'tabularAutoML_model_report')

automl_rd = RD(
    TabularAutoML(
        task = task, 
        timeout = TIMEOUT,
        cpu_limit = N_THREADS,
        reader_params = {'n_jobs': N_THREADS, 'cv': N_FOLDS, 'random_state': RANDOM_STATE},
        general_params={'use_algos': [['lgb', 'lgb_tuned', 'cb', 'linear_l2']]},
        #lgb_params = {'default_params':{gpu_device_id':0, 'gpu_platform_id':0}},
        gpu_ids=0, 
        memory_limit=35
    )
)

prediction: oof_pred = automl_rd.fit_predict(trainDf, roles = roles, verbose = 4)

github-actions[bot] commented 2 years ago

Stale issue message