I would recommend taking a look at one or more of the classifier threads, like this one:
Despite the examples, the script isn’t restricted to fluorescence.
As with any scripts, they depend on your version of QuPath, and potentially on your exact project. Without sharing that, it isn’t possible to point you to anything closer.
General QuPath guide:
Pete’s multiplex classifier:
Machine learning classifiers can be run from a single command in a script once they are saved.