[Python] How do I increment a variable after each training iteration using the CatBoost...

Discussão em 'Python' iniciado por Stack, Junho 22, 2025.

  1. Stack

    Stack Membro Participativo

    As the title says, I'm trying to increment a variable after each training iteration using the Catboost Classifier, to update a progress bar in a gui, and I can't seem to find anything about it on the internet.

    So far I've tried to make a class containing an after_iteration function and passing that or an instance of it as a parameter the fit method:

    class Test_Callback():
    def after_iteration(self, info):
    global progress
    progress += 1
    test = Test_Callback()
    model.fit(train_data, eval_set=test_data, callbacks=[test])
    #Alternatively pass the class directly
    model.fit(train_data, eval_set=test_data, callbacks=[Test_Callback()])


    This does increment the variable, but also ends the training after a single iteration.
    I've also tried passing an after_iteration() - function to the callbacks parameter directly, but it just crashes the script.

    Continue reading...

Compartilhe esta Página