<commit_before>import commons
import pandas as pd
import logging as log

def load_models(indicators):
    print("Loading models... ", end='', flush=True)
    models = {i: commons.read_model(i) for i in indicators}
    print("Done.")
    return models

df = pd.read_hdf('dataframe.hdf5.test', key='santander')
print(df.head())
df.drop(commons.indicators, inplace=True, axis=1)

log.info("Number of test cases: {}".format(df.shape[0]))

all_models = load_models(commons.indicators)
submission = {}

log.info("{}".format(list(df)))

customers = df['ncodpers'].values.tolist()
df.drop(['ncodpers'], inplace=True, axis=1)
for indicator in commons.indicators:
    log.info("Processing: {}".format(indicator))
    model = all_models[indicator]
    for decision in zip(customers, model.predict(df)):
        if decision[0]  not in submission: submission[decision[0]] = list()
        if decision[1]: submission[decision[0]].append(indicator)

with open('submission.csv', 'w') as submission_file:
    print("ncodpers,added_products", file=submission_file)
    for k, v in submission.items():
        print("{},{}".format(k, " ".join(set(v))), file=submission_file)<commit_msg>predict_proba<commit_after>import commons, sys
import pandas as pd
import logging as log

def load_models(indicators):
    print("Loading models... ", end='', flush=True)
    models = {i: commons.read_model(i) for i in indicators}
    print("Done.")
    return models

df = pd.read_hdf('dataframe.hdf5.test', key='santander')
print(df.head())
df.drop(commons.indicators, inplace=True, axis=1)

log.info("Number of test cases: {}".format(df.shape[0]))

all_models = load_models(commons.indicators)
submission = {}

log.info("{}".format(list(df)))

customers = df['ncodpers'].values.tolist()
df.drop(['ncodpers'], inplace=True, axis=1)
for indicator in commons.indicators:
    log.info("Processing: {}".format(indicator))
    model = all_models[indicator]
    for decision in zip(customers, model.predict_proba(df)):
        log.info("{}".format(decision))
        sys.exit()
        if decision[0]  not in submission: submission[decision[0]] = list()
        if decision[1]: submission[decision[0]].append(indicator)

with open('submission.csv', 'w') as submission_file:
    print("ncodpers,added_products", file=submission_file)
    for k, v in submission.items():
        print("{},{}".format(k, " ".join(set(v))), file=submission_file)
{'fraction_non_alphanumeric': 0.16805324459234608, 'fraction_numerical': 0.0066555740432612314, 'mean_word_length': 4.938271604938271, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '3612755', 'n_tokens_mistral': 814, 'n_tokens_neox': 803, 'n_words': 172}