Giter Club home page Giter Club logo

Comments (3)

PGimenez avatar PGimenez commented on June 4, 2024 2

The issue is that featureswas not accessible from cluster. Fixed in 55423ff

With the late updates to GF.jl, reactive variables tagged with @in @on can only be read or modified within an @onchange block. For this particular example we just have to first define a regular const features so that that it can be accessed from cluster, and then define @out featuresinside the @handlersblock.

from genieframeworkdemos.

svilupp avatar svilupp commented on June 4, 2024

Incredible! Thank you for the super fast response.

I've been playing with the new API, would it make sense to update the demo as well? I'm happy to open the PR:

using Clustering
import RDatasets: dataset
import DataFrames

using GenieFramework
@genietools

const data = DataFrames.insertcols!(dataset("datasets", "iris"), :Cluster => zeros(Int, 150))
function cluster(no_of_clusters=3, no_of_iterations=10; features)
    feats = Matrix(data[:, [c for c in features]])' |> collect
    result = kmeans(feats, no_of_clusters; maxiter=no_of_iterations)
    data[!, :Cluster] = assignments(result)
end

@app begin
    @in no_of_clusters = 3
    @in no_of_iterations = 10
    @in xfeature = :SepalLength
    @in yfeature = :SepalWidth
    @out features = [:SepalLength, :SepalWidth, :PetalLength, :PetalWidth]
    @out datatable = DataTable()
    @out datatablepagination = DataTablePagination(rows_per_page=50)
    @out irisplot = PlotData[]
    @out clusterplot = PlotData[]
    @out title = "My Iris Dashboard"

    @onchange isready, xfeature, yfeature, no_of_clusters, no_of_iterations begin
        cluster(no_of_clusters, no_of_iterations; features)
        datatable = DataTable(data)
        irisplot = plotdata(data, xfeature, yfeature; groupfeature=:Species)
        clusterplot = plotdata(data, xfeature, yfeature; groupfeature=:Cluster)
    end
end

@page("/", "ui.jl")

Server.isrunning() || Server.up()

You'll notice that I added features as a kwarg to avoid having to define it twice (not sure what would happen if they were defined inconsistently).

from genieframeworkdemos.

PGimenez avatar PGimenez commented on June 4, 2024

@svilupp yes right, but seeing how features isn't optional, I think it should be a regular argument rather than a keyword. Feel free to submit the PR!

from genieframeworkdemos.

Related Issues (8)

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.