<jupyter_start><jupyter_text>Dummy model<jupyter_code>df.select_dtypes(np.number).columns
feats = ['car_id']
x = df[ feats ].values
y = df['car_id'].values

model = DummyRegressor()
model.fit(x, y)
y_pred = model.predict(x)

mae(y, y_pred)
[x for x in df.columns if 'price' in x]
df['price_currency'].value_counts()
df['price_currency'].value_counts(normalize=True) * 100
df2 = df[ df['price_currency'] != 'EUR' ]
df2['price_currency'].value_counts()
df2.head()
df['param_color'].factorize()[0]


for feat in df.columns:
  print(feat)
SUFFIX_CAT = '__cat'
for feat in df.columns:
  if isinstance(df2[feat][0], list): continue

  factorized_values = df2[feat].factorize()[0]
  if SUFFIX_CAT in feat:
    df2[feat] = factorized_values
  else:
    df2[feat + SUFFIX_CAT] = factorized_values
  print(feat)
cat_feats = [x for x in df2.columns if SUFFIX_CAT in x]
cat_feats = [x for x in cat_feats if 'price' not in x]
len(cat_feats)
x = df2[ cat_feats ].values
y = df2[ 'price_value' ].values

model = DecisionTreeRegressor( max_depth=5 )
scores = cross_val_score(model, x, y, cv=3, scoring='neg_mean_absolute_error')
np.mean(scores)

m = DecisionTreeRegressor( max_depth=5 )
m.fit(x, y)

imp = PermutationImportance(m, random_state=0 ).fit(x, y)
eli5.show_weights(imp, feature_names=cat_feats)
df['param_moc'].values
def group_and_barplot(feat_groupby, feat_agg='price_value', agg_funcs=[np.mean, np.median, np.size], feat_sort='mean', top=50, subplots=True):
  return (
df
 .groupby(feat_groupby)[feat_agg]
 .agg(agg_funcs)
 .sort_values(by=feat_sort, ascending=False)
 .head(top)
).plot(kind='bar', figsize=(45, 15), subplots=subplots)
group_and_barplot('param_moc')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15171192443919718, 'fraction_numerical': 0.015938606847697757, 'mean_word_length': 6.369565217391305, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '456508', 'license': 'MIT', 'n_tokens_mistral': 707, 'n_tokens_neox': 679, 'n_words': 139, 'path': 'day3.ipynb', 'repo_name': 'bibix/dw', 'size': '1694'}