UPDATE: the guide for moodlemlbackend 3.0.5 with Python 3.6 can be found in this article: Moodle Analytics – Part 1. – Setting up the Python Machine Learning Backend in cPanel – Reloaded

Moodle Analytics machine learning models were introduced in Moodle 3.7.
Moodle currently supports two predictions processors:

  • PHP machine learning backend which comes with the core installation
  • Python machine learning backend which is using TensorFlow and much more accurate than the PHP backend and which is recommended over the PHP by MoodleDev.

Python backend requires python binary and moodlemlbackend python package.

This guide will help to to set up the the backend in cPanel.

Step 1.

  1. Login to your cPanel account.
  2. Click on “Setup Python App”
cPanel Software selection
cPanel Software selection

Step 2.

Moodle’s moodleemlbackend python package is only available from python 2.7, 3.4 and 3.5. For stables (Moodle 3.6 and 3.7) developers have added compatibility for Python 3.6.

Tried 2.7, 3.4 and 3.6, but for me only Python 3.4 worked well.

  1. Select Python 3.4 version from the drop-down list.
  2. Specify your Application root (eg. analytics).
  3. Specify your Application URL (eg. analytics). Do not leave it empty!
  4. Click “CREATE” button.
cPanel Python Create Application
cPanel Create Python Application

Step 3.

In old cPanel version Python modules can be added on the Setup Python App / Existing applications settings dialog but in the new version modules need to be installed manually. You may use Terminal or you can connect to your server with SSH.

  1. enter to your Python virtual environment, run the command but change the directories:
    $ source /home/your_home/virtualenv/analytics/3.4/bin/activate && cd /home/your_home/analytics
  2. Install moodlemlbackend package.
    $ pip install moodlemlbackend
Installing moodlemlbackend Python package
Installing moodlemlbackend Python package

The result should be like this:

Installing collected packages: scikit-learn, numpy, six, protobuf, tensorflow,scipy, python-dateutil, pytz, cycler, pyparsing, matplotlib, moodlemlbackend
Successfully installed cycler-0.10.0 matplotlib-1.5.3 moodlemlbackend-1.0.0 numpy-1.11.3 protobuf-3.9.1 pyparsing-2.4.2 python-dateutil-2.8.0 pytz-2019.2 scikit-learn-0.17.1 scipy-0.17.1 six-1.12.0 tensorflow-1.0.1

Restart Python application on the Setup Python App screen and you are done.

Cheers,

One thought to “Moodle Analytics – Part 1. – Setting up the Python Machine Learning Backend in cPanel”

  • shital

    wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.

    PMP Certification

    Reply

Leave a comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.