Regressor to estimate probability from samples What is a good way to estimate probabilities in a dataset of samples? Each sample is a measurement, that is usually 1 or 0. The goal is to calculate probabilies based on all feature rows.

Simple example dataset:

    feature   label
    dog       1
    dog       0
    dog       0
    dog       0
    cat       1
    cat       0


Expected Output:

    feature  result
    dog      0.25
    cat      0.5


The real dataset has around 50 features.
Assume that X are features and y - labels

#Put algorithm as you wish 
from sklearn.ensemble import RandomForestClassifier
clf = RandomForestClassifier(max_depth=2, random_state=0)
clf.fit(X_train, y_train )


clf.predict_proba(X_test) # there you will get probabilities of the class