Baseline-Modell

Eine Kaggle-Competition in Python gewinnen

Yauhen Babakhin

Kaggle Grandmaster

Modellierungsphase

 

Komponenten der Modellierungsphase

Eine Kaggle-Competition in Python gewinnen

Modellierungsphase

 

Baseline-Modell in der Modellierungsphase

Eine Kaggle-Competition in Python gewinnen

NYC-Taxi-Validierung

# Daten lesen
taxi_train = pd.read_csv('taxi_train.csv')
taxi_test = pd.read_csv('taxi_test.csv')
from sklearn.model_selection import train_test_split

# Lokale Validierung erstellen
validation_train, validation_test = train_test_split(taxi_train,
                                                     test_size=0.3,
                                                     random_state=123)
Eine Kaggle-Competition in Python gewinnen

Baseline-Modell I

import numpy as np
# Allen Testbeobachtungen den mittleren Fahrpreis zuweisen
taxi_test['fare_amount'] = np.mean(taxi_train.fare_amount)

# Vorhersagen in Datei schreiben taxi_test[['id','fare_amount']].to_csv('mean_sub.csv', index=False)
Validierungs-RMSE Public-LB-RMSE Public-LB-Platz
9.986 9.409 1449 / 1500
Eine Kaggle-Competition in Python gewinnen

Baseline-Modell II

# Mittleren Fahrpreis je Gruppe berechnen
naive_prediction_groups = taxi_train.groupby('passenger_count').fare_amount.mean()
# Vorhersagen für den Testsatz erstellen
taxi_test['fare_amount'] = taxi_test.passenger_count.map(naive_prediction_groups)

# Vorhersagen in Datei schreiben taxi_test[['id','fare_amount']].to_csv('mean_group_sub.csv', index=False)
Validierungs-RMSE Public-LB-RMSE Public-LB-Platz
9.978 9.407 1411 / 1500
Eine Kaggle-Competition in Python gewinnen

Baseline-Modell III

# Nur numerische Features wählen
features = ['pickup_longitude', 'pickup_latitude',
            'dropoff_longitude', 'dropoff_latitude', 'passenger_count']
from sklearn.ensemble import GradientBoostingRegressor

# Gradient-Boosting-Modell trainieren
gb = GradientBoostingRegressor()
gb.fit(taxi_train[features], taxi_train.fare_amount)

# Vorhersagen für Testdaten erstellen taxi_test['fare_amount'] = gb.predict(taxi_test[features])
Eine Kaggle-Competition in Python gewinnen

Baseline-Modell III

# Vorhersagen in Datei schreiben
taxi_test[['id','fare_amount']].to_csv('gb_sub.csv', index=False)
Validierungs-RMSE Public-LB-RMSE Public-LB-Platz
5.996 4.595 1109 / 1500
Eine Kaggle-Competition in Python gewinnen

Zwischenergebnisse

 

Modell Validierungs-RMSE Public-LB-RMSE
Einfacher Mittelwert 9.986 9.409
Gruppen-Mittelwert 9.978 9.407
Gradient Boosting 5.996 4.595
Eine Kaggle-Competition in Python gewinnen

Korrelation mit der Public Leaderboard

 

Modell Validierungs-RMSE Public-LB-RMSE
Modell A 3.500 3.800
Modell B 3.300 4.100
Modell C 3.200 3.900

 

Modell Validierungs-RMSE Public-LB-RMSE
Modell A 3.400 3.900
Modell B 3.100 3.400
Modell C 2.900 3.300
Eine Kaggle-Competition in Python gewinnen

Lass uns üben!

Eine Kaggle-Competition in Python gewinnen

Preparing Video For Download...