Skip to content

Instantly share code, notes, and snippets.

@heartonbit
Last active May 2, 2018 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heartonbit/2a7e916c3a184c17f6bf3a27d6f2a9ba to your computer and use it in GitHub Desktop.
Save heartonbit/2a7e916c3a184c17f6bf3a27d6f2a9ba to your computer and use it in GitHub Desktop.
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