Update app.py
Browse files
app.py
CHANGED
@@ -62,8 +62,8 @@ svm_classifier = read_model("https://github.com/manika-lamba/ml/raw/main/model-t
|
|
62 |
preprocessing = read_tf("https://github.com/manika-lamba/ml/raw/main/tfidf-topics.pkl")
|
63 |
|
64 |
|
65 |
-
# Function to predict the
|
66 |
-
def
|
67 |
# Preprocess the abstract
|
68 |
abstract_preprocessed = preprocessing.transform([abstract])
|
69 |
# Make prediction
|
@@ -93,8 +93,8 @@ if uploaded_file is not None:
|
|
93 |
df = pd.read_csv(uploaded_file, encoding='latin-1')
|
94 |
st.dataframe(df)
|
95 |
|
96 |
-
# Tag the "Abstract" column with the corresponding
|
97 |
-
df['
|
98 |
st.dataframe(df)
|
99 |
|
100 |
# Convert DataFrame to CSV and encode it properly
|
|
|
62 |
preprocessing = read_tf("https://github.com/manika-lamba/ml/raw/main/tfidf-topics.pkl")
|
63 |
|
64 |
|
65 |
+
# Function to predict the topic for a given abstract
|
66 |
+
def predict_topic (abstract):
|
67 |
# Preprocess the abstract
|
68 |
abstract_preprocessed = preprocessing.transform([abstract])
|
69 |
# Make prediction
|
|
|
93 |
df = pd.read_csv(uploaded_file, encoding='latin-1')
|
94 |
st.dataframe(df)
|
95 |
|
96 |
+
# Tag the "Abstract" column with the corresponding topics
|
97 |
+
df['topic'] = df['Abstract'].apply(lambda x: predict_topic(x)[0])
|
98 |
st.dataframe(df)
|
99 |
|
100 |
# Convert DataFrame to CSV and encode it properly
|