程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

AssertionError: Pipeline finished with 0 models for some reason

发布于2025-01-04 15:01     阅读(907)     评论(0)     点赞(8)     收藏(4)


I'm facing error on one or more models failed. I try to add Text Feature, but unsuccessful on implementing it (Same error). The data is bank movements, the target is a column named "Categoria". The idea behind the code is to train the Tabular Data [id, Date, TextTransactionBrief, Charge, Deposit] and in base of that data try to categorize what the model may predict, the movement was about on the Target column (Payroll, Taxes, etc.).

The Code:

import pandas as pd
from lightautoml.automl.presets.text_presets import TabularAutoML
from lightautoml.tasks import Task

N_THREADS = 4  #threads

# Cargar el dataset desde el archivo CSV
data = pd.read_csv('C:/Dataset2023_24.csv')

# Verificar si hay valores NaN en la columna 'Categoria'
# Si es así, rellenarlos con algún valor por defecto o eliminarlos
data['Categoria'] = data['Categoria'].fillna('Desconocido')

# Definir las celdas roles: 'target' para la categoría y 'drop' para la columna Día
roles = {'target': 'Categoria', 'drop': ['id']}

# Definir la tarea: en este caso, se trata de un problema de clasificación multiclase
task = Task('multiclass')  # Cambiar a 'binary' si solo tienes dos clases

# Instanciar el modelo AutoML
automl = TabularAutoML(task=task,
                       cpu_limit=N_THREADS,
                       reader_params = {'n_jobs':N_THREADS},
                       general_params = {'use_algos':[['linear_l2','lgb','lgb_tuned']]},
                       tuning_params = {'max_tuning_time':25*60},
                       timeout=600) # Puedes ajustar el tiempo límite (en segundos)

# Entrenar el modelo
oof_pred = automl.fit_predict(data, roles=roles)

# Mostrar las predicciones del Out-of-Fold (OOF) predictions
print(oof_pred)

# Guardar el modelo entrenado si lo deseas
automl.save_model('trained_model.pkl')

# Para hacer predicciones con un nuevo conjunto de datos, puedes usar:
# test_data = pd.read_csv('path_to_test_data.csv')
# preds = automl.predict(test_data)
# print(preds)

This is the log:

Traceback (most recent call last):
  File "C:\Users\Compumex\Documents\Desarrollo\MainTabSBC_GPT.py", line 29, in <module>
    oof_pred = automl.fit_predict(data, roles=roles)
  File "C:\Users\Compumex\AppData\Local\Programs\Python\Python310\lib\site-packages\lightautoml\automl\presets\tabular_presets.py", line 721, in fit_predict
    oof_pred = super().fit_predict(train, roles=roles, cv_iter=cv_iter, valid_data=valid_data, verbose=verbose)
  File "C:\Users\Compumex\AppData\Local\Programs\Python\Python310\lib\site-packages\lightautoml\automl\presets\base.py", line 208, in fit_predict
    result = super().fit_predict(
  File "C:\Users\Compumex\AppData\Local\Programs\Python\Python310\lib\site-packages\lightautoml\automl\base.py", line 218, in fit_predict
    pipe_pred = ml_pipe.fit_predict(train_valid)
  File "C:\Users\Compumex\AppData\Local\Programs\Python\Python310\lib\site-packages\lightautoml\pipelines\ml\base.py", line 135, in fit_predict
    assert (
AssertionError: Pipeline finished with 0 models for some reason.
Probably one or more models failed

I work on adding text Features, as strings. Creating Features as numeric values as in other cases, will not work in this categorization application.

Also a slick version without adding parameters or use model

task = Task('multiclass')  # Cambiar a 'binary' si solo tienes dos clases

# Instanciar el modelo AutoML
automl = TabularAutoML(task=task, timeout=3600)  # Puedes ajustar el tiempo límite (en segundos)

# Entrenar el modelo
oof_pred = automl.fit_predict(data, roles=roles)

# Mostrar las predicciones del Out-of-Fold (OOF) predictions
print(oof_pred)

解决方案


暂无回答



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:https://www.pythonheidong.com/blog/article/2046757/11e89478b6012611bc4c/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

8 0
收藏该文
已收藏

评论内容:(最多支持255个字符)