Is there a way to detect a change in user selection?

Hey guys;

I have a question regarding detecting a value that has changed.

Here is some background:

My app is going to allow a user to build and train a machine learning model depending on:

  1. The dataset chosen by the user. I built a dropdown menu for the user to choose a dataset. I store the name and the dataset in dcc.Store containers.
  2. The user selected machine learning model

The app will build a either a classification or regression model, depending on the dataset chosen by the user.

Where I’m having trouble is figuring out how to deal with the case where a user might change the dataset.

What I want to happen in that case is to clear any outputs (graphs, data, etc) related to the old dataset and machine learning model currently being displayed.

I’m not sure how to do this, so before i build a class, or find some other way of storing variables globally, I’d like to know if there are any attributes available in dash that I can use to help me in this situation.

Are there any attributes that I can use to detect a change?

Thank you!

Hi @iacisme

I’m not sure if I understand your problem. At startup your want the user to select a data set and based on that, you are loading the rest of the content. At this point you already detected a change, namely the value of the drop down.

Help me understand, why this is different from the second scenario.

hi @iacisme
I’m not sure I fully understand either. When the user chooses a new dataset from the dropdown, why can’t you load the new model that will execute and rerun the outputs (graphs, results, etc.)?

Hey guys. Thanks for responding. Sorry that I wasn’t clear enough.

I solved my issue. I created a dataclass. This way, I can monitor a user change.

When I submit my app project, hopefully it’ll make more sense why I needed to do something like this - and maybe suggest a simpler way.


1 Like