<jupyter_start><jupyter_text>Predict reporters (lasso final model)<jupyter_code>import numpy as np
import pandas as pd
import joblib

from optimalcodon.projects.rnastability.dataprocessing import get_data

# load the predictive model
lasso = joblib.load("../191005-EvaluateModelLearningCurve/results-data/final_model.joblib")
reporters = (
    pd.read_csv("reporters.csv")
    .rename(columns={'sequence': 'coding'})
    .assign(
        gene_id = lambda x: x.reporter_id + '|' + x.optimality,
        utrlenlog = np.nan,
        cdslenlog = lambda x: np.log(x.coding.str.len()),
        key = 'k' # tmp var
    )
    .drop(['reporter_id', 'optimality', 'description'], axis=1)

)
reporters.head()
(train_x, train_y), (test_x, test_y) = get_data('../data/191004-TrainAndTestSets/')
train_x.head()
cat_data = train_x[['specie', 'cell_type', 'datatype']].drop_duplicates().assign(key='k')

reporters = cat_data.merge(reporters, how='outer').drop(['key'], axis=1).set_index('gene_id')
reporters.sample(10)
reporters = reporters.loc[:, train_x.columns.values]
reporters['predicted_stability'] = lasso.predict(reporters)
reporters.to_csv('reporters_with_predicted_stability_all_sepcies.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15542763157894737, 'fraction_numerical': 0.013157894736842105, 'mean_word_length': 5.439153439153439, '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': '276179', 'license': 'MIT', 'n_tokens_mistral': 464, 'n_tokens_neox': 437, 'n_words': 70, 'path': 'paper-analysis/191107-PredictReporterPairs/PredictReporterSequences.ipynb', 'repo_name': 'santiago1234/MZT-rna-stability', 'size': '1216'}