Rozszerzamy możliwości z mlxtend!

Metody zespołowe w Pythonie

Román de las Heras

Data Scientist, Appodeal

Mlxtend

logo mlxtend

  • Rozszerzenia Uczenia Maszynowego
  • Narzędzia i funkcje dla Data Science:
    • Selekcja cech
    • Metody ensemble
    • Wizualizacja
    • Ocena modeli
  • Intuicyjne i przyjazne API
  • Zgodność z estymatorami scikit-learn
1 Raschka, Sebastian (2018) MLxtend: Providing machine learning and data science utilities and extensions to Python's scientific computing stack: https://rasbt.github.io/mlxtend/
Metody zespołowe w Pythonie

Implementacja stackingu z mlxtend

stackingclassification_overview.png

Charakterystyka:

  • Poszczególne estymatory są trenowane na pełnym zbiorze cech
  • Meta-estymator jest trenowany wyłącznie na prognozach jako meta-cechach
  • Meta-estymator może być trenowany z etykietami lub prawdopodobieństwami jako zmienną docelową
Metody zespołowe w Pythonie

StackingClassifier z mlxtend

from mlxtend.classifier 
    import StackingClassifier
# Instantiate the 1st-layer classifiers
clf1 = Classifier1(params1)
clf2 = Classifier2(params2)
...
clfN = ClassifierN(paramsN)
# Instantiate the 2nd-layer classifier
clf_meta = ClassifierMeta(paramsMeta)
# Build the Stacking classifier
clf_stack = StackingClassifier(
   classifiers=[clf1, clf2, ... clfN],
   meta_classifier=clf_meta,
   use_probas=False,
   use_features_in_secondary=False)
# Use the fit and predict methods
# like with scikit-learn estimators
clf_stack.fit(X_train, y_train)
pred = clf_stack.predict(X_test)
Metody zespołowe w Pythonie

StackingRegressor z mlxtend

from mlxtend.regressor 
    import StackingRegressor
# Instantiate the 1st-layer regressors
reg1 = Regressor1(params1)
reg2 = Regressor2(params2)
...
regN = RegressorN(paramsN)
# Instantiate the 2nd-layer regressor
reg_meta = RegressorMeta(paramsMeta)
# Build the Stacking regressor
reg_stack = StackingRegressor(
   regressors=[reg1, reg2, ... regN],
   meta_regressor=reg_meta,
   use_features_in_secondary=False)
# Use the fit and predict methods
# like with scikit-learn estimators
reg_stack.fit(X_train, y_train)
pred = reg_stack.predict(X_test)
Metody zespołowe w Pythonie

Rozszerzamy możliwości z mlxtend!

Metody zespołowe w Pythonie

Preparing Video For Download...