Giter VIP home page Giter VIP logo

raff.jl's Introduction

RAFF - Robust Algebraic Fitting Function

Build Status codecov

DOI DOI

This package implements a robust method to fit a given function (described by its parameters) to input data. The method is based on the LOVO algorithm [1] and also in a suitable voting strategy in order automatically eliminate outliers.

Potential use of this package is in statistical problems which depend on fitting functions or in more specific fields like computer vision for problems related shape detection.

For a brief description of the potential of this program and the difference between related strategies in the literature, like least square, consider the following dataset

A=[-2.0 5.0; -1.5 3.25; -1.0 2.0 ; -0.5 1.25; 0.0 1.0 ; 0.5 2.55; 1.0 2.0 ; 1.5 3.25; 2.0 5.0 ;]

Let us assume that we wish to find a fitting function given by parameters x[1], x[2] and the model

f(t)=x[1]*t^2+x[2]

where f(t[i])≈A[i,2] in the least square sense. When we apply a least square strategy we obtain

and when we apply RAFF strategy we get

Note that RAFF detects (automatically) the model f(t)=1.0*t^2 +1.0 that is, RAFF detects the point (0.5,2.55) like an outlier and excludes the influence of this point for determine f(t). Consequently, RAFF detects the number of possible outliers and in the same time, which their are. This fact distinguishes RAFF from other techniques like [1] or classical least square.

Other useful examples are found in the documentation and also in directory examples/.

Installation

RAFF is a package registered in the General repository. Consequently, in order to install RAFF, just type in REPL:

julia> ] add RAFF

Advanced

Several files with test problems are provided inside directory test/test_problems. We also provide some scripts to create new random test problems, visualize and solve them using RAFF. Those files can be found in test/scripts. For a detailed explanation of each script file, please refer to the documentation.

Contributing

Any suggestions or contributions to RAFF are very welcome. RAFF is a open-source software available through the MIT license, so users are free to create their own versions of the software. Users are specially encouraged to participate on the project in the following ways:

  • Modifications to the code can be submitter as pull requests to the branch master.
  • Bugs, suggestions and questions can be raised as issues in the project's Github page.
  • General doubts can also be sent directly to fncsobral at uem dot br.

Performance

The following table outlines the results found by the current version of RAFF in the test set.

Name Dim. N Points N Outl. Found Correct Time (s) Status Solution
C1 4 10 2 2 2 0.0006 1 [ 1.999e+00, 1.142e-02, -4.023e+00, -1.053e+01]
C2 4 10 2 1 1 0.0005 1 [ 1.575e+00, 2.635e+00, 3.434e+01, -7.821e+00]
C3 4 10 2 2 1 0.0005 1 [ 4.221e-01, -1.596e+01, 2.388e+01, 2.146e+02]
C4 4 10 1 1 1 0.0005 1 [ 2.701e+00, 2.556e+00, -5.914e+01, -1.021e+02]
C5 4 100 1 9 1 0.0210 1 [ 2.114e+00, 1.160e+00, -6.590e+00, -1.971e+01]
CI1 3 25 2 2 2 0.0020 1 [ 9.741e-01, 9.769e-01, 5.020e+00]
E1 3 20 1 1 0 0.0263 1 [ 3.271e+03, -9.884e+01, 5.507e+01]
E2 3 10 1 2 0 0.0110 1 [ 2.137e+03, 2.760e+03, 2.369e+02]
E3 3 100 1 1 1 0.2297 1 [ 9.590e+02, 9.632e+03, 3.940e-01]
E4 3 100 10 1 1 0.2308 1 [ 1.139e+03, 9.370e+03, 4.206e-01]
LOG1 4 10 1 0 0 0.0042 1 [ 1.479e+03, 2.201e+03, 6.611e+01, -2.075e+02]

Credits

  • Francisco Sobral (Leader)
  • Emerson Vitor Castelani
  • Ronaldo Lopes
  • Wesley Shirabayashi

The authors of this package were sponsored by Fundação Araucária, project number 002/17 - 47223. If you would like to cite this package, please use

Castelani, E. V., Lopes, R., Shirabayashi, W., & Sobral, F. N. C. (2019). RAFF.jl: Robust Algebraic Fitting Function in Julia. Journal of Open Source Software, 4(39), 1385. https://doi.org/10.21105/joss.01385

