Skip to content

Commit

Permalink
add basic streamlit mock
Browse files Browse the repository at this point in the history
to do = move input to pd.df
  • Loading branch information
soodoku committed Apr 16, 2023
1 parent c7f9409 commit 33756fa
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
11 changes: 11 additions & 0 deletions streamlit/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Cython>=0.28.5
numpy>=1.22.0
scikit-learn==0.22.2.post1
pandas>=1.3.0
joblib
tqdm
nltk
tensorflow>=2.7.2,<3
setuptools>=65.5.1
pranaam
streamlit
40 changes: 40 additions & 0 deletions streamlit/streamlit_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import streamlit as st
import pandas as pd
from pranaam import pranaam
import base64

def download_file(df):
csv = df.to_csv(index=False)
b64 = base64.b64encode(csv.encode()).decode()
href = f'<a href="data:file/csv;base64,{b64}" download="results.csv">Download results</a>'
st.markdown(href, unsafe_allow_html=True)

def app():
# Set app title
st.title("pranaam: predict religion based on name")

# Generic info.
st.write('Pranaam uses the Bihar Land Records data, plot-level land records, to build machine learning models that predict religion and caste from the name.')
st.write('[Github](https://github.com/appeler/pranaam)')

# Upload CSV file
uploaded_file = st.file_uploader("Choose a CSV file", type=["csv"])

# Load data
if uploaded_file is not None:
df = pd.read_csv(uploaded_file)
st.write("Data loaded successfully!")
else:
st.stop()

lname_col = st.selectbox("Select column with last name", df.columns)
lang = st.selectbox("Select the language", ["eng", "hin"])
function = sidebar_options[selected_function]
if st.button('Run'):
transformed_df = pranaam.pred_rel(df, namecol=lname_col, lang = lang)
st.dataframe(transformed_df)
download_file(transformed_df)

# Run the app
if __name__ == "__main__":
app()

0 comments on commit 33756fa

Please sign in to comment.