import pandas as pd
import numpy as np
X = pd.read_csv('xtraining_SC_GGP_AXA_FR.csv')
y = pd.read_csv('ytraining_SC_GGP_AXA_FR.csv')
Xscore = pd.read_csv('xscoring_SC_GGP_AXA_FR.csv')
y.describe()
target | |
---|---|
count | 1000.000000 |
mean | 0.170000 |
std | 0.375821 |
min | 0.000000 |
25% | 0.000000 |
50% | 0.000000 |
75% | 0.000000 |
max | 1.000000 |
X.describe()
age | surface | montant_assure | nb_sinistres_depuis_ouverture | cotisation_n-1 | cotisation_n | duree_contrat | duree_dernier_sinistre | duree_zero_sinistre | depa_01 | ... | cate_Artisans, | cate_Cadres | cate_Employés | cate_Inactifs | cate_Ouvriers | type_Appartement | type_Maison | stat_Locataire | stat_Occupant | stat_Propriétaire | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | ... | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.00000 | 1000.00000 | 1000.000000 | 1000.000000 | 1000.000000 |
mean | 42.198000 | 86.863400 | 22461.069000 | 1.492000 | 272.762170 | 286.046570 | 4883.704000 | 40.023000 | 3444.616000 | 0.009000 | ... | 0.174000 | 0.162000 | 0.341000 | 0.067000 | 0.125000 | 0.63400 | 0.36600 | 0.586000 | 0.028000 | 0.386000 |
std | 14.710853 | 28.498626 | 9076.273609 | 0.954383 | 76.378759 | 82.097481 | 2716.954916 | 41.793913 | 2826.615494 | 0.094488 | ... | 0.379299 | 0.368635 | 0.474283 | 0.250147 | 0.330884 | 0.48195 | 0.48195 | 0.492795 | 0.165055 | 0.487074 |
min | 15.000000 | 31.270000 | 4478.000000 | 0.000000 | 175.380000 | 181.360000 | 49.000000 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.00000 | 0.00000 | 0.000000 | 0.000000 | 0.000000 |
25% | 31.000000 | 66.235000 | 15574.500000 | 1.000000 | 211.842500 | 220.230000 | 2637.750000 | 1.000000 | 565.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.00000 | 0.00000 | 0.000000 | 0.000000 | 0.000000 |
50% | 42.000000 | 80.605000 | 21201.000000 | 1.000000 | 227.525000 | 240.705000 | 4819.000000 | 29.000000 | 3111.500000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 1.00000 | 0.00000 | 1.000000 | 0.000000 | 0.000000 |
75% | 52.000000 | 104.842500 | 27597.000000 | 2.000000 | 360.062500 | 372.647500 | 7353.250000 | 68.000000 | 6037.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 1.00000 | 1.00000 | 1.000000 | 0.000000 | 1.000000 |
max | 94.000000 | 179.780000 | 55852.000000 | 4.000000 | 440.870000 | 510.490000 | 9526.000000 | 202.000000 | 9429.000000 | 1.000000 | ... | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 |
8 rows × 121 columns
Xscore.describe()
age | surface | montant_assure | nb_sinistres_depuis_ouverture | cotisation_n-1 | cotisation_n | duree_contrat | duree_dernier_sinistre | duree_zero_sinistre | depa_01 | ... | cate_Artisans, | cate_Cadres | cate_Employés | cate_Inactifs | cate_Ouvriers | type_Appartement | type_Maison | stat_Locataire | stat_Occupant | stat_Propriétaire | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | 300.00000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | ... | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 |
mean | 42.59000 | 86.704767 | 22894.856667 | 1.466667 | 274.989200 | 288.086200 | 4810.156667 | 34.820000 | 3174.016667 | 0.010000 | ... | 0.156667 | 0.186667 | 0.370000 | 0.023333 | 0.116667 | 0.626667 | 0.373333 | 0.560000 | 0.016667 | 0.423333 |
std | 14.62949 | 30.453970 | 9374.614330 | 0.992727 | 80.104622 | 86.567491 | 2673.566074 | 39.671826 | 2745.057079 | 0.099665 | ... | 0.364094 | 0.390295 | 0.483611 | 0.151212 | 0.321559 | 0.484498 | 0.484498 | 0.497216 | 0.128233 | 0.494913 |
min | 15.00000 | 29.360000 | 7217.000000 | 0.000000 | 172.470000 | 180.700000 | 88.000000 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
25% | 31.00000 | 63.672500 | 15281.750000 | 1.000000 | 212.580000 | 221.105000 | 2521.000000 | 1.000000 | 472.500000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
50% | 43.00000 | 78.530000 | 20810.500000 | 1.000000 | 227.590000 | 240.395000 | 5101.000000 | 19.500000 | 2566.500000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 |
75% | 54.00000 | 107.357500 | 28494.750000 | 2.000000 | 364.185000 | 370.237500 | 7099.500000 | 62.000000 | 5547.250000 | 0.000000 | ... | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 1.000000 | 1.000000 | 1.000000 | 0.000000 | 1.000000 |
max | 86.00000 | 169.560000 | 50948.000000 | 5.000000 | 450.560000 | 599.500000 | 9530.000000 | 189.000000 | 9019.000000 | 1.000000 | ... | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
8 rows × 121 columns
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
X = scaler.fit_transform(X)
Xscore = scaler.transform(Xscore)
pd.DataFrame(X).describe()
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | ... | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.000000 | 1000.00000 | 1000.00000 | 1000.000000 | 1000.000000 | 1000.000000 |
mean | 0.344278 | 0.374341 | 0.350042 | 0.373000 | 0.366802 | 0.318071 | 0.510151 | 0.198134 | 0.365321 | 0.009000 | ... | 0.174000 | 0.162000 | 0.341000 | 0.067000 | 0.125000 | 0.63400 | 0.36600 | 0.586000 | 0.028000 | 0.386000 |
std | 0.186213 | 0.191897 | 0.176671 | 0.238596 | 0.287690 | 0.249438 | 0.286689 | 0.206901 | 0.299779 | 0.094488 | ... | 0.379299 | 0.368635 | 0.474283 | 0.250147 | 0.330884 | 0.48195 | 0.48195 | 0.492795 | 0.165055 | 0.487074 |
min | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.00000 | 0.00000 | 0.000000 | 0.000000 | 0.000000 |
25% | 0.202532 | 0.235439 | 0.215994 | 0.250000 | 0.137340 | 0.118099 | 0.273161 | 0.004950 | 0.059922 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.00000 | 0.00000 | 0.000000 | 0.000000 | 0.000000 |
50% | 0.341772 | 0.332200 | 0.325515 | 0.250000 | 0.196410 | 0.180309 | 0.503324 | 0.143564 | 0.329993 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 1.00000 | 0.00000 | 1.000000 | 0.000000 | 0.000000 |
75% | 0.468354 | 0.495404 | 0.450014 | 0.500000 | 0.695629 | 0.581191 | 0.770734 | 0.336634 | 0.640259 | 0.000000 | ... | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 1.00000 | 1.00000 | 1.000000 | 0.000000 | 1.000000 |
max | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | ... | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 |
8 rows × 121 columns
pd.DataFrame(Xscore).describe()
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | ... | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 | 300.000000 |
mean | 0.349241 | 0.373273 | 0.358486 | 0.366667 | 0.375190 | 0.324268 | 0.502391 | 0.172376 | 0.336623 | 0.010000 | ... | 0.156667 | 0.186667 | 0.370000 | 0.023333 | 0.116667 | 0.626667 | 0.373333 | 0.560000 | 0.016667 | 0.423333 |
std | 0.185183 | 0.205063 | 0.182478 | 0.248182 | 0.301724 | 0.263019 | 0.282111 | 0.196395 | 0.291129 | 0.099665 | ... | 0.364094 | 0.390295 | 0.483611 | 0.151212 | 0.321559 | 0.484498 | 0.484498 | 0.497216 | 0.128233 | 0.494913 |
min | 0.000000 | -0.012861 | 0.053315 | 0.000000 | -0.010961 | -0.002005 | 0.004115 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
25% | 0.202532 | 0.218184 | 0.210296 | 0.250000 | 0.140118 | 0.120758 | 0.260842 | 0.004950 | 0.050111 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
50% | 0.354430 | 0.318228 | 0.317914 | 0.250000 | 0.196655 | 0.179367 | 0.533080 | 0.096535 | 0.272192 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 |
75% | 0.493671 | 0.512339 | 0.467488 | 0.500000 | 0.711157 | 0.573869 | 0.743959 | 0.306931 | 0.588318 | 0.000000 | ... | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 1.000000 | 1.000000 | 1.000000 | 0.000000 | 1.000000 |
max | 0.898734 | 0.931183 | 0.904543 | 1.250000 | 1.036499 | 1.270440 | 1.000422 | 0.935644 | 0.956517 | 1.000000 | ... | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
8 rows × 121 columns
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
len(X_test)/len(X)
0.2
pd.DataFrame(X_train).describe()
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | ... | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.000000 | 800.00000 | 800.00000 | 800.000000 | 800.000000 | 800.000000 |
mean | 0.344747 | 0.373978 | 0.352949 | 0.368750 | 0.368131 | 0.318731 | 0.506860 | 0.197333 | 0.358045 | 0.006250 | ... | 0.172500 | 0.165000 | 0.342500 | 0.073750 | 0.122500 | 0.63375 | 0.36625 | 0.580000 | 0.027500 | 0.392500 |
std | 0.185341 | 0.189740 | 0.180912 | 0.234917 | 0.286502 | 0.249066 | 0.288273 | 0.201852 | 0.298163 | 0.078859 | ... | 0.378051 | 0.371413 | 0.474843 | 0.261527 | 0.328068 | 0.48208 | 0.48208 | 0.493867 | 0.163637 | 0.488613 |
min | 0.000000 | 0.010774 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.001688 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.00000 | 0.00000 | 0.000000 | 0.000000 | 0.000000 |
25% | 0.202532 | 0.235439 | 0.215002 | 0.250000 | 0.138178 | 0.119444 | 0.266092 | 0.004950 | 0.057376 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.00000 | 0.00000 | 0.000000 | 0.000000 | 0.000000 |
50% | 0.341772 | 0.335903 | 0.328045 | 0.250000 | 0.199066 | 0.180445 | 0.499156 | 0.153465 | 0.312971 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 1.00000 | 0.00000 | 1.000000 | 0.000000 | 0.000000 |
75% | 0.468354 | 0.488570 | 0.460938 | 0.500000 | 0.694037 | 0.581207 | 0.768756 | 0.336634 | 0.627559 | 0.000000 | ... | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 1.00000 | 1.00000 | 1.000000 | 0.000000 | 1.000000 |
max | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | ... | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 |
8 rows × 121 columns
pd.DataFrame(X_test).describe()
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | ... | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 | 200.000000 |
mean | 0.342405 | 0.375793 | 0.338414 | 0.390000 | 0.361484 | 0.315430 | 0.523317 | 0.201337 | 0.394428 | 0.020000 | ... | 0.180000 | 0.150000 | 0.335000 | 0.040000 | 0.135000 | 0.635000 | 0.365000 | 0.610000 | 0.030000 | 0.360000 |
std | 0.190125 | 0.200777 | 0.158461 | 0.252674 | 0.293059 | 0.251531 | 0.280589 | 0.226485 | 0.305180 | 0.140351 | ... | 0.385152 | 0.357967 | 0.473175 | 0.196451 | 0.342581 | 0.482638 | 0.482638 | 0.488974 | 0.171015 | 0.481205 |
min | 0.000000 | 0.000000 | 0.053295 | 0.000000 | 0.016498 | 0.028742 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
25% | 0.215190 | 0.235506 | 0.231868 | 0.250000 | 0.129421 | 0.111909 | 0.287802 | 0.004950 | 0.077871 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
50% | 0.341772 | 0.319541 | 0.310498 | 0.500000 | 0.185242 | 0.179564 | 0.532605 | 0.123762 | 0.390550 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 |
75% | 0.443038 | 0.518955 | 0.424106 | 0.500000 | 0.707051 | 0.580143 | 0.772475 | 0.329208 | 0.671148 | 0.000000 | ... | 0.000000 | 0.000000 | 1.000000 | 0.000000 | 0.000000 | 1.000000 | 1.000000 | 1.000000 | 0.000000 | 1.000000 |
max | 0.949367 | 0.982291 | 0.834294 | 1.000000 | 0.890956 | 0.831921 | 0.996307 | 0.930693 | 0.968607 | 1.000000 | ... | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
8 rows × 121 columns
pd.DataFrame(y_train).describe()
target | |
---|---|
count | 800.000000 |
mean | 0.170000 |
std | 0.375868 |
min | 0.000000 |
25% | 0.000000 |
50% | 0.000000 |
75% | 0.000000 |
max | 1.000000 |
pd.DataFrame(y_test).describe()
target | |
---|---|
count | 200.000000 |
mean | 0.170000 |
std | 0.376575 |
min | 0.000000 |
25% | 0.000000 |
50% | 0.000000 |
75% | 0.000000 |
max | 1.000000 |
from imblearn.over_sampling import SMOTE
sm = SMOTE(random_state=42)
x_train_res, y_train_res = sm.fit_sample(X_train, y_train)
print(y_train.value_counts(), y_train_res.value_counts())
target 0.0 664 1.0 136 dtype: int64 target 1.0 664 0.0 664 dtype: int64
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report
model_RF = RandomForestClassifier(n_estimators=1000)
model_RF.fit(x_train_res , y_train_res)
y_pred = model_RF.predict(X_test)
target_names = ['non résilié', 'resilié'] # 1 résilié, 0 pas résilié
print(classification_report(y_test, y_pred,target_names=target_names))
precision recall f1-score support non résilié 0.93 0.92 0.92 166 resilié 0.62 0.68 0.65 34 accuracy 0.88 200 macro avg 0.78 0.80 0.79 200 weighted avg 0.88 0.88 0.88 200
from sklearn.ensemble import GradientBoostingClassifier
model_GB = GradientBoostingClassifier(n_estimators=1000)
model_GB.fit(x_train_res , y_train_res)
y_pred = model_GB.predict(X_test)
target_names = ['non résilié', 'resilié']
print(classification_report(y_test, y_pred,target_names=target_names))
precision recall f1-score support non résilié 0.94 0.91 0.92 166 resilié 0.62 0.71 0.66 34 accuracy 0.88 200 macro avg 0.78 0.81 0.79 200 weighted avg 0.88 0.88 0.88 200
from sklearn.ensemble import AdaBoostClassifier
model_AB = AdaBoostClassifier()
model_AB.fit(x_train_res , y_train_res)
y_pred = model_AB.predict(X_test)
target_names = ['non résilié', 'resilié']
print(classification_report(y_test, y_pred,target_names=target_names))
precision recall f1-score support non résilié 0.93 0.88 0.90 166 resilié 0.53 0.68 0.60 34 accuracy 0.84 200 macro avg 0.73 0.78 0.75 200 weighted avg 0.86 0.84 0.85 200
from bayes_opt import BayesianOptimization
from sklearn.metrics import f1_score
# Basic Example : https://github.com/fmfn/BayesianOptimization/blob/master/examples/basic-tour.ipynb
def black_box_function(n_estimators, learning_rate=0):
model = AdaBoostClassifier(n_estimators = int(n_estimators),
learning_rate = 10**learning_rate,
random_state = 42)
model.fit(x_train_res , y_train_res)
y_pred = model.predict(X_test)
return f1_score(y_test, y_pred)
pbounds = {'n_estimators':(10, 30), 'learning_rate':(-0.05, 0.05)}
optimizer = BayesianOptimization(
f=black_box_function,
pbounds=pbounds,
verbose=2, # verbose = 1 prints only when a maximum is observed, verbose = 0 is silent
random_state=1,
)
optimizer.maximize(
init_points=10,
n_iter=200,
)
print('max')
print(optimizer.max)
| iter | target | learni... | n_esti... | ------------------------------------------------- | 1 | 0.7089 | -0.008298 | 24.41 | | 2 | 0.6923 | -0.04999 | 16.05 | | 3 | 0.7073 | -0.03532 | 11.85 | | 4 | 0.6897 | -0.03137 | 16.91 | | 5 | 0.6829 | -0.01032 | 20.78 | | 6 | 0.72 | -0.008081 | 23.7 | | 7 | 0.6753 | -0.02955 | 27.56 | | 8 | 0.7105 | -0.04726 | 23.41 | | 9 | 0.7273 | -0.00827 | 21.17 | | 10 | 0.7229 | -0.03596 | 13.96 | | 11 | 0.7179 | -0.007011 | 21.28 | | 12 | 0.7073 | 0.01039 | 13.78 | | 13 | 0.7317 | -0.03507 | 22.58 | | 14 | 0.7013 | 0.01136 | 22.72 | | 15 | 0.6977 | -0.01044 | 13.23 | | 16 | 0.7105 | -0.05 | 22.49 | | 17 | 0.6829 | -0.01468 | 21.17 | | 18 | 0.72 | 0.01099 | 17.86 | | 19 | 0.6923 | 0.00532 | 24.04 | | 20 | 0.6966 | -0.03516 | 18.13 | | 21 | 0.7073 | 0.01034 | 13.78 | | 22 | 0.7273 | -0.03031 | 22.57 | | 23 | 0.6829 | -0.01265 | 21.18 | | 24 | 0.7317 | -0.03232 | 22.58 | | 25 | 0.6835 | -0.03319 | 23.68 | | 26 | 0.7229 | -0.03413 | 13.97 | | 27 | 0.7297 | -0.02612 | 22.58 | | 28 | 0.7013 | 0.000315 | 21.18 | | 29 | 0.7073 | -0.02756 | 22.59 | | 30 | 0.72 | 0.000387 | 23.7 | | 31 | 0.6923 | 0.003145 | 23.71 | | 32 | 0.7229 | -0.02833 | 13.96 | | 33 | 0.7105 | -0.04397 | 22.58 | | 34 | 0.6842 | -0.003856 | 19.76 | | 35 | 0.7059 | -0.03591 | 22.57 | | 36 | 0.7229 | -0.01857 | 14.29 | | 37 | 0.72 | -0.00727 | 23.7 | | 38 | 0.7368 | -0.02643 | 14.29 | | 39 | 0.6923 | -0.01537 | 22.58 | | 40 | 0.7229 | -0.02017 | 14.28 | | 41 | 0.7143 | -0.02964 | 14.29 | | 42 | 0.7143 | -0.03763 | 14.28 | | 43 | 0.6977 | -0.02414 | 14.28 | | 44 | 0.72 | -0.004892 | 23.7 | | 45 | 0.725 | -0.006783 | 27.31 | | 46 | 0.7143 | -0.0317 | 14.29 | | 47 | 0.7059 | -0.03789 | 22.58 | | 48 | 0.7229 | -0.02697 | 13.96 | | 49 | 0.7273 | -0.02878 | 22.58 | | 50 | 0.725 | -0.004436 | 27.31 | | 51 | 0.7179 | -0.006697 | 21.28 | | 52 | 0.7273 | -0.02933 | 22.59 | | 53 | 0.7143 | -0.01339 | 14.28 | | 54 | 0.6835 | -0.03413 | 23.39 | | 55 | 0.6923 | -0.02074 | 29.96 | | 56 | 0.7229 | -0.03278 | 13.96 | | 57 | 0.6977 | -0.02405 | 14.29 | | 58 | 0.7297 | -0.02543 | 22.58 | | 59 | 0.7229 | -0.03681 | 13.97 | | 60 | 0.6494 | -0.009551 | 27.31 | | 61 | 0.6829 | 0.006223 | 16.56 | | 62 | 0.6933 | 0.02765 | 13.92 | | 63 | 0.7317 | -0.03269 | 22.59 | | 64 | 0.6753 | -0.02335 | 22.58 | | 65 | 0.7073 | -0.03869 | 13.97 | | 66 | 0.7229 | -0.03417 | 13.96 | | 67 | 0.7229 | -0.0304 | 13.96 | | 68 | 0.7105 | 0.02672 | 23.46 | | 69 | 0.7073 | -0.03992 | 13.97 | | 70 | 0.7317 | -0.03472 | 22.58 | | 71 | 0.6753 | 0.01585 | 19.81 | | 72 | 0.7297 | -0.02563 | 22.57 | | 73 | 0.7297 | -0.02604 | 22.58 | | 74 | 0.7317 | -0.03239 | 22.57 | | 75 | 0.7105 | -0.02205 | 22.57 | | 76 | 0.7209 | -0.02868 | 19.62 | | 77 | 0.7059 | -0.03574 | 22.57 | | 78 | 0.725 | -0.002359 | 27.31 | | 79 | 0.7273 | -0.02864 | 22.57 | | 80 | 0.6753 | 0.03513 | 20.67 | | 81 | 0.7143 | -0.02885 | 14.29 | | 82 | 0.72 | -0.000691 | 23.7 | | 83 | 0.7143 | -0.02838 | 14.28 | | 84 | 0.7229 | -0.0215 | 14.27 | | 85 | 0.725 | -0.001135 | 27.31 | | 86 | 0.7273 | -0.02949 | 22.58 | | 87 | 0.7143 | -0.01783 | 14.27 | | 88 | 0.7143 | -0.01541 | 14.28 | | 89 | 0.7229 | -0.03371 | 13.97 | | 90 | 0.6667 | 0.03289 | 29.7 | | 91 | 0.7013 | -0.004525 | 21.17 | | 92 | 0.725 | -0.006537 | 27.3 | | 93 | 0.7317 | -0.03363 | 22.58 | | 94 | 0.72 | 0.01181 | 17.85 | | 95 | 0.7273 | -0.02811 | 22.56 | | 96 | 0.7179 | 0.03583 | 11.03 | | 97 | 0.6988 | -0.04844 | 11.03 | | 98 | 0.72 | -0.005421 | 23.69 | | 99 | 0.725 | -0.003373 | 27.31 | | 100 | 0.7229 | -0.02875 | 13.97 | | 101 | 0.7317 | -0.0317 | 22.57 | | 102 | 0.725 | -0.003994 | 27.3 | | 103 | 0.7317 | -0.02606 | 13.97 | | 104 | 0.7317 | -0.03203 | 22.56 | | 105 | 0.6667 | -0.01108 | 23.7 | | 106 | 0.7229 | -0.03034 | 13.97 | | 107 | 0.7273 | -0.02879 | 22.56 | | 108 | 0.725 | 0.001284 | 27.3 | | 109 | 0.6977 | -0.02414 | 13.96 | | 110 | 0.7229 | -0.02835 | 13.96 | | 111 | 0.7317 | -0.02569 | 13.97 | | 112 | 0.7059 | -0.03629 | 22.56 | | 113 | 0.7317 | -0.03362 | 22.55 | | 114 | 0.7297 | -0.0264 | 22.55 | | 115 | 0.7105 | -0.02175 | 22.55 | | 116 | 0.6753 | 0.02889 | 20.23 | | 117 | 0.7105 | -0.03839 | 22.55 | | 118 | 0.6494 | -0.00918 | 27.3 | | 119 | 0.7027 | 0.02998 | 27.67 | | 120 | 0.6818 | -0.01368 | 10.26 | | 121 | 0.7229 | -0.02186 | 13.98 | | 122 | 0.7273 | -0.02985 | 22.55 | | 123 | 0.72 | 0.01326 | 17.85 | | 124 | 0.7073 | -0.03763 | 12.63 | | 125 | 0.7317 | -0.02649 | 13.98 | | 126 | 0.725 | 0.000708 | 27.31 | | 127 | 0.7073 | -0.04029 | 13.49 | | 128 | 0.6818 | -0.0342 | 19.62 | | 129 | 0.6977 | -0.02281 | 13.97 | | 130 | 0.7342 | -0.04295 | 20.19 | | 131 | 0.7342 | -0.04592 | 20.19 | | 132 | 0.7342 | -0.0392 | 20.18 | | 133 | 0.6842 | 0.002835 | 11.47 | | 134 | 0.7105 | -0.022 | 22.56 | | 135 | 0.7317 | -0.03169 | 22.55 | | 136 | 0.7342 | -0.04505 | 20.19 | | 137 | 0.6923 | -0.01419 | 22.83 | | 138 | 0.6966 | -0.03732 | 18.91 | | 139 | 0.6977 | -0.03507 | 20.18 | | 140 | 0.7229 | -0.02949 | 13.97 | | 141 | 0.7143 | -0.01192 | 14.29 | | 142 | 0.7436 | -0.04955 | 20.19 | | 143 | 0.7317 | -0.02579 | 13.98 | | 144 | 0.7059 | -0.03712 | 22.55 | | 145 | 0.7436 | -0.04984 | 20.19 | | 146 | 0.7342 | -0.04167 | 20.18 | | 147 | 0.7105 | -0.03834 | 22.59 | | 148 | 0.7342 | -0.04779 | 20.2 | | 149 | 0.6494 | -0.0114 | 27.3 | | 150 | 0.7342 | -0.04754 | 20.18 | | 151 | 0.7229 | -0.02047 | 11.35 | | 152 | 0.7229 | -0.02718 | 13.98 | | 153 | 0.7342 | -0.04512 | 20.18 | | 154 | 0.7294 | -0.0198 | 19.62 | | 155 | 0.7294 | -0.02184 | 19.61 | | 156 | 0.7654 | -0.02304 | 19.61 | | 157 | 0.7294 | -0.01931 | 19.61 | | 158 | 0.6966 | -0.03566 | 18.6 | | 159 | 0.7436 | -0.04827 | 20.2 | | 160 | 0.6923 | -0.02572 | 19.61 | | 161 | 0.7342 | -0.04471 | 20.18 | | 162 | 0.7342 | -0.04209 | 20.18 | | 163 | 0.6316 | -0.01572 | 24.41 | | 164 | 0.7342 | -0.04472 | 20.17 | | 165 | 0.6966 | -0.02401 | 19.62 | | 166 | 0.7229 | -0.01921 | 13.98 | | 167 | 0.7229 | -0.03052 | 13.98 | | 168 | 0.7342 | -0.04705 | 20.2 | | 169 | 0.7 | 0.04646 | 12.87 | | 170 | 0.6923 | -0.02636 | 19.62 | | 171 | 0.7436 | -0.04914 | 20.17 | | 172 | 0.7342 | -0.04669 | 20.17 | | 173 | 0.7342 | -0.04572 | 20.2 | | 174 | 0.7273 | -0.04561 | 18.47 | | 175 | 0.7848 | 0.04772 | 17.78 | | 176 | 0.7848 | 0.04406 | 17.78 | | 177 | 0.7848 | 0.04471 | 17.78 | | 178 | 0.7317 | 0.03386 | 18.93 | | 179 | 0.7632 | 0.04011 | 18.93 | | 180 | 0.7848 | 0.04769 | 17.78 | | 181 | 0.7317 | 0.03206 | 18.94 | | 182 | 0.7532 | 0.04485 | 18.92 | | 183 | 0.7632 | 0.042 | 18.93 | | 184 | 0.72 | 0.01095 | 17.86 | | 185 | 0.7143 | -0.04837 | 15.47 | | 186 | 0.7848 | 0.0473 | 17.78 | | 187 | 0.6829 | -0.0407 | 23.65 | | 188 | 0.6923 | -0.01221 | 26.04 | | 189 | 0.7532 | 0.04529 | 18.94 | | 190 | 0.7848 | 0.04348 | 17.79 | | 191 | 0.7 | 0.04061 | 12.46 | | 192 | 0.7848 | 0.04312 | 17.79 | | 193 | 0.7532 | 0.04991 | 18.93 | | 194 | 0.7848 | 0.04101 | 17.79 | | 195 | 0.7073 | 0.0367 | 17.79 | | 196 | 0.7848 | 0.0435 | 17.78 | | 197 | 0.6923 | 0.02793 | 24.72 | | 198 | 0.7013 | 0.01218 | 22.56 | | 199 | 0.7073 | 0.007552 | 13.13 | | 200 | 0.6761 | 0.03671 | 28.28 | | 201 | 0.7105 | 0.03921 | 18.93 | | 202 | 0.7848 | 0.04867 | 17.78 | | 203 | 0.7436 | 0.03745 | 18.93 | | 204 | 0.7532 | 0.04703 | 18.93 | | 205 | 0.7317 | 0.02761 | 18.92 | | 206 | 0.7532 | 0.04951 | 18.93 | | 207 | 0.7848 | 0.04445 | 17.77 | | 208 | 0.7848 | 0.04138 | 17.79 | | 209 | 0.6667 | -0.02362 | 23.7 | | 210 | 0.7632 | 0.04247 | 18.93 | ================================================= max {'target': 0.7848101265822784, 'params': {'learning_rate': 0.047715766463314324, 'n_estimators': 17.779424609189796}}
model = AdaBoostClassifier(n_estimators = int(optimizer.max['params']['n_estimators']),
learning_rate = 10**optimizer.max['params']['learning_rate'],
random_state = 42)
model.fit(x_train_res , y_train_res)
y_pred = model.predict(X_test)
print("F1", f1_score(y_test, y_pred))
print(classification_report(y_test, y_pred,target_names=target_names))
F1 0.7848101265822784 precision recall f1-score support non résilié 0.98 0.92 0.95 166 resilié 0.69 0.91 0.78 34 accuracy 0.92 200 macro avg 0.83 0.91 0.87 200 weighted avg 0.93 0.92 0.92 200
yscore = model.predict(Xscore)
np.mean(yscore)
0.2733333333333333
yDF = pd.DataFrame(data = yscore.astype(int), columns=['target'])
yDF.index+=1000
yDF.to_csv("result_schindler_hugo.csv")