Skip to content
Snippets Groups Projects
Commit f8d13fc0 authored by Tim O'Donnell's avatar Tim O'Donnell Committed by GitHub
Browse files

Merge pull request #85 from hammerlab/pan-allele-class1

Fix bug in score_from_peptides_df
parents f2160e59 c6352472
No related merge requests found
......@@ -757,7 +757,7 @@ class AffinityMeasurementDataset(object):
(k in keys_to_remove_set)
for k in zip(self.alleles, self.peptides)
])
keep_mask = ~remove_mask
keep_mask = remove_mask == False
return self.slice(keep_mask)
def difference(self, other_dataset):
......
......@@ -422,6 +422,8 @@ class PresentationModel(object):
assert 'experiment_name' in peptides_df.columns
assert 'hit' in peptides_df.columns
peptides_df = peptides_df.copy()
peptides_df["prediction"] = self.predict(peptides_df)
top_n = float(peptides_df.hit.sum())
......@@ -432,8 +434,13 @@ class PresentationModel(object):
}
else:
ranks = peptides_df.prediction.rank(ascending=False)
hit_indices = ranks[peptides_df.hit > 0].values
hit_lengths = peptides_df.peptide[
peptides_df.hit > 0
].str.len().values
result = {
'hit_indices': numpy.sort(ranks[peptides_df.hit > 0].values),
'hit_indices': hit_indices,
'hit_lengths': hit_lengths,
'total_peptides': len(peptides_df),
}
result['score'] = (
......@@ -572,5 +579,5 @@ def ensemble_predictions(models, peptides_df, mask_indices_list=None):
values = panel.ix[:, :, col]
assert values.shape == (len(peptides_df), len(models))
result[col] = model.combine_ensemble_predictions(col, values.values)
assert_no_null(result[col])
assert_no_null(pandas.Series(result[col]))
return result
......@@ -188,8 +188,8 @@ def describe_nulls(df, related_df_with_same_index_to_describe=None):
if isinstance(df, pandas.Series):
df = df.to_frame()
with pandas.option_context('mode.use_inf_as_null', True):
null_counts_by_col = df.isnull().sum(axis=0)
null_rows = df.isnull().sum(axis=1) > 0
null_counts_by_col = pandas.isnull(df).sum(axis=0)
null_rows = pandas.isnull(df).sum(axis=1) > 0
return (
"Columns with nulls:\n%s, related rows with nulls:\n%s, "
"full df:\n%s" % (
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment