Skip to content

Commit

Permalink
Merge pull request #88 from bio-ontology-research-group/docs
Browse files Browse the repository at this point in the history
Docs
  • Loading branch information
ferzcam authored Nov 19, 2024
2 parents f3a05fe + f6e4195 commit fab9ff6
Show file tree
Hide file tree
Showing 47 changed files with 73 additions and 3,218 deletions.
4 changes: 0 additions & 4 deletions docs/source/corpus/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ To train a Word2Vec model with a generated corpus, we can use the class: :class:
model.generate_corpus(save=True, with_annotations=True)
model.train()

.. testoutput::

Corpus saved in test

.. attention::
The ``set_w2v_model`` receives the same arguments as the :class:`gensim.models.word2vec.Word2Vec` model.

17 changes: 8 additions & 9 deletions docs/source/evaluation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@ Evaluating the embeddings

The evaluation of models is specific to the task, which is given by the dataset. For example, when using the |ppidataset|, we will use the |ppievaluator|. For example, a typical pipeline to train a model would be:



.. testcode::

from mowl.datasets.builtin import PPIYeastSlimDataset
from mowl.models import SyntacticPlusW2VModel

from mowl.evaluation import PPIEvaluator

dataset = PPIYeastSlimDataset()
model = SyntacticPlusW2VModel(dataset, corpus_filepath="test")
model.set_evaluator(PPIEvaluator)
model.set_w2v_model(min_count=1)

model.generate_corpus(save=True, with_annotations=True)
model.train()

To evaluate, we first need to assign the evaluator:

.. testcode::

from mowl.evaluation import PPIEvaluator
model.set_evaluator(PPIEvaluator)
model.evaluate()

model.evaluate(dataset.testing)

What characterizes each evaluator class are two things:

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/source/examples/elmodels/plot_1_elembeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"outputs": [],
"source": [
"from mowl.datasets.builtin import PPIYeastSlimDataset\nfrom mowl.models.elembeddings.examples.model_ppi import ELEmPPI\n\ndataset = PPIYeastSlimDataset()\n\nmodel = ELEmPPI(dataset,\n embed_dim=30,\n margin=0.1,\n reg_norm=1,\n learning_rate=0.001,\n epochs=20,\n batch_size=4096,\n model_filepath=None,\n device='cpu')\n\nmodel.train()"
"from mowl.datasets.builtin import PPIYeastSlimDataset\nfrom mowl.models.elembeddings.examples.model_ppi import ELEmPPI\n\ndataset = PPIYeastSlimDataset()\n\nmodel = ELEmPPI(dataset,\n embed_dim=30,\n margin=0.1,\n reg_norm=1,\n learning_rate=0.001,\n epochs=20,\n batch_size=20000,\n model_filepath=None,\n device='cuda')\n\nmodel.train()"
]
},
{
Expand All @@ -72,7 +72,7 @@
},
"outputs": [],
"source": [
"from mowl.evaluation import PPIEvaluator\n\nmodel.set_evaluator(PPIEvaluator)\nmodel.evaluate()"
"from mowl.evaluation import PPIEvaluator\n\nmodel.set_evaluator(PPIEvaluator)\nmodel.evaluate(dataset.testing)\n\nprint(model.metrics)"
]
}
],
Expand All @@ -92,7 +92,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
"version": "3.9.20"
}
},
"nbformat": 4,
Expand Down
7 changes: 4 additions & 3 deletions docs/source/examples/elmodels/plot_1_elembeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
reg_norm=1,
learning_rate=0.001,
epochs=20,
batch_size=4096,
batch_size=20000,
model_filepath=None,
device='cpu')
device='cuda')

model.train()

Expand All @@ -93,5 +93,6 @@
from mowl.evaluation import PPIEvaluator

model.set_evaluator(PPIEvaluator)
model.evaluate()
model.evaluate(dataset.testing)

print(model.metrics)
2 changes: 1 addition & 1 deletion docs/source/examples/elmodels/plot_1_elembeddings.py.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2ddd5683746cd97d8125b7a8921302ed
08e8036ed8ba5df4a24e22223004d627
22 changes: 9 additions & 13 deletions docs/source/examples/elmodels/plot_1_elembeddings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ Training the model
reg_norm=1,
learning_rate=0.001,
epochs=20,
batch_size=4096,
batch_size=20000,
model_filepath=None,
device='cpu')
device='cuda')
model.train()
Expand All @@ -124,8 +124,7 @@ Training the model

.. code-block:: none
Number of evaluation classes: 6039
0%| | 0/20 [00:00<?, ?it/s] 5%|▌ | 1/20 [00:15<04:55, 15.58s/it] 10%|█ | 2/20 [00:15<01:57, 6.53s/it] 15%|█▌ | 3/20 [00:15<01:01, 3.63s/it] 20%|██ | 4/20 [00:16<00:36, 2.28s/it] 25%|██▌ | 5/20 [00:16<00:22, 1.52s/it] 30%|███ | 6/20 [00:16<00:14, 1.07s/it] 35%|███▌ | 7/20 [00:16<00:10, 1.28it/s] 40%|████ | 8/20 [00:16<00:07, 1.68it/s] 45%|████▌ | 9/20 [00:17<00:05, 2.13it/s] 50%|█████ | 10/20 [00:17<00:03, 2.60it/s] 55%|█████▌ | 11/20 [00:17<00:02, 3.07it/s] 60%|██████ | 12/20 [00:17<00:02, 3.51it/s] 65%|██████▌ | 13/20 [00:17<00:01, 3.89it/s] 70%|███████ | 14/20 [00:18<00:01, 4.20it/s] 75%|███████▌ | 15/20 [00:18<00:01, 4.45it/s] 80%|████████ | 16/20 [00:18<00:00, 4.64it/s] 85%|████████▌ | 17/20 [00:18<00:00, 4.76it/s] 90%|█████████ | 18/20 [00:18<00:00, 4.87it/s] 95%|█████████▌| 19/20 [00:19<00:00, 4.92it/s] 100%|██████████| 20/20 [00:19<00:00, 4.98it/s] 100%|██████████| 20/20 [00:19<00:00, 1.04it/s]
0%| | 0/20 [00:00<?, ?it/s] 5%|▌ | 1/20 [00:14<04:42, 14.84s/it] 70%|███████ | 14/20 [00:14<00:04, 1.31it/s] 100%|██████████| 20/20 [00:14<00:00, 1.33it/s]

1

Expand All @@ -139,7 +138,7 @@ Evaluating the model
Now, it is time to evaluate embeddings. For this, we use the
:class:`ModelRankBasedEvaluator <mowl.evaluation.ModelRankBasedEvaluator>` class.

.. GENERATED FROM PYTHON SOURCE LINES 91-98
.. GENERATED FROM PYTHON SOURCE LINES 91-99
.. code-block:: Python
Expand All @@ -148,8 +147,9 @@ Now, it is time to evaluate embeddings. For this, we use the
from mowl.evaluation import PPIEvaluator
model.set_evaluator(PPIEvaluator)
model.evaluate()
model.evaluate(dataset.testing)
print(model.metrics)
Expand All @@ -158,21 +158,17 @@ Now, it is time to evaluate embeddings. For this, we use the

.. code-block:: none
Number of evaluation classes: 6039
Evaluating in device: cpu
Evaluating with deductive closure: False
Excluding testing set: False
Filtering deductive closure: False
{'mr': 2464.669435215947, 'mrr': 0.0024686094502139495, 'f_mr': 2464.669435215947, 'f_mrr': 0.0024686094502139495, 'auc': 0.5919726009910654, 'f_auc': 0.5919726009910654, 'hits@1': 0.00016611295681063124, 'hits@3': 0.0009966777408637873, 'hits@10': 0.0027408637873754154, 'hits@50': 0.016777408637873754, 'hits@100': 0.03106312292358804, 'f_hits@1': 0.00016611295681063124, 'f_hits@3': 0.0009966777408637873, 'f_hits@10': 0.0027408637873754154, 'f_hits@50': 0.016777408637873754, 'f_hits@100': 0.03106312292358804}
.. rst-class:: sphx-glr-timing

**Total running time of the script:** (1 minutes 19.804 seconds)
**Total running time of the script:** (0 minutes 36.813 seconds)

**Estimated memory usage:** 4175 MB
**Estimated memory usage:** 2066 MB


