hidevscommunity commited on
Commit
e8cab69
1 Parent(s): 4cf0a6b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +88 -0
app.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pickle
4
+ import streamlit.components.v1 as components
5
+ from sklearn.feature_extraction.text import CountVectorizer
6
+ from sklearn.model_selection import train_test_split
7
+ import pandas as pd
8
+ # Separate target and feature column in X and y variable
9
+ df = pd.read_csv('stress.csv')
10
+ # X will be the features
11
+ X = np.array(df["text"])
12
+
13
+ # y will be the target variable
14
+ y = np.array(df["label"])
15
+ cv = CountVectorizer()
16
+ # Load the pickled model
17
+
18
+ X = cv.fit_transform(X)
19
+ X_train, X_test, y_train, y_test = train_test_split(X, y,
20
+ test_size=0.33,
21
+ random_state=42)
22
+
23
+ # Function for model prediction
24
+ def model_prediction(features):
25
+ features = cv.transform([features]).toarray()
26
+ pickled_model = pickle.load(open('Stress_Detection_BernoulliNB.pkl', 'rb'))
27
+ Message = str(list(pickled_model.predict(features)))
28
+
29
+ return Message
30
+
31
+ def app_design():
32
+ # Add input fields for High, Open, and Low values
33
+ image = '36.png' # Load image
34
+ st.image(image, use_column_width=True)
35
+
36
+ st.subheader("Enter the following values:")
37
+
38
+ text= st.text_input("Enter your message")
39
+ # Create a feature list from the user inputs
40
+ features = text # add features according to notebook
41
+
42
+ # Make a prediction when the user clicks the "Predict" button
43
+ if st.button('Predict Sarcasm'):
44
+ predicted_value = model_prediction(features)
45
+ if predicted_value == "['Stress']":
46
+ st.success("Your message contains Stress")
47
+ elif predicted_value == "['No Stress']":
48
+ st.success("Your message doesnot contains Stress")
49
+
50
+
51
+
52
+ def about_hidevs():
53
+
54
+ components.html("""
55
+ <div>
56
+ <h4>🚀 Unlock Your Dream Job with HiDevs Community!</h4>
57
+ <p class="subtitle">🔍 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.</p>
58
+ <p class="subtitle">💼 We offer an upskill program in <b>Gen AI, Data Science, Machine Learning</b>, and assist startups in adopting <b>Gen AI</b> at minimal development costs.</p>
59
+ <p class="subtitle">🆓 Best of all, everything we offer is <b>completely free</b>! We are dedicated to helping society.</p>
60
+ <p class="subtitle">Book free of cost 1:1 mentorship on any topic of your choice — <a class="link" href="https://topmate.io/deepakchawla1307">topmate</a></p>
61
+ <p class="subtitle">✨ 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 <a class="link" href="https://hidevscommunity.wixsite.com/hidevs">here</a></p>
62
+ <p class="subtitle">💡 Join us now, and turbocharge your career!</p>
63
+ <p class="subtitle"><a class="link" href="https://hidevscommunity.wixsite.com/hidevs" target="__blank">Website</a>
64
+ <a class="link" href="https://www.youtube.com/@HidevsCommunity1307/" target="__blank">YouTube</a>
65
+ <a class="link" href="https://www.instagram.com/hidevs_community/" target="__blank">Instagram</a>
66
+ <a class="link" href="https://medium.com/@hidevscommunity" target="__blank">Medium</a>
67
+ <a class="link" href="https://www.linkedin.com/company/hidevs-community/" target="__blank">LinkedIn</a>
68
+ <a class="link" href="https://github.com/hidevscommunity" target="__blank">GitHub</a></p>
69
+ </div>
70
+ """,
71
+ height=600)
72
+
73
+ def main():
74
+
75
+ # Set the app title and add your website name and logo
76
+ st.set_page_config(
77
+ page_title="Stress Detection",
78
+ page_icon=":chart_with_upwards_trend:",
79
+ )
80
+
81
+ st.title("Welcome to our Stress Detection App!")
82
+
83
+ app_design()
84
+ st.header("About HiDevs Community")
85
+ about_hidevs()
86
+
87
+ if __name__ == '__main__':
88
+ main()