<jupyter_start><jupyter_text>DecisionTree<jupyter_code>def run_model(model, feats):
  X = df[feats].values
  y = df['price_value'].values

  scores = cross_val_score(model, X, y, cv = 3, scoring='neg_mean_absolute_error')
  return np.mean(scores), np.std(scores)

run_model(DecisionTreeRegressor(max_depth=5), cat_feats)<jupyter_output><empty_output><jupyter_text>Random Forest<jupyter_code>xgb_params = {
    'max_depth':5, 
    'n_estimators':50, 
    'learning_rate':0.1,
    'seed':0
}

run_model(xgb.XGBRegressor(**xgb_params), cat_feats)
m = xgb.XGBRegressor(**xgb_params)
m.fit(X, y)

imp = PermutationImportance(m, random_state=0).fit(X, y)
0.1274 ± 0.0017 	param_napęd__cat
0.1159 ± 0.0025 	param_stan__cat
0.1131 ± 0.0037 	param_rok-produkcji__cat
0.0565 ± 0.0010 	param_faktura-vat__cat
0.0482 ± 0.0014 	param_moc__cat
0.0416 ± 0.0017 	param_skrzynia-biegów__cat
0.0252 ± 0.0010 	param_marka-pojazdu__cat
0.0247 ± 0.0014 	feature_kamera-cofania__cat
0.0232 ± 0.0008 	param_typ__cat
0.0198 ± 0.0006 	param_pojemność-skokowa__cat
0.0148 ± 0.0011 	seller_name__cat
0.0124 ± 0.0005 	param_wersja__cat
0.0124 ± 0.0009 	feature_wspomaganie-kierownicy__cat
0.0120 ± 0.0008 	param_model-pojazdu__cat
0.0113 ± 0.0003 	feature_system-start-stop__cat
0.0099 ± 0.0004 	param_kod-silnika__cat
0.0089 ± 0.0003 	feature_asystent-pasa-ruchu__cat
0.0081 ± 0.0004 	feature_łopatki-zmiany-biegów__cat
0.0076 ± 0.0002 	feature_światła-led__cat
0.0075 ± 0.0006 	feature_czujniki-parkowania-przednie__cat eli5.show_weights(imp, feature_names = cat_feats)
feats = ['param_napęd__cat','param_stan__cat','param_rok-produkcji__cat','param_faktura-vat__cat','param_moc__cat','param_skrzynia-biegów__cat','param_marka-pojazdu__cat','feature_kamera-cofania__cat','param_typ__cat','param_pojemność-skokowa__cat','seller_name__cat','param_wersja__cat','feature_wspomaganie-kierownicy__cat','param_model-pojazdu__cat','feature_system-start-stop__cat','param_kod-silnika__cat','feature_asystent-pasa-ruchu__cat','feature_łopatki-zmiany-biegów__cat','feature_światła-led__cat','feature_czujniki-parkowania-przednie__cat']
run_model(xgb.XGBRegressor(**xgb_params), cat_feats)
len(feats)
df['param_napęd'].unique()
df['param_rok-produkcji'].unique()
df['param_rok-produkcji__cat'].unique()
df['param_rok-produkcji'] = df['param_rok-produkcji'].map(lambda x: -1 if str(x) == 'None' else int(x))
feats = ['param_napęd__cat','param_stan__cat','param_rok-produkcji','param_faktura-vat__cat','param_moc__cat','param_skrzynia-biegów__cat','param_marka-pojazdu__cat','feature_kamera-cofania__cat','param_typ__cat','param_pojemność-skokowa__cat','seller_name__cat','param_wersja__cat','feature_wspomaganie-kierownicy__cat','param_model-pojazdu__cat','feature_system-start-stop__cat','param_kod-silnika__cat','feature_asystent-pasa-ruchu__cat','feature_łopatki-zmiany-biegów__cat','feature_światła-led__cat','feature_czujniki-parkowania-przednie__cat']
run_model(xgb.XGBRegressor(**xgb_params), feats)
df['param_moc'] = df['param_moc'].map(lambda x:-1 if str(x) == 'None' else int(x.split(' ')[0]) )

df['param_moc'].unique()
feats = ['param_napęd__cat','param_stan__cat','param_rok-produkcji','param_faktura-vat__cat','param_moc','param_skrzynia-biegów__cat','param_marka-pojazdu__cat','feature_kamera-cofania__cat','param_typ__cat','param_pojemność-skokowa__cat','seller_name__cat','param_wersja__cat','feature_wspomaganie-kierownicy__cat','param_model-pojazdu__cat','feature_system-start-stop__cat','param_kod-silnika__cat','feature_asystent-pasa-ruchu__cat','feature_łopatki-zmiany-biegów__cat','feature_światła-led__cat','feature_czujniki-parkowania-przednie__cat']
run_model(xgb.XGBRegressor(**xgb_params), feats)
df['param_pojemność-skokowa'] = df['param_pojemność-skokowa'].map(lambda x:-1 if str(x) == 'None' else int(str(x).split('cm')[0].replace(' ', '')) )
df['param_pojemność-skokowa'].unique()
feats = ['param_napęd__cat','param_stan__cat','param_rok-produkcji','param_faktura-vat__cat','param_moc','param_skrzynia-biegów__cat','param_marka-pojazdu__cat','feature_kamera-cofania__cat','param_typ__cat','param_pojemność-skokowa','seller_name__cat','param_wersja__cat','feature_wspomaganie-kierownicy__cat','param_model-pojazdu__cat','feature_system-start-stop__cat','param_kod-silnika__cat','feature_asystent-pasa-ruchu__cat','feature_łopatki-zmiany-biegów__cat','feature_światła-led__cat','feature_czujniki-parkowania-przednie__cat']
run_model(xgb.XGBRegressor(**xgb_params), feats)<jupyter_output>[10:57:32] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.
[10:57:35] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.
[10:57:39] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.
{'fraction_non_alphanumeric': 0.14697406340057637, 'fraction_numerical': 0.04981473857554549, 'mean_word_length': 9.679120879120878, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '649521', 'license': 'MIT', 'n_tokens_mistral': 2202, 'n_tokens_neox': 2031, 'n_words': 197, 'path': 'day4.ipynb', 'repo_name': 'mb345/dw_matrix_car', 'size': '4858'}