import streamlit as st import numpy as np import pickle import streamlit.components.v1 as components from sklearn.feature_extraction.text import CountVectorizer from sklearn.model_selection import train_test_split import pandas as pd import nltk import re nltk.download('stopwords') stemmer = nltk.SnowballStemmer("english") from nltk.corpus import stopwords import string stopword=set(stopwords.words('english')) # Separate target and feature column in X and y variable df = pd.read_csv('stress.csv') # X will be the features def clean(text): text = str(text).lower() text = re.sub('\[.*?\]', '', text) text = re.sub('https?://\S+|www\.\S+', '', text) text = re.sub('<.*?>+', '', text) text = re.sub('[%s]' % re.escape(string.punctuation), '', text) text = re.sub('\n', '', text) text = re.sub('\w*\d\w*', '', text) text = [word for word in text.split(' ') if word not in stopword] text=" ".join(text) text = [stemmer.stem(word) for word in text.split(' ')] text=" ".join(text) return text df["text"] = df["text"].apply(clean) X = np.array(df["text"]) # y will be the target variable y = np.array(df["label"]) df["text"] = df["text"].apply(clean) cv = CountVectorizer() # Load the pickled model X = cv.fit_transform(X) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42) # Function for model prediction def model_prediction(features): features = cv.transform([features]).toarray() pickled_model = pickle.load(open('Stress_Detection_BernoulliNB.pkl', 'rb')) Message = str(list(pickled_model.predict(features))) return Message def app_design(): # Add input fields for High, Open, and Low values image = '36.png' # Load image st.image(image, use_column_width=True) st.subheader("Enter the following values:") text= st.text_input("Enter your message") # Create a feature list from the user inputs features = text # add features according to notebook # Make a prediction when the user clicks the "Predict" button if st.button('Predict Stress'): predicted_value = model_prediction(features) if predicted_value == "['Stress']": st.success("Your message contains Stress") elif predicted_value == "['No Stress']": st.success("Your message doesnot contains Stress") def about_hidevs(): components.html("""

🚀 Unlock Your Dream Job with HiDevs Community!

🔍 Seeking the perfect job? HiDevs Community is your gateway to career success in the tech industry. Explore free expert courses, job-seeking support, and career transformation tips.

đź’Ľ We offer an upskill program in Gen AI, Data Science, Machine Learning, and assist startups in adopting Gen AI at minimal development costs.

🆓 Best of all, everything we offer is completely free! We are dedicated to helping society.

Book free of cost 1:1 mentorship on any topic of your choice — topmate

✨ We dedicate over 30 minutes to each applicant’s resume, LinkedIn profile, mock interview, and upskill program. If you’d like our guidance, check out our services here

đź’ˇ Join us now, and turbocharge your career!

Website YouTube Instagram Medium LinkedIn GitHub

""", height=600) def main(): # Set the app title and add your website name and logo st.set_page_config( page_title="Stress Detection", page_icon=":chart_with_upwards_trend:", ) st.title("Welcome to our Stress Detection App!") app_design() st.header("About HiDevs Community") about_hidevs() if __name__ == '__main__': main()