From a95febdd3ef7976b08e030419fab90339fcdc1aa Mon Sep 17 00:00:00 2001 From: epaaso Date: Thu, 18 Jan 2024 07:16:20 -0600 Subject: [PATCH 1/3] sparse dot product --- ikarus/classifier.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ikarus/classifier.py b/ikarus/classifier.py index 59baa8b..9ad717b 100644 --- a/ikarus/classifier.py +++ b/ikarus/classifier.py @@ -82,7 +82,7 @@ def calculate_connectivities( path = Path.cwd() / out_dir / name path.mkdir(parents=True, exist_ok=True) save_npz(path / "connectivities_sparse.npz", sparse) - return sparse.todense() + return sparse def propagate_labels( @@ -113,7 +113,7 @@ def propagate_labels( ] = True final_pred_proba.loc[certainty_info[f"certain{i}"] == False] = 0.000001 - final_step_mtx = np.dot(connectivities, final_pred_proba.values) + final_step_mtx = connectivities.dot(final_pred_proba.values) final_step_mtx = np.divide(final_step_mtx, final_step_mtx.sum(axis=1)) final_pred_proba.loc[:, :] = final_step_mtx @@ -393,7 +393,7 @@ def predict( self.out_dir, ) else: - connectivities = load_npz(connectivities_path).todense() + connectivities = load_npz(connectivities_path) if connectivities.shape[0] != adata.shape[0]: raise IndexError( f"Shape of connectivities matrix ({connectivities.shape}) does " @@ -550,7 +550,7 @@ def cnv_correct( self.out_dir, ) else: - connectivities = load_npz(connectivities_path).todense() + connectivities = load_npz(connectivities_path) if connectivities.shape[0] != adata.shape[0]: raise IndexError( f"Shape of connectivities matrix ({connectivities.shape}) does " From 8cf8be9bef33d39a99b23ac0bc27e2b503217f0a Mon Sep 17 00:00:00 2001 From: epaaso Date: Thu, 18 Jan 2024 09:37:42 -0600 Subject: [PATCH 2/3] fix sum axis --- ikarus/classifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ikarus/classifier.py b/ikarus/classifier.py index 9ad717b..597d44c 100644 --- a/ikarus/classifier.py +++ b/ikarus/classifier.py @@ -114,7 +114,7 @@ def propagate_labels( final_pred_proba.loc[certainty_info[f"certain{i}"] == False] = 0.000001 final_step_mtx = connectivities.dot(final_pred_proba.values) - final_step_mtx = np.divide(final_step_mtx, final_step_mtx.sum(axis=1)) + final_step_mtx = np.divide(final_step_mtx, final_step_mtx.sum(axis=0)) final_pred_proba.loc[:, :] = final_step_mtx current = final_pred_proba.idxmax(axis=1) From fe2775e1194465013bcfc5dc9cd595bec011be19 Mon Sep 17 00:00:00 2001 From: Ernesto Paas Date: Fri, 7 Jun 2024 19:55:48 +0000 Subject: [PATCH 3/3] changed the axis --- ikarus/classifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ikarus/classifier.py b/ikarus/classifier.py index 597d44c..4fff1e7 100644 --- a/ikarus/classifier.py +++ b/ikarus/classifier.py @@ -114,7 +114,7 @@ def propagate_labels( final_pred_proba.loc[certainty_info[f"certain{i}"] == False] = 0.000001 final_step_mtx = connectivities.dot(final_pred_proba.values) - final_step_mtx = np.divide(final_step_mtx, final_step_mtx.sum(axis=0)) + final_step_mtx = np.divide(final_step_mtx, final_step_mtx.sum(axis=1, keepdims=True)) final_pred_proba.loc[:, :] = final_step_mtx current = final_pred_proba.idxmax(axis=1)