OTTAA-Project / ottaa_project_flutter

Join us to create the first predictive augmentative communication platform for speech-impaired children!
https://ottaa-project.github.io/
GNU General Public License v3.0
10 stars 4 forks source link

Predictive Algorithm #25

Closed hectoritr closed 2 years ago

hectoritr commented 2 years ago

Screenshot of the feature to be developed. No need.

Describe the solution you'd like We need to implement an algorithm that helps prediction based on the context. This works related to TAGs so this has to be present in the Pictogram JSON in order to work.

We will start only with the Frequency of usage and Time of the day, keep in mind that more variables will be implemented to design the code accordingly.

A "score" value should be calculated for each "Child" pictogram in the Relationship array of the father and sorted based on the "score" value, this should happen each time the user selects a "parent" Pictogram.

The formula to calculate "score" is as follows. (peso = weight; hora = time; sexo = gender; edad = age)

double pesoFrec = 2, pesoAgenda = 8, pesoGps = 12, pesoHora = 50,
                pesoSexo = 3, pesoEdad = 5;

score = (frec * pesoFrec) + (agendaUsuario * pesoAgenda) + (gps * pesoGps) + (horaDelDia *
                pesoHora) + (sexoUsuario * pesoSexo) + (edadUsuario * pesoEdad);

Pseudocode

The user chooses one Pictogram from MainScreen "parent" Pictogram

Get the array "Relacion" with all children from the "parent" Pictogram.
Sort them by "score"
Show in MainScreen the first 4 with the highest score.

To calculate "score" For each of the children of "parent" pictogram in array "Relacion"

Get the current device time
Get the frec value
Get the array "hora"

Calculate the current TAG for hora with the following formula

            if (time >= 5 && time <= 11) {
                return Horario.MANANA;
            } else if (time > 11 && time <= 14) {
                return Horario.MEDIODIA;
            } else if (time > 14 && time < 20) {
                return Horario.TARDE;
            } else {
                return Horario.NOCHE;

_Now we start to combine everything

We should see if the Pictogram TAG hora matches with Current Device TAG hora, if at least one match should return 1 if not 0

try {
            if(json == null)
                return 0;
            if(json.has(Constants.HORA)){
                JSONArray array = json.getJSONArray(Constants.HORA);
                for (int i = 0; i < array.length(); i++) {
                    if (hora.toString().equals(array.get(i).toString())) {
                        return 1;
                    }
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return 0;

After this, we should calculate "score" with the given formula and return the value to the sorted method.

Action Plan Add an Action Plan wit