Skip to content
Merged
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
2 changes: 1 addition & 1 deletion popv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if sys.version_info[:2] != (3, 10):
warnings.warn(
"Pretrained models on huggingface are trained with Python 3.11. "
f"Detected Python {sys.version.split()[0]} will not load these models.",
"Detected Python {sys.version.split()[:2]} will not load these models.",
UserWarning,
stacklevel=3,
)
Expand Down
4 changes: 2 additions & 2 deletions popv/algorithms/_svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def predict(self, adata):
if adata.uns["_prediction_mode"] == "retrain":
train_idx = adata.obs["_ref_subsample"]
train_x = adata[train_idx].layers[self.layer_key] if self.layer_key else adata[train_idx].X
train_x = np.array(train_x.todense())
train_y = adata.obs.loc[train_idx, self.labels_key].cat.codes.to_numpy()
if settings.cuml:
from cuml.svm import LinearSVC
from sklearn.multiclass import OneVsRestClassifier

self.classifier_dict["probability"] = self.return_probabilities
clf = OneVsRestClassifier(LinearSVC(**self.classifier_dict))
train_x = train_x.todense()
clf.fit(train_x, train_y)
joblib.dump(
clf,
Expand Down Expand Up @@ -131,7 +131,7 @@ def predict(self, adata):
for i in range(0, adata.n_obs, shard_size):
tmp_x = test_x[i : i + shard_size]
names_x = adata.obs_names[i : i + shard_size]
tmp_x = tmp_x.todense()
tmp_x = np.array(tmp_x.todense())
result_df.loc[names_x, self.result_key] = adata.uns["label_categories"][clf.predict(tmp_x).astype(int)]
if self.return_probabilities:
result_df.loc[names_x, f"{self.result_key}_probabilities"] = np.max(
Expand Down
2 changes: 2 additions & 0 deletions popv/hub/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import os
import sys
from dataclasses import asdict, dataclass, field

from anndata import AnnData
Expand Down Expand Up @@ -194,6 +195,7 @@ def _to_model_card(self) -> ModelCard:
"genomics",
"single-cell",
f"anndata_version:{self.anndata_version}",
f"python_version:{'.'.join([str(i) for i in sys.version_info[:3]])}",
"popV",
]
for t in self.tissues:
Expand Down
Loading