Skip to content

Commit

Permalink
✨ Test tutorial on colab
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry committed May 30, 2024
1 parent cac23b2 commit c5c1335
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test_pkg_on_colab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test that tutorial runs on latest colab image

on:
push:
branches: [dev]
pull_request:
branches: [main]
schedule:
- cron: '0 2 3 * *'

jobs:
test-tutorial-on-colab:
name: Test tutorial on latest colab image
runs-on: ubuntu-latest-4core # increase disk space
# https://console.cloud.google.com/artifacts/docker/colab-images/europe/public/runtime
container:
image: europe-docker.pkg.dev/colab-images/public/runtime:latest
steps:
- uses: actions/checkout@v4
- name: Install pimms-learn and papermill
run: |
python3 -m pip install pimms-learn papermill
- name: Run tutorial
run: |
cd project
papermill 04_1_train_pimms_models.ipynb 04_1_train_pimms_models_output.ipynb
20 changes: 10 additions & 10 deletions project/04_1_train_pimms_models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"id": "eae0a078",
"metadata": {},
"source": [
"# Scikit-learn styple transformers of the data\n",
"# PIMMS Tutorial: Scikit-learn style transformers\n",
"\n",
"1. Load data into pandas dataframe\n",
"2. Fit transformer on training data\n",
"2. Fit model on training data, potentially specify validation data\n",
"3. Impute only missing values with predictions from model\n",
"\n",
"Autoencoders need wide training data, i.e. a sample with all its features' intensities, whereas\n",
Expand All @@ -34,7 +34,7 @@
" except metadata.PackageNotFoundError:\n",
" print(\"Install PIMMS...\")\n",
" # !pip install git+https://github.com/RasmussenLab/pimms.git@dev\n",
" !pip install pimms-learn "
" !pip install pimms-learn"
]
},
{
Expand Down Expand Up @@ -74,7 +74,7 @@
"\n",
"\n",
"from vaep.plotting.defaults import color_model_mapping\n",
"import vaep.plotting.data \n",
"import vaep.plotting.data\n",
"import vaep.sampling\n",
"\n",
"from vaep.sklearn.cf_transformer import CollaborativeFilteringTransformer\n",
Expand Down Expand Up @@ -208,7 +208,7 @@
"\n",
"\n",
"def select_features(df, feat_prevalence=.2, axis=0):\n",
" # ! vaep.filter.select_features\n",
" # # ! vaep.filter.select_features\n",
" N = df.shape[axis]\n",
" minimum_freq = N * feat_prevalence\n",
" freq = df.notna().sum(axis=axis)\n",
Expand Down Expand Up @@ -273,7 +273,7 @@
"metadata": {},
"outputs": [],
"source": [
"# # # CollaborativeFilteringTransformer?"
"# # # # CollaborativeFilteringTransformer?"
]
},
{
Expand Down Expand Up @@ -680,10 +680,6 @@
}
],
"metadata": {
"mystnb": {
"execution_raise_on_error": true,
"execution_timeout": 120
},
"jupytext": {
"cell_metadata_filter": "-all",
"main_language": "python",
Expand All @@ -705,6 +701,10 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.17"
},
"mystnb": {
"execution_raise_on_error": true,
"execution_timeout": 120
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions project/04_1_train_pimms_models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# %% [markdown]
# # Scikit-learn styple transformers of the data
# # PIMMS Tutorial: Scikit-learn style transformers
#
# 1. Load data into pandas dataframe
# 2. Fit transformer on training data
# 2. Fit model on training data, potentially specify validation data
# 3. Impute only missing values with predictions from model
#
# Autoencoders need wide training data, i.e. a sample with all its features' intensities, whereas
Expand All @@ -21,7 +21,7 @@
except metadata.PackageNotFoundError:
print("Install PIMMS...")
# # !pip install git+https://github.com/RasmussenLab/pimms.git@dev
# !pip install pimms-learn
# !pip install pimms-learn

# %% [markdown]
# If on colab, please restart the environment and run everything from here on.
Expand All @@ -42,7 +42,7 @@


from vaep.plotting.defaults import color_model_mapping
import vaep.plotting.data
import vaep.plotting.data
import vaep.sampling

from vaep.sklearn.cf_transformer import CollaborativeFilteringTransformer
Expand Down

0 comments on commit c5c1335

Please sign in to comment.