Skip to content

Instantly share code, notes, and snippets.

@tc87
Last active March 31, 2020 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tc87/b7c9d5870afed0d7300c6be5f20badfd to your computer and use it in GitHub Desktop.
Save tc87/b7c9d5870afed0d7300c6be5f20badfd to your computer and use it in GitHub Desktop.
st.sidebar.title('Features')
...
# If the user doesn't want to select which features to control, these will be used.
default_control_features = ['Young','Smiling','Male']
if st.sidebar.checkbox('Show advanced options'):
# Randomly initialize feature values.
features = get_random_features(feature_names, seed)
# Let the user pick which features to control with sliders.
control_features = st.sidebar.multiselect(
'Control which features?',
sorted(features), default_control_features)
else:
features = get_random_features(feature_names, seed)
# Don't let the user pick feature values to control.
control_features = default_control_features
# Insert user-controlled values from sliders into the feature vector.
for feature in control_features:
features[feature] = st.sidebar.slider(feature, 0, 100, 50, 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment