GithubHelp home page GithubHelp logo

fuzzy.jl's Introduction

Gitlab: phelipe GitHub phelipe

Hi there! πŸ‘‹πŸ½

I would say that I am a developer and researcher. I solve problems using math, logic, and code.

Personal stuff:

  • πŸ˜„ Pronouns: He/His
  • πŸ§‘πŸΎβ€πŸ’» I am a full stack software engineer, having some experience in devops and mobile development
  • πŸ”­ I’m currently working as a senior software engineer
  • πŸ‘― I’m looking to collaborate on projects written in Rust
  • πŸ‘¨πŸΎβ€πŸŽ“ I have a Ph.D. in Teleinformatics Engineering, my research topics are robotics, control, optimization, and machine learning.
  • πŸ“– I'm interested in robotics, low level programing, compilers, IA and math.

Where to find me πŸ“¬:

Linkedin: phelipe Lattes: phelipe

Personal projects

I am currently working on a flutter mobile app to raise funds for stray animals

Current Stack πŸ§‘πŸΎβ€πŸ’»

  • Programing: Rust, GO, javascript, Dart, Lua
  • Server Technologies: GraphQL, gRPC
  • Front-end: React, HTML, CSS
  • Mobile: Flutter, React Native
  • Infra: Docker, Git, CI (Github-Actions, Gitlab CI)
  • Cloud: AWS

fuzzy.jl's People

Contributors

phelipe avatar sov-trotter avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

fuzzy.jl's Issues

change indmax to argmax

@phelipe in the defuzz function there is a call to indmax. In the version of Julia I am using (1.6.2) it gives me UndefVarError: indmax not defined. I am new to Julia, but I think this ought to be changed to argmax

NaN result when values supplied ar outside of trapezoidMF

@phelipe thank you for your all your work on this package. Taking the example of the tipping problem, when I supply input values which are outside of the range of the MF I get a NaN in the FIS evaluation. Is this expected or am I doing something wrong?
I simplified the tipping problem with 1 MF and 1 rule below.

service = Dict( "poor"      => TrapezoidalMF(0.0, 0.0, 2.0, 4.0), 
                "good"      => TriangularMF(3., 5., 7.))

inputs = [service]

tip  = Dict("cheap"     => TrapezoidalMF(10., 10., 20., 30.),
            "average"   => TriangularMF(20., 30., 40.), 
            "generous"  => TrapezoidalMF(30., 40, 50., 50.))

rule1 = Rule(["poor"], "cheap")
rules = [rule1]

fis_tips = FISMamdani(inputs, tip, rules)

The MF for service looks as follows:

First I tried to supply a value comprised within the "poor" trapezoid

in_vals = [2.5]
println(eval_fis(fis_tips, in_vals))

result = 16.25, which indeed matches with the "cheap" tip
However when I supply a value at the edge of the "poor" trapezoid or beyond I get NaN

in_vals = [4.]
println(eval_fis(fis_tips, in_vals))

result = NaN

in_vals = [5.]
println(eval_fis(fis_tips, in_vals))

result = NaN

Docs

provide better documentation

Ploting membership functions

Dear Phelipe,
Sorry to bring back the question of plotting. But, I just wanted to give a small feedback.
First, I realise that it was simpler to use Fuzzy eval than trying to work with the MF control points:

# Membership functions 
mf_tri = TriangularMF(1, 2, 3)
mf_gauss = GaussianMF(5, 2)

# Plot MF (CairoMakie)
x = range(0, 10, length=1000)
fig = Figure()
ax = Axis(fig[1,1])
lines!(ax, x, map(x->Fuzzy.eval(mf_gauss, x), x), color=:red)
lines!(ax, x, map(x->Fuzzy.eval(mf_tri, x), x), color=:green)
fig

plot_8

My only problem is related to the fact that the MF are stored as dictionnary.

# Temperatures
temp = Dict("cold" => TrapezoidalMF(-12., -12., 0., 1.), 
            "cool" => TrapezoidalMF(0., 1., 10., 15.),
            "warm" => TrapezoidalMF(10., 15., 18., 23.),
            "hot"  => TrapezoidalMF(18., 23., 30., 30.))

Thus, when creating a plot function that will take membership functions (plotMF(MF; colors, label...)) , it is not possible to pass parameters in the shape of an array, e.g. colors=["#4575b4", "#91bfdb", "#999999", "#ef8a62"] as the order of the MF is unpredictible.
So I wondered if it would be possible to use an ordered dict such OrderedCollections.jl ?
Or to directly add some complementary parameter during the definition of the membership function dict:

