Update app.py
Browse files42 unmodified lines43444546474849505152535455565758596061626364656667686970717242 unmodified linestab1, tab2, tab3 = st.tabs(["π Load Data", "π Tagged ETDs", "π Download Data"])with tab1:#===load data===if uploaded_file is not None:df = pd.read_csv(uploaded_file, encoding='latin-1')st.dataframe(df)with tab2:#===tagged ETDs===# Tag the "Abstract" column with the corresponding categoriesdf['category'] = df['Abstract'].apply(predict_category)st.dataframe(df)# Function to predict the category for a given abstractdef predict_category(abstract):# Preprocess the abstractabstract_preprocessed = preprocessing.transform([abstract])# Make predictionprediction = svm_classifier.predict(abstract_preprocessed)return predictionwith tab3:#===download result===# Create a download buttonif st.sidebar.button("Download"):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 csv file</a>'st.markdown(href, unsafe_allow_html=True)42 unmodified lines43444546474849505152535455565758596061626364656667686970717242 unmodified linestab1, tab2, tab3 = st.tabs(["π Load Data", "π Tagged ETDs", "π Download Data"])with tab1:#===load data===if uploaded_file is not None:df = pd.read_csv(uploaded_file, encoding='latin-1')st.dataframe(df)with tab2:#===tagged ETDs===# Tag the "Abstract" column with the corresponding categoriesdf['category'] = df['Abstract'].apply(predict_category)st.dataframe(df)# Function to predict the category for a given abstractdef predict_category(abstract):# Preprocess the abstractabstract_preprocessed = preprocessing.transform([abstract])# Make predictionprediction = svm_classifier.predict(abstract_preprocessed)return predictionwith tab3:#===download result===# Create a download buttonif st.sidebar.button("Download"):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 csv file</a>'st.markdown(href, unsafe_allow_html=True)
app.py+22-22