Giter Site home page Giter Site logo

Comments (9)

lucaferranti avatar lucaferranti commented on May 23, 2024

Hi there 👋 ,

thank you for your interest!

Could you clarify what you mean that currently only integers are possible? It should work with floating-point numbers without problems

julia> using FuzzyLogic

julia> mf = TriangularMF(1.0, 2.0, 3.0)
TriangularMF{Float64}(1.0, 2.0, 3.0)

julia> m2 = TriangularMF(1.1, 2.3, 4.5)
TriangularMF{Float64}(1.1, 2.3, 4.5)

julia> mf(1.1)
0.10000000000000009

julia> m2(1.1)
0.0

julia> m2(1.5)
0.3333333333333333

from fuzzylogic.jl.

bananthahally avatar bananthahally commented on May 23, 2024

from fuzzylogic.jl.

lucaferranti avatar lucaferranti commented on May 23, 2024

Hi, yes a screen-shot would be very helpful.

Meanwhile, if I had to try to guess your issue, I would guess you encountered the following

julia> mf = TriangularMF(1, 2.1, 3.1)
ERROR: MethodError: no method matching TriangularMF(::Int64, ::Float64, ::Float64)

Closest candidates are:
  TriangularMF(::T, ::T, ::T) where T<:Real
   @ FuzzyLogic ~/.julia/dev/FuzzyLogic/src/membership_functions.jl:63

the problem here is that for many membership functions it expects all parameters to be of the same type, so either all integers or all floats. In that case, you would have to type

mf = TriangularMF(1.0, 2.1, 3.1)

this philosophy (all of the same type) is common in statically typed languages. There would be three possible fixes of this

  1. Leave it as is, and document better the inputs should either be all floats or all integer $^*$
  2. Support automatically promoting inputs, so that TrinagularMF(1, 2.1 3.1) would automatically become TriangularMF(1.0, 2.1, 3.1)
  3. Parametrize each membership function by the type of each parameter.

I can think of small drawbacks of each solution, so none is perfect.

$^*$ For completeness, there is an important exception where mixed types are supported, that is

julia> GeneralizedBellMF(1.0, 2, 3.0)
GeneralizedBellMF{Float64, Int64}(1.0, 2, 3.0)

The reason for this is the following: for other membership functions (triangular, gaussian, etc.) supporting mixed types is just a small short-cut, since one can always type TriangularMF(1.0, 2.1, 3.0) without any drawback. Indeed, it's very likely that the integer will be promoted to float at the first operation of the inference pipeline.

In the case of the Generalized Bell MF, however, the second parameter is significantly different from the others. The first and third are, respectively, a variance and a mean, while the second one is an exponent. It's much more reasonable to expect an exponent to be integer and also float ^ integer is much faster than float ^ float, which is why for the generalized bell membership function I chose from the beginning to support different types

from fuzzylogic.jl.

lucaferranti avatar lucaferranti commented on May 23, 2024

(the close issue was a misclick, reopened ;) )

from fuzzylogic.jl.

bananthahally avatar bananthahally commented on May 23, 2024

from fuzzylogic.jl.

lucaferranti avatar lucaferranti commented on May 23, 2024

I don't see your attached screenshots unfortunately.

For now you should be able to overcome the problem by typing the integer as float (e.g. 1.0 instead of 1), does this get you unblocked?

I'll try to update the user interface to be more friendly and accept mixed inputs in the upcoming days.

from fuzzylogic.jl.

bananthahally avatar bananthahally commented on May 23, 2024

from fuzzylogic.jl.

lucaferranti avatar lucaferranti commented on May 23, 2024

In an upcoming release, one will be able to automatically create membership functions with mixed precisions, like

GaussianMF(1, 2.0)
TriangularMF(2, 4.0, 5//1)

and the constructor will automatically handle the promotion for all membership functions. This however relies on new features of Julia 1.10, so will have to wait for it to be released. I will notify on this issue, once this is implemented.

Meanwhile, you can manually convert those to floats, e.g. writing GaussianMF(1.0, 2.5) instead of GaussianMF(1, 2.5)

from fuzzylogic.jl.

bananthahally avatar bananthahally commented on May 23, 2024

from fuzzylogic.jl.

Related Issues (4)

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.