temp = Dict("cold" => (mf=TrapezoidalMF(-12., -12., 0., 1.), label="Cold", color="#4575b4"), 
            "cool" => (mf=TrapezoidalMF(0., 1., 10., 15.), label="Cool", color="#91bfdb"),
            "warm" => (mf=TrapezoidalMF(10., 15., 18., 23.), label="Warm", color="#999999"),
            "hot"  => (mf=TrapezoidalMF(18., 23., 30., 30.), label="Hot", color="#ef8a62"))

Thanks a lot.

Ploting membership functions

Thanks a lot for your work.
I was wondering if it could be possible to add a plotting method in Fuzzy package?
I did a small function based on the Makie package:

using CairoMakie

# Temperatures
temp = Dict("cold" => TrapezoidalMF(-11., -2., 0., 5.), 
            "good" => TrapezoidalMF(2., 5., 9., 12.),
            "warm" => TrapezoidalMF(9., 12., 30., 30.))

# Plotting function
function PlotMF(MF, xlabel="Values")
   
    # Figure setup
    fig = Figure(resolution = (600, 400), font = "sans")

    # Axis setup
    ax = Axis(fig[1,1], 
            xlabel = xlabel, ylabel = "Membership grade", 
            xgridstyle=:dash, ygridstyle=:dash, 
            yticks = LinearTicks(5), 
            rightspinevisible = false, topspinevisible = false)
    ylims!(0.,1.2)

    # Loop over MF
    for (key, value) in MF
        if typeof(value) === TrapezoidalMF
            x = [value.l_bottom_vertex, value.l_top_vertex, 
                value.r_top_vertex, value.r_bottom_vertex]
            y = [0, 1, 1, 0]
        elseif typeof(value) === TriangularMF
            x = [value.l_vertex, value.center, value.r_vertex]
            y = [0, 1, 0]
        end
        # Remove last element if the two last values are identical
        if x[end] == x[end - 1]
            pop!(x)
            pop!(y)
        end
        # Add lines
        lines!(ax, x, y)
        # Add MF name
        annotations!(ax, uppercasefirst(key), 
                    position = ((x[1] + x[end]) / 2, 1.01), 
                    align = [:center, :bottom])
    end
    return fig
end

# Test
PlotMF(temp, "Temperature (Β°C)")

Capture d’écran 2021-07-22 154939

Would it be relevant ?

Target only a subset of input in rules

I am currently moving from R to Julia. I am trying to test the Fuzzy.jl package and I have a small issue with the rule definition.
Is it possible to target only a subset of input in a rule?
In the following example, I a trying to reproduce the classical example of restaurant tip :

Rules:

  • IF the service was excellent or the food quality was delicious, THEN the tip will be generous.
  • IF the service was good, THEN the tip will be average.
  • IF the service was poor and the food quality was poor THEN the tip will be cheap.
service = Dict( "poor"      => TriangularMF(-1, 0, 1.5), 
                "good"      => TriangularMF(3.5, 5, 6.5),
                "excellent" => TriangularMF(8.5, 10, 11.5))

food = Dict("rancid"    => TrapezoidalMF(-2, 0, 2, 4),
            "delicious" => TrapezoidalMF(7, 9, 11, 13))

inputs = [service, food]

tip  = Dict("cheap"     => TriangularMF(2.5, 5, 7.5),
            "average"   => TriangularMF(10, 12.5, 15), 
            "generous"  => TriangularMF(17.5, 20, 22.5))

rule1 = Rule(["poor", "rancid"], "cheap", "MAX")

# How to not include food input ?
rule2 = Rule(["good", ""], "average")

rule3 = Rule(["excellent", "delicious"], "generous", "MAX")
rules = [rule1, rule2, rule3]

fis_tips = FISMamdani(inputs, tip, rules)

So is there a way to avoid including food input for the rule2 ?
Thanks

Changes in sintax

Implement a named tuple in place of the input vector (close to the R Sets package) :

# Convert named tuple to array
inputs_names = [:service, :food]
r(val) = [haskey(val, i) ? getindex(val, i) : "" for i in inputs_names]

rule1 = Rule(r((service="poor", food = "rancid")), "cheap", "MAX")
rule2 = Rule(r((service="good",)), "average")
rule3 = Rule(r((service="excellent", food = "delicious")), "generous", "MAX")
rules = [rule1, rule2, rule3]

I don't know if this syntax could be relevant for others?

Originally posted by @pierrethiriet in #12 (comment)

ANFIS

This is more of a feature request than an issue, but a Julia implementation of ANFIS (paper attached) could be a worthwhile application of this package. I'm happy to help work on it if there is interest.
anfis.pdf

update code to 1.6

  • update code to 1.6
  • create github actions to run tests
  • update code to julia repo

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

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.