Comments (3)
The issue is that features
was 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 features
inside the @handlers
block.
from genieframeworkdemos.
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.
@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)
- [SearchLight] - Can't edit primary key before saving HOT 2
- StipplePlotlyExamples: Why project.toml contains url of packages of `aryan` user? HOT 1
- Database demo stuck in a loop at 100% CPU usage HOT 1
- Click events on map demo
- Re-attach to running process, or kill process on page close HOT 7
- unconnected clients lead to high CPU load
- CSVAnalysis is broken HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from genieframeworkdemos.