How to use the streamlit.header function in streamlit

To help you get started, we’ve selected a few streamlit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MarcSkovMadsen / awesome-streamlit / gallery / nba_roster_turnover / roster_turnover.py View on Github external
"Explore NBA roster turnover since\nthe 2003-04 season. **Roster turnover** is \ndefined as the "
        "sum of the difference\nin total minutes played by each player\non a given team between any two "
        "years."
    )
    st.sidebar.table(
        pd.DataFrame.from_dict(
            wins_turnover_corr, orient="index", columns=["correlation"]
        ).round(2)
    )

    # Data frame for the plot
    fig = get_turnover_vs_wins_plot(roster_turnover, year, teams_colorscale)
    st.plotly_chart(fig, width=1080, height=600)

    # Show the roster DataFrame
    st.header("Minutes Played Breakdown by Team")
    selected_team = st.selectbox("Select a team", teams)
    st.dataframe(
        roster_turnover_pivot(player_minutes, team=selected_team, year=year), width=1080
    )
    st.text("* The numbers in the table are minutes played")
github awarebayes / RecNN / examples / streamlit_demo.py View on Github external
std = D.std(axis=1).mean()
            return I, mean, std

        def get_action(model_name, action_id):
            gen_action = models[model_name].forward(state)
            gen_action = gen_action[action_id].detach().cpu().numpy()
            return gen_action

        st.subheader('(Optional) Select the state are getting the recommendations for')

        action_id = np.random.randint(0, state.size(0), 1)[0]
        action_id_manual = st.checkbox('Manually set state index')
        if action_id_manual:
            action_id = st.slider("Choose state index:", min_value=0, max_value=state.size(0))

        st.header('Metric')
        dist = st.selectbox('Select distance', ['L2', 'IP', 'COS'])

        ddpg_action = get_action('ddpg', action_id).reshape(1, -1)
        td3_action  = get_action('td3', action_id).reshape(1, -1)

        topk = st.slider("TOP K items to recommend:", min_value=1, max_value=30, value=10)

        ddpg_I, ddpg_mean, ddpg_std = get_err(ddpg_action, dist, topk, euc=True)
        td3_I, td3_mean, td3_std = get_err(td3_action, dist, topk, euc=True)

        # Mean Err
        st.subheader('Mean error')
        st.markdown("""
        How close are we to the actual movie embedding? 
        
        The closer the better, although higher error may
github streamlit / streamlit / examples / images.py View on Github external
image = Image.open(io.BytesIO(si.get_images()["image.png"]))
data.append((image, "PIL Image.open('image.png')"))
image = Image.open(io.BytesIO(si.get_images()["image.jpeg"]))
data.append((image, "PIL Image.open('image.jpeg')"))
data.append(
    (Image.new("RGB", (200, 200), color="red"), "Image.new('RGB', color='red')")
)

images = []
captions = []
for i, c in data:
    images.append(i)
    captions.append(c)
st.image(images, caption=captions, format="png")

st.header("Bytes IO Image")
image = io.BytesIO(si.get_images()["image.png"])
st.image(image, caption=str(type(image)), format="png")

st.header("From a file")
st.image("/tmp/image.png", caption="/tmp/image.png", format="png")

st.header("From open")
st.image(open("/tmp/image.png", "rb").read(), caption="from read", format="png")

st.header("Numpy arrays")
image = Image.open(io.BytesIO(si.get_images()["image.png"]))
rgba = np.array(image)

data = []
# Full RGBA image
data.append((rgba, str(rgba.shape)))
github streamlit / streamlit / examples / reference.py View on Github external
]

    df = pd.DataFrame(
        np.random.randn(8, 4),
        index=arrays,
        columns=[
            datetime(2012, 5, 1),
            datetime(2012, 5, 2),
            datetime(2012, 5, 3),
            datetime(2012, 5, 4),
        ],
    )

    st.write(df, "...and its transpose:", df.T)

st.header("Visualizing data as charts")

st.write(
    "Charts are just as simple, but they require us to introduce some "
    "special functions first."
)

st.write("So assuming `data_frame` has been defined as...")

with st.echo():
    chart_data = pd.DataFrame(
        np.random.randn(20, 5), columns=["pv", "uv", "a", "b", "c"]
    )

st.write("...you can easily draw the charts below:")

st.subheader("Example of line chart")
github ICLRandD / Blackstone / black_lit.py View on Github external
vector_size = nlp.meta.get("vectors", {}).get("width", 0)
if vector_size:
    st.header("Vectors & Similarity")
    st.code(nlp.meta["vectors"])
    text1 = st.text_input("Text or word 1", "apple")
    text2 = st.text_input("Text or word 2", "orange")
    doc1 = process_text(spacy_model, text1)
    doc2 = process_text(spacy_model, text2)
    similarity = doc1.similarity(doc2)
    if similarity > 0.5:
        st.success(similarity)
    else:
        st.error(similarity)

st.header("Token attributes")

if st.button("Show token attributes"):
    attrs = [
        "idx",
        "text",
        "lemma_",
        "pos_",
        "tag_",
        "dep_",
        "head",
        "ent_type_",
        "ent_iob_",
        "shape_",
        "is_alpha",
        "is_ascii",
        "is_digit",
github explosion / spaCy / examples / streamlit_spacy.py View on Github external
Process text with [spaCy](https://spacy.io) models and visualize named entities,
dependencies and more. Uses spaCy's built-in
[displaCy](http://spacy.io/usage/visualizers) visualizer under the hood.
"""
)