The following paper describes the theory and several comparison tests

@article{Castelani2021, author = {Castelani, Emerson V. and Lopes, Ronaldo and Shirabayashi, Wesley V. I. and Sobral, Francisco N. C.}, doi = {10.1007/s10898-020-00970-4}, journal = {Journal of Global Optimization}, title = {{A robust method based on LOVO functions for solving least squares problems}}, url = {http://link.springer.com/10.1007/s10898-020-00970-4}, year = {2021} }

References

[1] Andreani, R., Martínez, J. M., Martínez, L., & Yano, F. S. (2009). Low order-value optimization and applications. Journal of Global Optimization, 43(1), 1-22.

raff.jl's People

Contributors

evcastelani avatar fsobral avatar juliatagbot avatar kyleniemeyer avatar matbesancon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

raff.jl's Issues

[JOSS] installation instruction

Since the package is not installable as registered packages for now, either register it (Registrator would be the best option) or add the installation steps at the beginning of the README

Voting strategy in `praff` is different from `raff`

The voting strategy in praff does not apply the filter strategy, nor uses the Inf norm. My suggestion is to implement a function voting_strategy() or something similar so both functions call this one and the implementations remain the same.

Future of Logging

We have to decide how RAFF will show output in a mathematical and efficient way, trying to avoid the use of print or @printf as much as possible. Also we have to decide how logging will work in distributed environments.

Error in view function

There is an error of acess in some index of array.
error_raff

The model in this case was model(x,t)=x[1]*t^2+x[2] and the dataset was

A=[ -2.0  5.0 
 -1.5  3.25
 -1.0  2.0 
 -0.5  1.25
  0.0  1.0 
  0.5  1.25
  1.0  2.0 
  1.5  3.25
  2.0  5.0 ]

Printing logging messages by default

It would be more interesting if logging messages were omitted by default. In current version info messages are printed. Of course we can set
global_logger(ConsoleLogger(stdout, Logging.Error))
But that's uncomfortable.

Paper to JOSS

I have finished the first draft of the paper. @evcastelani Can you build it using Pandoc to see if it works? We can discuss about improvements in this issue.

Infinity "Interrupt exception"

When killing praffwith CTRL+C, it got stuck in this

┌ Error: Error when retrieving solutions.
│   e = InterruptException:
└ @ RAFF ~/personal/clss/RAFF.jl/src/RAFF.jl:760

error.

[JOSS] Julia style guide

RAFF.SortFun!
From Julia style guide, use CamelCase style only for modules and types, use snake_case with lower letters and underscores for functions, values, etc

[JOSS] error running examples

Run with Julia opened in the examples/ folder:

julia> include("./runraff.jl")
[ Info: Precompiling RAFF [4aa82a78-ed18-41f9-aee6-9d73ba3a0b42]
ERROR: LoadError: MethodError: no method matching raff(::getfield(Main, Symbol("##3#4")), ::Array{Any,2}, ::Int64)
Closest candidates are:
  raff(::Function, ::Array{Float64,2}, ::Int64; kwargs...) at /home/mbesancon/.julia/dev/RAFF/src/RAFF.jl:516
  raff(::Function, ::Function, ::Array{Float64,2}, ::Int64; MAXMS, SEEDMS, initguess, ε, noutliers) at /home/mbesancon/.julia/dev/RAFF/src/RAFF.jl:386
Stacktrace:
 [1] top-level scope at /home/mbesancon/.julia/dev/RAFF/examples/runraff.jl:34
 [2] include at ./boot.jl:326 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1038
 [4] include(::Module, ::String) at ./sysimg.jl:29
 [5] include(::String) at ./client.jl:403
 [6] top-level scope at none:0
in expression starting at /home/mbesancon/.julia/dev/RAFF/examples/runraff.jl:9

There should be some explanation in the README what the examples and scripts folders are for, are they different? Should they be tested by Travis CI to ensure they stay up to date?

This issue is raised as part of openjournals/joss-reviews#1385

[JOSS] Merge JOSS branch

The structure of the JOSS branch is very different from the normal repo. The joss branch should have the same structure as the master branch (that of a Julia package), with a paper folder containing the paper.md and .bib files.

This issue is raised as part of: openjournals/joss-reviews#1385

[JOSS] Paper review 1

You will find below my initial review of the paper itself:

Title of the package:
Why "Algebraic"? It uses numerical methods and not symbolic differentiation.

First line: use \mathbb{R} instead of \mathcal{R}

Prefer Package.jl to Package to designate it

Second paragraph of "Summary"
"adjustment of mathematical functions to data" is also refered to as regression, which is not mentioned in the paper, while it is fundamentally the purpose of the package.

"Detection of outliers is always regarded ...". It's hard to see what the authors mean here. Without proper references backing up the statement, this seems rather vague.

"Recently, a good review", the use of "good" is subjective (what is a good review, in what context). A review of what?

In statistics, it is common to use f(x; θ) for a function of x with parameters theta, which one tries to fit in a regression task.

In paragraph "Functionality", the equation is not homogeneous with the rest:
ϕ(x,t) instead of ϕ(x;t), prefer ";" to indicate the separation of data and parameters.

There could be a section on the method itself, or at least more development, including on the LOVO algorithm. For instance, the method is not black-box optimization but assumes the existence of gradient, thus making it first-order. Furthermore, if gradients are not provided by users, the use of ForwardDiff makes it mandatory to have the function defined in a generic way (accepting any Real number).
Thus, how is the proposed method different from using other first-order methods (such as the ones in Optim.jl or JuliaSmoothOptimizers)? This should be detailed.

"it is obvious that its arguments [...]", avoid the use of "obvious" which is subjective, and develop what is meant here.

"Additional features" paragraph, sentence: "the distributed version is a centralized ..." is a contradiction and should be re-phrased.

This belongs to the JOSS review openjournals/joss-reviews#1385

Remove hidden effect of inner function `LovoFun`

Function LovoFun is a closure with an allocated vector ind which returns the p smallest indices in the LOVO sense. However, if LovoFun is called for two different values of \theta, it will override the indices from the previous calls.

Although this effect is not wrong, it is hidden from the user. We need to make it explicit. This enhancement is necessary to deal with #3 .

Implement circle and line detection problems from OVO paper

Implement some tests from

R. Andreani, G. Cesar, R. M. Cesar-Jr., J. M. Martínez, and P. J. S. Silva, “Efficient curve detection using a {Gauss-Newton} method with applications in agriculture,” in Proc. 1st International Workshop on Computer Vision Applications for Developing Regions in Conjunction with ICCV 2007-CVDR-ICCV07, 2007.

Two runs of `praff` are not equal

When a worker is created, a MersenneTwister object is assigned to this worker, which is used to generate random starting guesses to lmlovo. However, this object is not reset between two runs with different values of p. That means that the order that each worker gets a problem affects the starting point and, as a consequence, the solution. Therefore, two calls of praff might return different solutions.

This is not a problem in the parallel world, but can be fixed if we restart the MersenneTwister object before the solution of each value of p. In order to do this, we have to send SEEDMS integer, rather than the seedMS object to the worker. Then, we create the MersenneTwister before a solution for a given p.

[JOSS] A statement of need on documentation

I think that the documentation could benefit from more information in the overview. Something like the following part of the second paragraph from the Summary section of the paper:

RAFF provides automatic detection of outliers using a voting system. It is an optimization-based package, based on algorithms for Lower Order-Value Optimization (LOVO) which were introduced in [@Andreani2005] and revisited in [@Andreani2009] to fit the user-provided models $\phi$ to experimental data. Recently, a good review can be found in [@Martinez2012]. In order to find a robust adjustment, a voting system is used, which is also responsible for the detection of possible outliers.

Related to openjournals/joss-reviews#1385

[JOSS] Gradient function signature

From the documentation tutorial:

julia> gmodel(x, t, g)=begin
          g[1] = t[1]^2
          g[2] = 1.0
          return g
       end

Following the Julia style guide, the function could have a bang gmodel! to indicate it is
modifying its arguments. Moreover, the mutated argument is preferred placed first, as in gmodel!(g, x, t)

Issue created for openjournals/joss-reviews#1385

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.