.. _sphx_glr_download_examples_elmodels_plot_1_elembeddings.py:
Expand Down
6 changes: 3 additions & 3 deletions docs/source/examples/elmodels/plot_2_elboxembeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"outputs": [],
"source": [
"from mowl.datasets.builtin import PPIYeastSlimDataset\nfrom mowl.models.elboxembeddings.examples.model_ppi import ELBoxPPI\n\ndataset = PPIYeastSlimDataset()\n\nmodel = ELBoxPPI(dataset,\n embed_dim=30,\n margin=-0.05,\n reg_norm=1,\n learning_rate=0.001,\n epochs=20,\n batch_size=4096,\n model_filepath=None,\n device='cpu')\n\nmodel.train()"
"from mowl.datasets.builtin import PPIYeastSlimDataset\nfrom mowl.models.elboxembeddings.examples.model_ppi import ELBoxPPI\n\ndataset = PPIYeastSlimDataset()\n\nmodel = ELBoxPPI(dataset,\n embed_dim=30,\n margin=-0.05,\n reg_norm=1,\n learning_rate=0.001,\n epochs=20,\n batch_size=20000,\n model_filepath=None,\n device='cpu')\n\nmodel.train()"
]
},
{
Expand All @@ -72,7 +72,7 @@
},
"outputs": [],
"source": [
"from mowl.evaluation import PPIEvaluator\n\nmodel.set_evaluator(PPIEvaluator)\nmodel.evaluate()"
"from mowl.evaluation import PPIEvaluator\n\nmodel.set_evaluator(PPIEvaluator)\nmodel.evaluate(dataset.testing)"
]
}
],
Expand All @@ -92,7 +92,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
"version": "3.9.20"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/elmodels/plot_2_elboxembeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
reg_norm=1,
learning_rate=0.001,
epochs=20,
batch_size=4096,
batch_size=20000,
model_filepath=None,
device='cpu')

Expand All @@ -91,4 +91,4 @@
from mowl.evaluation import PPIEvaluator

model.set_evaluator(PPIEvaluator)
model.evaluate()
model.evaluate(dataset.testing)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a24176821130d17727870b9907ea387d
00584b1a2fc4ce8970b4ecedb98dc6f4
17 changes: 5 additions & 12 deletions docs/source/examples/elmodels/plot_2_elboxembeddings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Training the model
reg_norm=1,
learning_rate=0.001,
epochs=20,
batch_size=4096,
batch_size=20000,
model_filepath=None,
device='cpu')
Expand All @@ -115,8 +115,7 @@ Training the model

.. code-block:: none
Number of evaluation classes: 6039
0%| | 0/20 [00:00<?, ?it/s] 5%|▌ | 1/20 [00:00<00:06, 2.99it/s] 10%|█ | 2/20 [00:00<00:05, 3.08it/s] 15%|█▌ | 3/20 [00:00<00:05, 3.06it/s] 20%|██ | 4/20 [00:01<00:05, 2.99it/s] 25%|██▌ | 5/20 [00:01<00:04, 3.02it/s] 30%|███ | 6/20 [00:02<00:04, 2.96it/s] 35%|███▌ | 7/20 [00:02<00:04, 2.95it/s] 40%|████ | 8/20 [00:02<00:04, 2.94it/s] 45%|████▌ | 9/20 [00:03<00:03, 2.94it/s] 50%|█████ | 10/20 [00:03<00:03, 2.97it/s] 55%|█████▌ | 11/20 [00:03<00:03, 2.95it/s] 60%|██████ | 12/20 [00:04<00:02, 2.95it/s] 65%|██████▌ | 13/20 [00:04<00:02, 2.95it/s] 70%|███████ | 14/20 [00:04<00:02, 2.99it/s] 75%|███████▌ | 15/20 [00:05<00:01, 2.93it/s] 80%|████████ | 16/20 [00:05<00:01, 2.94it/s] 85%|████████▌ | 17/20 [00:05<00:01, 2.93it/s] 90%|█████████ | 18/20 [00:06<00:00, 2.94it/s] 95%|█████████▌| 19/20 [00:06<00:00, 2.93it/s] 100%|██████████| 20/20 [00:06<00:00, 2.95it/s] 100%|██████████| 20/20 [00:06<00:00, 2.96it/s]
0%| | 0/20 [00:00<?, ?it/s] 5%|▌ | 1/20 [00:00<00:05, 3.60it/s] 10%|█ | 2/20 [00:00<00:04, 4.13it/s] 15%|█▌ | 3/20 [00:00<00:03, 4.37it/s] 20%|██ | 4/20 [00:00<00:03, 4.53it/s] 25%|██▌ | 5/20 [00:01<00:03, 4.65it/s] 30%|███ | 6/20 [00:01<00:02, 4.70it/s] 35%|███▌ | 7/20 [00:01<00:02, 4.50it/s] 40%|████ | 8/20 [00:01<00:02, 4.57it/s] 45%|████▌ | 9/20 [00:01<00:02, 4.60it/s] 50%|█████ | 10/20 [00:02<00:02, 4.57it/s] 55%|█████▌ | 11/20 [00:02<00:01, 4.61it/s] 60%|██████ | 12/20 [00:02<00:01, 4.66it/s] 65%|██████▌ | 13/20 [00:02<00:01, 4.55it/s] 70%|███████ | 14/20 [00:03<00:01, 4.60it/s] 75%|███████▌ | 15/20 [00:03<00:01, 4.64it/s] 80%|████████ | 16/20 [00:03<00:00, 4.50it/s] 85%|████████▌ | 17/20 [00:03<00:00, 4.59it/s] 90%|█████████ | 18/20 [00:03<00:00, 4.46it/s] 95%|█████████▌| 19/20 [00:04<00:00, 4.42it/s] 100%|██████████| 20/20 [00:04<00:00, 4.33it/s] 100%|██████████| 20/20 [00:04<00:00, 4.49it/s]
1
Expand All @@ -139,26 +138,20 @@ Now, it is time to evaluate embeddings. For this, we use the
from mowl.evaluation import PPIEvaluator
model.set_evaluator(PPIEvaluator)
model.evaluate()
model.evaluate(dataset.testing)
.. rst-class:: sphx-glr-script-out

.. code-block:: none
Number of evaluation classes: 6039
.. rst-class:: sphx-glr-timing

**Total running time of the script:** (1 minutes 30.418 seconds)
**Total running time of the script:** (0 minutes 37.188 seconds)

**Estimated memory usage:** 3174 MB
**Estimated memory usage:** 1681 MB


.. _sphx_glr_download_examples_elmodels_plot_2_elboxembeddings.py:
Expand Down
10 changes: 5 additions & 5 deletions docs/source/examples/elmodels/sg_execution_times.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Computation times
=================
**02:50.222** total execution time for 2 files **from examples/elmodels**:
**01:14.002** total execution time for 2 files **from examples/elmodels**:

.. container::

Expand All @@ -33,8 +33,8 @@ Computation times
- Time
- Mem (MB)
* - :ref:`sphx_glr_examples_elmodels_plot_2_elboxembeddings.py` (``plot_2_elboxembeddings.py``)
- 01:30.418
- 3174.5
- 00:37.188
- 1681.3
* - :ref:`sphx_glr_examples_elmodels_plot_1_elembeddings.py` (``plot_1_elembeddings.py``)
- 01:19.804
- 4175.1
- 00:36.813
- 2065.5
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/source/examples/graph_based/plot_1_dl2vec.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
"outputs": [],
"source": [
"from mowl.evaluation import GDAEvaluator\nmodel.set_evaluator(GDAEvaluator)\nmodel.evaluate()"
"from mowl.evaluation import GDAEvaluator\nmodel.set_evaluator(GDAEvaluator)\nmodel.evaluate(dataset.testing)"
]
}
],
Expand All @@ -78,7 +78,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
"version": "3.9.20"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/graph_based/plot_1_dl2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@

from mowl.evaluation import GDAEvaluator
model.set_evaluator(GDAEvaluator)
model.evaluate()
model.evaluate(dataset.testing)

2 changes: 1 addition & 1 deletion docs/source/examples/graph_based/plot_1_dl2vec.py.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7a4c447f2412785f8362abe44cff19c2
fed90cad2165a3cd8374233ec981339b
Loading

0 comments on commit fab9ff6

Please sign in to comment.