Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Read the results

compare() returns a pandas DataFrame, and the hosted API returns the same table as JSON or CSV. It has one row for each algorithm and position: with 100 author labels and two algorithms, 200 rows, ordered by algorithm and then by position.

Columns

ColumnTypeMeaning
run_idstrThe run ID of the call
algorithmstrThe name of the algorithm
pair_indexintThe position in the label lists, from 0
author_labelstrThe author label, lowercased
algorithm_labelstrThe algorithm label, lowercased
author_ontology_idstrThe ID of the Cell Ontology term that the author label matched, such as CL:0000815, or an empty string if it matched none
author_ontology_namestrThe name of that term, such as regulatory T cell
author_embedding_similarityfloat or strThe cosine similarity of the label’s description with the description of its closest term, also when the label stayed unmatched
algorithm_ontology_idstrAs author_ontology_id, for the algorithm label
algorithm_ontology_namestrAs author_ontology_name, for the algorithm label
algorithm_embedding_similarityfloat or strAs author_embedding_similarity, for the algorithm label
cytescore_similarityfloatThe similarity of the two terms under the chosen metric, or 0 when a label is empty or unmatched
similarity_methodstrHow the row was scored, or why it was not

Similarities are rounded to 4 decimals. For a compound label, the ID, name and embedding similarity columns of its side list every part, separated by semicolons, and the embedding similarity is then a string, such as 0.7012;0.6634. The name of a term is its first label in the ontology mapping file. For nearly all terms that is the term’s name in the Cell Ontology; a few differ, such as CL:0000649, which the mapping names prickle cell.

similarity_method

ValueMeaning
cytescoreBoth labels matched a term and were scored with the metric
cytescore_compoundAt least one label has several parts; the part scores were reduced with compound_scoring
partial_matchOnly one of the labels matched a term; the score is 0
no_matchesNeither label matched a term; the score is 0
emptyOne or both labels are empty; the score is 0, and a non-empty label keeps its match
string_similarityAt least one matched term has an ID that does not start with CL:; the score still comes from the metric. The shipped ontology files hold only CL: IDs, so this does not occur with them

A label stays unmatched when the cosine similarity with its closest term is below min_match_similarity; see The match threshold.

Interpret the scores

Scores depend on the metric and the model pair, so compare algorithms only within one set of settings.

Summaries with pandas

import pandas as pd

# Mean score of each algorithm.
df.groupby("algorithm")["cytescore_similarity"].mean()

# Share of label pairs whose labels matched the same Cell Ontology term.
matched = df["author_ontology_id"] != ""
same_term = matched & (df["author_ontology_id"] == df["algorithm_ontology_id"])
same_term.groupby(df["algorithm"]).mean()

# Rows that were not scored.
df[df["similarity_method"].isin(["partial_match", "no_matches", "empty"])]

# The author labels sorted by how well they fit their term; compound labels last.
fit = pd.to_numeric(df["author_embedding_similarity"], errors="coerce")
df.assign(fit=fit).drop_duplicates("author_label").sort_values("fit")[
    ["author_label", "author_ontology_name", "fit"]
]

Save the results

df.to_csv("cyteonto_results.csv", index=False)

When you load the CSV with pandas, pass keep_default_na=False, or empty IDs and names become NaN:

df = pd.read_csv("cyteonto_results.csv", keep_default_na=False)