-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
862d48d
commit 2c81f68
Showing
2 changed files
with
16 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
...ntrol_methods/my_control_method/script.py → src/control_methods/true_labels/script.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
import anndata as ad | ||
import sklearn.linear_model | ||
|
||
## VIASH START | ||
# Note: this section is auto-generated by viash at runtime. To edit it, make changes | ||
# in config.vsh.yaml and then run `viash config inject config.vsh.yaml`. | ||
par = { | ||
'input_train': 'resources_test/task_template/pancreas/train.h5ad', | ||
'input_test': 'resources_test/task_template/pancreas/test.h5ad', | ||
'input_solution': 'resources_test/task_template/pancreas/solution.h5ad', | ||
'output': 'output.h5ad' | ||
} | ||
meta = { | ||
'name': 'logistic_regression' | ||
'name': 'true_labels' | ||
} | ||
## VIASH END | ||
|
||
print('Reading input files', flush=True) | ||
input_train = ad.read_h5ad(par['input_train']) | ||
input_test = ad.read_h5ad(par['input_test']) | ||
input_solution = ad.read_h5ad(par['input_solution']) | ||
|
||
print('Preprocess data', flush=True) | ||
# ... preprocessing ... | ||
|
||
print('Train model', flush=True) | ||
# ... train model ... | ||
classifier = sklearn.linear_model.LogisticRegression() | ||
classifier.fit(input_train.obsm["X_pca"], input_train.obs["label"].astype(str)) | ||
|
||
print('Generate predictions', flush=True) | ||
# ... generate predictions ... | ||
obs = classifier.predict(input_test.obsm["X_pca"]) | ||
obs_label_pred = input_solution.obs["label"] | ||
|
||
print("Write output AnnData to file", flush=True) | ||
output = ad.AnnData( | ||
uns={ | ||
'dataset_id': input_train.uns['dataset_id'], | ||
'normalization_id': input_train.uns['normalization_id'], | ||
'method_id': meta['name'] | ||
}, | ||
obs={ | ||
'label_pred': obs | ||
'label_pred': obs_label_pred | ||
} | ||
) | ||
output.write_h5ad(par['output'], compression='gzip') |