Streamlit selectbox use Array list

Hello people,

I am developing a streamlit dashboard and I have different array lists that look like this

import numpy as np
import streamlit as st

svm_pred = np.array([1.50, 2.51, 3.34, 4.123, 5.22])
linear_pred = np.array([0.31, 2.11, 0.33, 4.0, 5])
bayesian_pred = np.array([1, 2.56, 3.89, 4, 5])

Now, I am using this arrays to plot different graphs and due to that I want the arrays to be selected from a dropdown list where when selected, it will automatically plot the graph.

Here is how I created my dropdown list:

   preds = {
        'SVM Predictions': svm_pred,
        'Polynomial Regression Predictions': linear_pred,
        'Bayesian Ridge Regression Predictions': bayesian_pred,
    }

 model_predict = st.sidebar.selectbox(
        "Select the model to predict : ", list(preds.keys()))

On plotting code, I call the model_predict selectbox to plot the chart,otherwise the chart will be empty.


    plot_predictions(adjusted_dates, world_cases,
                     model_predict, 'SVM Predictions', 'purple')
    plot_predictions(adjusted_dates, world_cases, model_predict,
                     'Polynomial Regression Predictions', 'orange')

    plot_predictions(adjusted_dates, world_cases, model_predict,
                     'Bayesian Ridge Regression Predictions', 'green')

When I run the code, I get this error

ValueError: Illegal format string "Polynomial Regression Predictions"; two marker symbols

What am I missing and how can I resolve this

What is your plot_predictions function definition? Iā€™m not clear since you are passing in both the output from your selector (model_predict) along with another hard-coded selection (one of the three choices in each of the three calls to your plot function).

Are you converting back to the pointer to your lists within the plot_predictions function? If not, you would need to give it (for example) preds['SVM Predictions'] instead of the string 'SVM Predictions'.