Last active
May 2, 2018 02:19
-
-
Save heartonbit/2a7e916c3a184c17f6bf3a27d6f2a9ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def predict_score(model_pickle_path, target_filepath, n_meta_columns, n_feature_columns): | |
""" | |
model_pickle_path : | |
target_filepath : target gene expression examples with meta | |
n_meta_columns : number of meta columns | |
n_feature_columns : number of feature(gene)s | |
return score DataFrame | |
""" | |
df0 = pd.read_csv(target_filepath, header=-1) | |
x_header = df0.iloc[:, 0:n_meta_columns] | |
X = df0.iloc[:, n_meta_columns:n_meta_columns + n_feature_columns] | |
model = pickle.load(open(model_pickle_path, mode='rb')) | |
score_vectors = model.predict_proba(X.values, output_margin=True) | |
score_vector_df = pd.DataFrame(score_vectors) | |
target_score_vector_df = pd.concat([x_header, score_vector_df], axis=1) | |
return target_score_vector_df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment