<jupyter_start><jupyter_text>Arithmetic mean<jupyter_code>test_prediction_ar_mean = test_predictions.groupby('SK_ID_CURR')['lightGBM_prediction'].apply(np.mean).reset_index()

test_prediction_ar_mean.columns = ['SK_ID_CURR','TARGET']
test_prediction_ar_mean[test_prediction_ar_mean['SK_ID_CURR']==100001]<jupyter_output><empty_output><jupyter_text>Geometric mean<jupyter_code>test_prediction_geom_mean = test_predictions.groupby('SK_ID_CURR')['lightGBM_prediction'].apply(gmean).reset_index()

test_prediction_geom_mean.columns = ['SK_ID_CURR','TARGET']
test_prediction_geom_mean[test_prediction_ar_mean['SK_ID_CURR']==100001]<jupyter_output><empty_output><jupyter_text>Rank Mean<jupyter_code>def calculate_rank(predictions):
    rank = (1 + predictions.rank().values) / (predictions.shape[0] + 1)
    return rank

test_predictions_with_ranks = []
for fold_id, fold_df in test_predictions.groupby('fold_id'):
    fold_df['lightGBM_rank'] = calculate_rank(fold_df['lightGBM_prediction'])
    test_predictions_with_ranks.append(fold_df)
test_predictions_with_ranks = pd.concat(test_predictions_with_ranks, axis=0)

test_predictions_with_ranks.head()
test_prediction_rank_mean = test_predictions_with_ranks.groupby('SK_ID_CURR')['lightGBM_rank'].apply(np.mean).reset_index()

test_prediction_rank_mean.columns = ['SK_ID_CURR','TARGET']
test_prediction_rank_mean[test_prediction_ar_mean['SK_ID_CURR']==100001]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1240418118466899, 'fraction_numerical': 0.015331010452961672, 'mean_word_length': 14.115789473684211, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '30403', 'license': 'MIT', 'n_tokens_mistral': 562, 'n_tokens_neox': 547, 'n_words': 38, 'path': 'notebooks/test_prediction_distributions.ipynb', 'repo_name': 'JerryCatLeung/open-solution-home-credit', 'size': '1435'}