File size: 1,208 Bytes
1889170
 
 
a5fd2e9
9b1e220
726d783
1889170
9b1e220
726d783
1889170
9b1e220
726d783
1889170
 
7bd1bd8
1889170
 
 
 
7bd1bd8
 
 
726d783
 
7bd1bd8
 
 
726d783
5354f7b
726d783
1889170
7bd1bd8
 
 
726d783
7bd1bd8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pickle
import streamlit as st

# Load saved model, vectorizer, and binarizer
with open("vectorizer (3).pkl", "rb") as f:
    vectorizer = pickle.load(f)

with open("model (6).pkl", "rb") as f:
    model = pickle.load(f)

with open("binarizer (3).pkl", "rb") as f:
    mlb = pickle.load(f)

st.title("πŸ”– Stack Overflow Tags Predictor")
st.markdown("Enter a question title and description. Tags will be predicted automatically.")

title = st.text_input("πŸ“Œ Enter Question Title")
description = st.text_area("πŸ“ Enter Question Description", height=150)

def predict_tags(title, description):
    if not title.strip() or not description.strip():
        return []
    input_text = title + " " + description
    input_vector = vectorizer.transform([input_text])
    
    # Predict tags using the model's internal default threshold
    predicted_binary = model.predict(input_vector)
    tags = mlb.inverse_transform(predicted_binary)
    return tags[0] if tags else []

if st.button("Predict Tags"):
    tags = predict_tags(title, description)
    if tags:
        st.success("βœ… Predicted Tags: " + ", ".join(tags))
    else:
        st.info("ℹ️ No tags predicted. Try refining your question.")