<commit_before><commit_msg>create predictions on pre-trained models<commit_after>import numpy as np
import pandas as pd
from sklearn.externals import joblib

from data_preprocessing import join_strings
from model import mlb, count_vectorizer_test_x, tfidf_vectorizer_test_x, file_cnt, file_tfidf

count_vectorizer_model, tfidf_vectorizer_model = joblib.load(file_cnt), joblib.load(file_tfidf)
print("Both the trained models have been imported successfully!")
print()
print("Making predictions...")
pred1 = count_vectorizer_model.predict(count_vectorizer_test_x.toarray())
pred2 = tfidf_vectorizer_model.predict(tfidf_vectorizer_test_x.toarray())

# Combine predictions and map the labels if the values do not equal 0, else assign empty string
arr = np.where((pred1 + pred2) != 0, mlb.classes_, "")
# Load the array into a DataFrame constructor and join non-empty strings
predictions = pd.DataFrame(arr).apply(join_strings, axis=1).to_frame("tags")
# Submit predictions
print("Submitting predictions...")
predictions.to_csv("tags.tsv", index=False)
print("done")
{'fraction_non_alphanumeric': 0.09519321394910461, 'fraction_numerical': 0.006597549481621112, 'mean_word_length': 7.428571428571429, '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': '6414020', 'n_tokens_mistral': 332, 'n_tokens_neox': 323, 'n_words': 90}