Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Snow White and the Dwarf Ensemble

Johannes Kolbe
December 12, 2024
2

Snow White and the Dwarf Ensemble

A fairy tale introduction to the concept of Ensemble Learning

Johannes Kolbe

December 12, 2024
Tweet

Transcript

  1. About Me Johannes Kolbe • Data Scientist at celebrate company

    ◦ Focus on Computer Vision ◦ Some Expertise in NLP • M.Sc. in Computer Science at TU Berlin • Hugging Face Fellow ◦ Leading CV Study Group on discord: https://huggingface.co/join/discord ◦ Past Study Groups: https://github.com/huggingface/community-events/ tree/main/computer-vision-study-group @[email protected] linkedin.com/in/johko github.com/johko huggingface.co/johko
  2. Soft Voting 80% Ruby 15% Amethyst 5% Garnet 40% Amethyst

    35% Ruby 25% Garnet 95% Ruby 3% Amethyst 2% Garnet 50% Garnet 40% Ruby 10% Amethyst 50% Amethyst 25% Garnet 25% Ruby 80% Ruby 15% Amethyst 5% Garnet 75% Ruby 15% Garnet 10% Amethyst 62% Ruby 20% Amethyst 18% Garnet P
  3. Voting Classifier import numpy as np from sklearn.linear_model import LogisticRegression

    from sklearn.naive_bayes import GaussianNB from sklearn.ensemble import RandomForestClassifier, VotingClassifier clf1 = LogisticRegression(multi_class='multinomial', random_state=1) clf2 = RandomForestClassifier(n_estimators=50, random_state=1) clf3 = GaussianNB() X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) y = np.array([1, 1, 1, 2, 2, 2]) eclf1 = VotingClassifier(estimators=[('lr', clf1), ('rf', clf2), ('gnb', clf3)], voting='hard') eclf1 = eclf1.fit(X, y) eclf1.predict(X) https://scikit-learn.org/stable/modules/g enerated/sklearn.ensemble.VotingClas sifier.html
  4. Bagging Classifier from sklearn.ensemble import BaggingClassifier from sklearn.datasets import make_classification

    X, y = make_classification(n_samples=100, n_features=4, n_informative=2, n_redundant=0, random_state=0, shuffle=False) clf = BaggingClassifier(n_estimators=10, random_state=0).fit(X, y) clf.predict([[0, 0, 0, 0]]) clf.score(X, y) https://scikit-learn.org/stable/modules/g enerated/sklearn.ensemble.RandomFo restClassifier.html#sklearn.ensemble.R andomForestClassifier
  5. Adaboost Classifier from sklearn.ensemble import AdaBoostClassifier from sklearn.datasets import make_classification

    X, y = make_classification(n_samples=1000, n_features=4, n_informative=2, n_redundant=0, random_state=0, shuffle=False) clf = AdaBoostClassifier(n_estimators=100) clf.fit(X, y) clf.predict([[0, 0, 0, 0]]) clf.score(X, y) https://scikit-learn.org/stable/modules/g enerated/sklearn.ensemble.AdaBoostC lassifier.html#sklearn.ensemble.AdaBo ostClassifier
  6. Stacking Classifier from sklearn.datasets import load_iris from sklearn.ensemble import BaggingClassifier

    from sklearn.ensemble import AdaBoostClassifier from sklearn.linear_model import LogisticRegression from sklearn.ensemble import StackingClassifier X, y = load_iris(return_X_y=True) estimators = [ ('rf', BaggingClassifier(n_estimators=10, random_state=42)), ('svr', AdaBoostClassifier(n_estimators=100)) ] clf = StackingClassifier( estimators=estimators, final_estimator=LogisticRegression() ) from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, random_state=42) clf.fit(X_train, y_train).score(X_test, y_test) https://scikit-learn.org/stable/modules/g enerated/sklearn.ensemble.StackingCl assifier.html
  7. CRÉDITOS: Esta plantilla para presentaciones es una creación de Slidesgo,

    e incluye iconos de Flaticon, infografías e imágenes de Freepik Gracia s ¿Tienes alguna pregunta? [email protected] +91 620 421 838 tupaginaweb.com Por favor, conserva esta diapositiva para atribuirnos Slide Design from slidesgo: