From fbcc1650aed872b4a0ddf94d1769c799677296e1 Mon Sep 17 00:00:00 2001 From: darrylong Date: Fri, 3 Nov 2023 18:37:51 +0800 Subject: [PATCH] Updated researcher doc --- docs/source/user/iamaresearcher.rst | 55 +++++++++++++++++++---------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/docs/source/user/iamaresearcher.rst b/docs/source/user/iamaresearcher.rst index c25bddd1f..5f4cc6295 100644 --- a/docs/source/user/iamaresearcher.rst +++ b/docs/source/user/iamaresearcher.rst @@ -15,7 +15,7 @@ In this guide, we will cover the following topics: - Adding your own metric - Adding your own dataset - Development Workflow -- Analyze results +- Using additional packages What can you do with Cornac? ----------------------------- @@ -289,6 +289,9 @@ Adding your own model on Cornac is easy. Cornac is designed to be flexible and extensible, allowing researchers to easily add their own models into the framework. +Files to add +^^^^^^^^^^^^ + Below is an example of the ``PMF`` model which was already added into Cornac. We will use this as a reference to add our own model. @@ -769,6 +772,9 @@ We will use this as a reference to add our own model. user_based=True, ).run() +Files to edit +^^^^^^^^^^^^^ + To add your model to the overall Cornac package, you need to edit the following file: @@ -800,36 +806,49 @@ Development Workflow Before we move on to the section of building a new model, let's take a look at the development workflow of Cornac. -The main workflow of developing a new model will be to: - -``Create an example, Create model files --> Build --> Run Example`` +First time setup +^^^^^^^^^^^^^^^^ -Whenever a new change is done to your model files, you are required to rebuild -Cornac using the ``setup.py`` script. This will ensure that the changes you have -made to your model files are reflected in the Cornac package. +As Cornac contains models which uses Cython, compilation is required before +testing could be done. In order to do so, you need to run the following command: +.. code-block:: bash -Rebuilding Cornac -^^^^^^^^^^^^^^^^^ + python setup.py build_ext —inplace -1. To build Cornac on your environment: +This will compile the Cython files and place the compiled files in the +``cornac/models`` folder. -.. code-block:: bash - python3 setup.py install +The main workflow of developing a new model will be to: +1. Code model files +2. Code example +3. Run Example -.. note:: +Folder structure for testing +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - The following packages are required for building Cornac on your environment: ``Cython``, ``numpy``, ``scipy``. +.. code-block:: bash - If you do not have them, install by using the following commands: + cornac + |-- cornac + | |-- models + | |-- mymodel + | | |-- __init__.py + | | |-- recom_mymodel.py + | |-- requirements.txt + |-- mymodel_example.py <-- not in the examples folder - .. code-block:: bash +To run the example, ensure that your current working directory is in the top +``cornac`` folder. Then, run the following command: + +.. code-block:: bash - pip3 install Cython numpy scipy + python mymodel_example.py -2. Run an example utilising your new model. +Whenever a new change is done to your model files, just run the example for +testing and debugging. Analyze Results ---------------