How to add two binary classifiers after each other?


I am working on gender-age classifiers. I am done with gender classifier with accuracy 98.8% and I am working on age classifier. I need to merge both binary classifier in one classifier model to get one export.pkl file. How can I do that?

input is image face and output is predicting both gender and age.
Thank you,

I am trying this but I dont know if it is correct .
I export my model from pkl file that predict face but how can I pass it to new learn to predict something else (gender for example)?


You can try something like this

class My_Learner(Learner):
    def __init(self, gender, age):
        self.gender = gender
        self.age = age
    def predict(self, x):
        out1 = self.gender.predict(x)
        out2 = self.age.predict(x)
        return (out1, out2)

I don’t think you need to subclass the Learner class, making a python object class can also work. If you use python object class, then you can simply use pickle to export it.

1 Like