Spaces:
Runtime error
Runtime error
File size: 852 Bytes
f7bdf42 ad19e4d b8e812e f7bdf42 b8e812e f7bdf42 |
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 |
import streamlit as st
import pickle
import numpy as np
import pandas as pd
import nltk
import re
from nltk.corpus import stopwords
from nltk.stem.porter import PorterStemmer
from nltk.stem import WordNetLemmatizer
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
model = pickle.load(open('spam_model.sav','rb'))
tf = pickle.load(open('vectorizer.pkl','rb'))
st.title('Spam classifier')
input = st.text_area('Enter sms here')
ps = PorterStemmer()
review = re.sub('[^a-zA-Z]', ' ', input) # to remove punctuation
review = review.lower()
review = review.split()
review = [ps.stem(word) for word in review if not word in stopwords.words('english')]
review = ' '.join(review)
X = tf.fit_transform(review).toarray()
if input:
output = model.predict(X)
st.json(output)
|