projektAI/venv/Lib/site-packages/mlxtend/externals/name_estimators.py
2021-06-06 22:13:05 +02:00

33 lines
924 B
Python

from ..externals import six
from collections import defaultdict
# The :mod:`sklearn.pipeline` module implements utilities to build a composite
# estimator, as a chain of transforms and estimators.
# Author: Edouard Duchesnay
# Gael Varoquaux
# Virgile Fritsch
# Alexandre Gramfort
# Lars Buitinck
# Licence: BSD
def _name_estimators(estimators):
"""Generate names for estimators."""
names = [type(estimator).__name__.lower() for estimator in estimators]
namecount = defaultdict(int)
for _, name in zip(estimators, names):
namecount[name] += 1
for k, v in list(six.iteritems(namecount)):
if v == 1:
del namecount[k]
for i in reversed(range(len(estimators))):
name = names[i]
if name in namecount:
names[i] += "-%d" % namecount[name]
namecount[name] -= 1
return list(zip(names, estimators))