I'm inheriting from sklearn.ensemble import RandomForestClassifier, and I'm trying to print my new estimator:
class my_rf(RandomForestClassifier):
def __str__(self):
return "foo_" + RandomForestClassifier.__str__(self)
gives foo_my_rf()
I also tried:
class my_rf(RandomForestClassifier):
def __str__(self):
return "foo_" + super(RandomForestClassifier, self).__str__()
with the same result. expected is something pretty like sklearn default behaviour:
>>> a = RandomForestClassifier()
>>> print a
RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False)
>>>
This is also the result when I use print a.__str__().
What am I missing? Thanks.
related to How do I change the string representation of a Python class?