Giter Site home page Giter Site logo

galdeia.github.io's Introduction

Laboratory Assistant: Lightweight Symbolic Regression

This project was developed to show the possibility of applying the SymTree algorithm as a lightweight alternative to common Symbolic Regression algorithms. This tool can be used as an assistent to physics and engineering experimental labs to verify equations and functions seen in theory classes.

The algorithm was entirely developed in JavaScript.


Getting Started

The project is hosted at http://gAldeia.github.io, where you can use the SymTree algorithm online without any further requirements.

Also, the project page contains a brief tutorial on how to use the tool, some pre made examples to try out the algorithm and a theorical fundamentation of the project (in portuguese);


Installation and Usage

In case you only want the algorithm source code, you'll need to download and include in your HTML two files:

LoadFile.js SymbolicRegression.js
The LoadFile.js deals with the user input, reading it from a html <input type=text> tag or from a html <input type=file>, and converting it to an array of DataPoints (an object created to make notation more meanfull) The SymbolicRegression.js contains three algorithms, all based on the new data structure recently introduced by Fabrício Olivetti de França (GitHub) called IT - iteraction transformation.

Pre requisites

The project depends on the math.js library to handle matrix operations, ploty.js for plotting the results, Mathajax for displaying LaTeX equations, Bootstrap for the structure of the site, jQuery for the interactiveness, and Font Awesome for the icons on the menus.

It is important to notice that is possible to use those libraries without installing it (via CDN).

Running

  1. Read the user input using one of the methods:
  performUpload('my-manualinput', 'manual');
  performUpload('my-csvinput', 'csv');
  1. Use one of the regression algorithms and store the result in a variable:
  performRegression('SymTree');
  performRegression('ITLS');
  performRegression('ITES');
  1. The performRegression method will search for some tags to set the parameters of the models:
 if (algorithm==="SymTree"){
        let iteractions = parseInt($('#symtree-iteractions').val());
        let minI        = parseInt($('#symtree-inv').val());
        let minT        = parseInt($('#symtree-transf').val());
        let threshold   = parseFloat($('#symtree-threshold').val());
        let stopscore   = parseFloat($('#symtree-stopscore').val());

        configuration = {
            iteractions       : iteractions,
            threshold         : threshold,
            minInverse        : minI,
            minTransformation : minT,
            stopscore         : stopscore
        }
        
        //(Xs, ts, iterations, threshold, minI, minT, stopScore)
        expression = SYMTREE(Xtemp, ytemp, iteractions, threshold, minI, minT, stopscore);
    }

    if (algorithm==="ITLS"){
        let popsize     = Number($('#itls-popsize').val());
        let startsize   = Number($('#itls-startsize').val());
        let endsize     = Number($('#itls-endsize').val());
        let expolim     = Number($('#itls-expolim').val());
        let iteractions = Number($('#itls-iteractions').val());
        let stopscore   = Number($('#itls-stopscore').val());

        configuration = {
            popsize     : popsize,
            startsize   : startsize,
            endsize     : endsize,
            expolim     : expolim,
            iteractions : iteractions,
            stopscore   : stopscore   
        }

        //(Xs, ys, popSize, minSize, maxSize, expolim, iterations, stopScore)
        expression = ITLS(Xtemp, ytemp, popsize, startsize, startsize+endsize, expolim, iteractions, stopscore);
    }
        
    if (algorithm==="ITES"){
        let popsize    = Number($('#ites-popsize').val());
        let startsize  = Number($('#ites-startsize').val());
        let endsize    = Number($('#ites-endsize').val());
        let selecsize  = Number($('#ites-selecsize').val());
        let expolim    = Number($('#ites-expolim').val());
        let gens       = Number($('#ites-gens').val());
        let stopscore  = Number($('#ites-stopscore').val());
        
        configuration = {
            popsize    : popsize,
            startsize  : startsize,
            endsize    : endsize,
            selecsize  : selecsize,
            expolim    : expolim,
            gens       : gens,
            stopscore  : stopscore
        }

        //(Xs, ys, popSize, selectedSize, minSize, maxSize, expolim, generations, stopScore)
        expression = ITES(Xtemp, ytemp, popsize, selecsize, startsize, startsize+endsize, expolim, gens, stopscore);
    }
  1. Now to retrieve informations from the returned expression:
  let exp_str   = printIT_html(expression);
  let exp_latex = printIT_latex(expression);

License

See the LICENSE.md file for details.

galdeia.github.io's People

Contributors

dependabot[bot] avatar folivetti avatar galdeia avatar

Watchers

 avatar  avatar

galdeia.github.io's Issues

Uso de >= para determinar inclusão de novos termos

if (aux_term.getScore() >= leaf.getScore()){//score é calculado no construtor
refined_exp_list.push(exp_list[i]);
}
}
//remove da exp_list aqueles termos que já estão na expressão
var toCheck = leaf.getTerms();
for (var i=0; i<toCheck.length; i++){
for(var j=refined_exp_list.length-1; j>=0; j--){
if (toCheck[i].getTerm_d()==refined_exp_list[j].getTerm_d()){ //compara a string de cada um
refined_exp_list.slice(j, 1);
}
}
}
var children = [ ];
while (refined_exp_list.length>0){
//esta seria a greedy search
var best = leaf;
for(var i=refined_exp_list.length-1; i>=0; i--){
var aux = new LinearExpression( best.getTerms().concat([refined_exp_list[i]]) );
if (aux.getScore() >= best.getScore()){

Quando utilizamos >= para comparar se o termo deve ser incluído ou não, o == ajuda a acrescentar termos inúteis, já que eles não melhoram o score e aumentam a complexidade da expressão!

var -> let

trocar as últimas var por let na SymTree

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.