|
|
import pickle |
|
|
import streamlit as st |
|
|
|
|
|
|
|
|
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]) |
|
|
|
|
|
|
|
|
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.") |
|
|
|