Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding euclidean option for grit calculation #44

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cytominer_eval/transform/transform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import numpy as np
import pandas as pd
from sklearn.metrics.pairwise import euclidean_distances

from typing import List

from cytominer_eval.utils.transform_utils import (
Expand All @@ -23,7 +25,10 @@ def get_pairwise_metric(df: pd.DataFrame, similarity_metric: str) -> pd.DataFram
m=similarity_metric, avail=available_pairwise_similarity_metrics
)

pair_df = df.transpose().corr(method=similarity_metric)
if similarity_metric == "euclidean":
pair_df = pd.DataFrame(euclidean_distances(df))
else:
pair_df = df.transpose().corr(method=similarity_metric)

# Check if the metric calculation went wrong
# (Current pandas version makes this check redundant)
Expand Down
2 changes: 1 addition & 1 deletion cytominer_eval/utils/availability_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_available_similarity_metrics():
r"""Output the available metrics for calculating pairwise similarity in the
cytominer_eval library
"""
return ["pearson", "kendall", "spearman"]
return ["pearson", "kendall", "spearman", "euclidean"]


def get_available_grit_summary_methods():
Expand Down