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.")