· Aug 22 4m read

QuinielaML or how to get rich with Embedded Python and IntegratedML

Welcome dear members of the Community to the presentation and first article of a small project that will demonstrate the capabilities of InterSystems IRIS to provide full backup functionality for a web application developed in Angular. This article will be limited to presenting the concept as well as the InterSystems IRIS functionalities used in a general way, going into more detail in subsequent articles.

Welcome to QuinielaML!


It is possible that you have already heard about InterSystems IRIS functionalities such as Embedded Python and IntegratedML, but surely you have not had the opportunity to get involved with them or you simply do not know how to fit these functionalities into your day to day, well, taking advantage of the the beginning of the soccer season in Spain, I thought that would be a great way to explain all these features of InterSystems IRIS developing an application to help us to predict soccer results in order to become millionaires with the Quiniela.

What is Quiniela?
Lord Of The Rings Smeagol GIF - Lord Of The Rings Smeagol Gollum - Discover  & Share GIFs

For those of you who are not familiar with the term, Quiniela is a very famous type of sports betting in Spain since, for many years, it was the only legal sports betting format.

La Quiniela is, roughly speaking, a type of sports bet in which you must guess who will be the winner of 15 games each round (10 First Division games and 5 Second Division). The victory of the home/local team is marked with a 1, that of the away/visitor team with a 2 and the tie with an X.

Here you have an example of a ticket from the Quiniela.

Quiniela Elige8, el nuevo juego asociado a la quiniela. - Loteria Cano

How to predict Quiniela results?

We can't really predict an outcome, but what we can do is estimate the probability of each outcome based on certain variables. In this case we have taken into consideration the following:

  1. Historical results: result of matches between two teams since the year 2000.
  2. Home team streak: Home team wins the last 3 home games.
  3. Away team streak: Away team wins in the last away games played.
  4. Referee: result of the teams according to the referee.

How to get all that data to build our prediction model?

Web scraping to the rescue! All these historical data are accessible on the web, so we will only need to implement from our IRIS a way to obtain this data from a particular website, for our example we have used BDFutbol, which provides us with data regarding all the matches played historically both the First and Second division.

How can we perform such web scraping? Very simple, with Embedded Python, we will only need to import the beautifulsoup4 and requests Python libraries into our IRIS server and we will be able to obtain the necessary information from said website.

Project architecture

As a former developer I have chosen Angular to develop the user interface part and thus not complicate my life too much. It is obvious that the backend selection will be InterSystems IRIS with the IntegratedML functionality included in its Community version.

Here you can see a small diagram of the chosen architecture:

How to deploy and run it:

The entire project is Dockerized, so you only need to download the source code from GitHub to your local computer, install Docker and Docker Compose and execute the following instructions from the terminal, in the path where you downloaded the project:

docker-compose build
docker-compose up -d

It will automatically deploy an InterSystems IRIS image to port 52774 (using the usual management portal access) and the Angular application directly to this URL

Accessing to QuinielaML

Once the login page is open, we must enter as username and password:

superuser / SYS

It will be redirected directly to the predictions screen, but we must display the side menu by clicking on the application icon in the upper left:

And select Data management from the menu:

This will take us to the screen from which we can import the data from the BDFutbol website, prepare it to calculate the streaks and modify the text values to numerical format and finally create the data model and train the model with the prepared data.

You must start with the first option on the left and move in the direction of the arrows, waiting for the previous step to finish:

Generating predictions:

With the model trained, we will only have to start entering the matches of the day that we want to predict. To do this, we will click on the application icon in the upper left and select Result prediction

From this screen we will only have to fill in the fields at the top to generate an adequate prediction, it is enough to add the data of the teams to generate the prediction, but the more data, the better.

The frontend part has not been fully reviewed, so you may find a bug, don't hesitate to let me know so I can improve it.

With each match you record you will automatically see the prediction given by the model for the result. Once the round is over, you can enter the result to get an idea of the approximate prediction by clicking on the match in question.

Good! You already have everything to become millionaires with the Quiniela and InterSystems IRIS. In the next article we will explain how we open a session from Angular with InterSystems IRIS through JWT.

Until next time!

Discussion (0)1
Log in or sign up to continue