spacy_model = st.sidebar.selectbox("Model name", SPACY_MODEL_NAMES)
model_load_state = st.info(f"Loading model '{spacy_model}'...")
nlp = load_model(spacy_model)
model_load_state.empty()

text = st.text_area("Text to analyze", DEFAULT_TEXT)
doc = process_text(spacy_model, text)

if "parser" in nlp.pipe_names:
    st.header("Dependency Parse & Part-of-speech tags")
    st.sidebar.header("Dependency Parse")
    split_sents = st.sidebar.checkbox("Split sentences", value=True)
    collapse_punct = st.sidebar.checkbox("Collapse punctuation", value=True)
    collapse_phrases = st.sidebar.checkbox("Collapse phrases")
    compact = st.sidebar.checkbox("Compact mode")
    options = {
        "collapse_punct": collapse_punct,
        "collapse_phrases": collapse_phrases,
        "compact": compact,
    }
    docs = [span.as_doc() for span in doc.sents] if split_sents else [doc]
    for sent in docs:
        html = displacy.render(sent, options=options)
        # Double newlines seem to mess with the rendering
        html = html.replace("\n\n", "\n")
        if split_sents and len(docs) > 1:
github streamlit / streamlit / examples / plotly_example.py View on Github external
###

st.header("Matplotlib chart in Plotly")

import matplotlib.pyplot as plt

f = plt.figure()
arr = np.random.normal(1, 1, size=100)
plt.hist(arr, bins=20)

st.plotly_chart(f)


###

st.header("3D plot")

x, y, z = np.random.multivariate_normal(np.array([0, 0, 0]), np.eye(3), 400).transpose()

trace1 = go.Scatter3d(
    x=x,
    y=y,
    z=z,
    mode="markers",
    marker=dict(
        size=12,
        color=z,  # set color to an array/list of desired values
        colorscale="Viridis",  # choose a colorscale
        opacity=0.8,
    ),
)
github ICLRandD / Blackstone / black_stream.py View on Github external
html = html.replace("\n", " ")
    st.write(HTML_WRAPPER.format(html), unsafe_allow_html=True)
    attrs = ["text", "label_", "start", "end", "start_char", "end_char"]
    if "entity_linker" in nlp.pipe_names:
        attrs.append("kb_id_")
    data = [
        [str(getattr(ent, attr)) for attr in attrs]
        for ent in doc.ents
        if ent.label_ in labels
    ]
    df = pd.DataFrame(data, columns=attrs)
    st.dataframe(df)


if "textcat" in nlp.pipe_names:
    st.header("Text Classification")
    st.markdown(f"> {text}")
    df = pd.DataFrame(doc.cats.items(), columns=("Label", "Score"))
    st.dataframe(df)


vector_size = nlp.meta.get("vectors", {}).get("width", 0)
if vector_size:
    st.header("Vectors & Similarity")
    st.code(nlp.meta["vectors"])
    text1 = st.text_input("Text or word 1", "libel")
    text2 = st.text_input("Text or word 2", "slander")
    doc1 = process_text(spacy_model, text1)
    doc2 = process_text(spacy_model, text2)
    similarity = doc1.similarity(doc2)
    if similarity > 0.5:
        st.success(similarity)
github explosion / spaCy / examples / streamlit_spacy.py View on Github external
"head",
        "ent_type_",
        "ent_iob_",
        "shape_",
        "is_alpha",
        "is_ascii",
        "is_digit",
        "is_punct",
        "like_num",
    ]
    data = [[str(getattr(token, attr)) for attr in attrs] for token in doc]
    df = pd.DataFrame(data, columns=attrs)
    st.dataframe(df)


st.header("JSON Doc")
if st.button("Show JSON Doc"):
    st.json(doc.to_json())

st.header("JSON model meta")
if st.button("Show JSON model meta"):
    st.json(nlp.meta)
github leenamurgai / debias-ml / source / analysis_model.py View on Github external
from utilities import DataParams
from utilities import ProcessedDataParams
from oversample import Oversampler
from model import nn_classifier
from train_test import make_training_and_test_sets
from train_test import normalise
from train_test import make_results_df
from train_test import train_predict
from plot_results import probability_density_functions

################################################################################
################################################################################
################################################################################

st.title('debias-ml: model testing')
st.header('1 Processed Data Ingestion''')
st.write('')

params = DataParams()
filename = params.filename
sensitive_features  = params.sensitive_features
target_feature = params.target_feature
pos_target  = params.pos_target
n_train = params.n_train

data_df = pd.read_csv('../data/processed/'+filename)
st.write('Data read successfully!')

params = ProcessedDataParams()
bias_cols = params.bias_cols
target_col = params.target_col
feature_cols = list(data_df.columns)