shubham142000's picture
Update app.py
1caa55b verified
import streamlit as st
import pandas as pd
# import CosineDistanceClustering
import PU
import bert_embeddings
import oneclass
# Function to recommend papers
def recommend_papers(positive_df, unlabelled_df, model="tfidf"):
pass
# Streamlit app
def main():
st.title("ArXiv Feed Recommendations")
# User input for model selection
model = st.selectbox("Select Model", ["PU","oneclass"])
# Upload CSV files
st.subheader("Upload Positive Labeled CSV")
positive_file = st.file_uploader("Upload CSV", type=['csv'], key="positive")
st.subheader("Upload Unlabelled Data CSV")
unlabelled_file = st.file_uploader("Upload CSV", type=['csv'], key="unlabelled")
if positive_file is not None and unlabelled_file is not None:
# Read CSV files
positive_df = pd.read_csv(positive_file)
unlabelled_df = pd.read_csv(unlabelled_file)
# Show uploaded data
st.subheader("Positive Labeled Data")
st.write(positive_df)
st.subheader("Unlabelled Data")
st.write(unlabelled_df)
# Button to trigger recommendation
if st.button("Recommend"):
# Call recommend_papers function
recommended_indices = recommend_papers(positive_df, unlabelled_df, model.lower())
st.write(recommended_indices)
# Download CSV
st.markdown(get_csv_download_link(recommended_indices), unsafe_allow_html=True)
# Function to generate a download link for CSV
def get_csv_download_link(data):
csv = data.to_csv(index=False)
b64 = base64.b64encode(csv.encode()).decode()
href = f'<a href="data:file/csv;base64,{b64}" download="recommendations.csv">Download CSV</a>'
return href
if __name__ == "__main__":
main()