hidevscommunity commited on
Commit
c1e3118
1 Parent(s): e821015

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +94 -0
app.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ import nltk
9
+ import re
10
+ from sklearn.naive_bayes import BernoulliNB
11
+ from collections import Counter
12
+ from nltk.corpus import stopwords
13
+
14
+ df = pd.read_csv('spam_new.csv',encoding= 'latin-1')
15
+
16
+ # X will be the features
17
+ X = np.array(df["message"])
18
+
19
+ # y will be the target variable
20
+ y = np.array(df["class"])
21
+ cv = CountVectorizer()
22
+
23
+ X = cv.fit_transform(X)
24
+ X_train, X_test, y_train, y_test = train_test_split(X, y,
25
+ test_size=0.33,
26
+ random_state=42)
27
+
28
+ model = BernoulliNB()
29
+ model.fit(X_train, y_train)
30
+ # Function for model prediction
31
+ def model_prediction(features):
32
+ features = cv.transform([features]).toarray()
33
+ Message = str(list(model.predict(features)))
34
+
35
+ return Message
36
+
37
+ def app_design():
38
+
39
+ image = '58.png' # Load image
40
+ st.image(image, use_column_width=True)
41
+
42
+ st.subheader("Enter the following values:")
43
+
44
+ text= st.text_input("Enter your text")
45
+ # Create a feature list from the user inputs
46
+ features = text # add features according to notebook
47
+
48
+ # Make a prediction when the user clicks the "Predict" button
49
+ if st.button('Predict Spam'):
50
+ predicted_value = model_prediction(features)
51
+ if predicted_value == "['ham']":
52
+ st.success("Your comment is not spam")
53
+ elif predicted_value == "['spam']":
54
+ st.success("Your Comment is spam")
55
+
56
+
57
+
58
+ def about_hidevs():
59
+
60
+ components.html("""
61
+ <div>
62
+ <h4>🚀 Unlock Your Dream Job with HiDevs Community!</h4>
63
+ <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>
64
+ <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>
65
+ <p class="subtitle">🆓 Best of all, everything we offer is <b>completely free</b>! We are dedicated to helping society.</p>
66
+ <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>
67
+ <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>
68
+ <p class="subtitle">💡 Join us now, and turbocharge your career!</p>
69
+ <p class="subtitle"><a class="link" href="https://hidevscommunity.wixsite.com/hidevs" target="__blank">Website</a>
70
+ <a class="link" href="https://www.youtube.com/@HidevsCommunity1307/" target="__blank">YouTube</a>
71
+ <a class="link" href="https://www.instagram.com/hidevs_community/" target="__blank">Instagram</a>
72
+ <a class="link" href="https://medium.com/@hidevscommunity" target="__blank">Medium</a>
73
+ <a class="link" href="https://www.linkedin.com/company/hidevs-community/" target="__blank">LinkedIn</a>
74
+ <a class="link" href="https://github.com/hidevscommunity" target="__blank">GitHub</a></p>
75
+ </div>
76
+ """,
77
+ height=600)
78
+
79
+ def main():
80
+
81
+ # Set the app title and add your website name and logo
82
+ st.set_page_config(
83
+ page_title="Spam Detection",
84
+ page_icon=":chart_with_upwards_trend:",
85
+ )
86
+
87
+ st.title("Welcome to our Spam Detection App!")
88
+
89
+ app_design()
90
+ st.header("About HiDevs Community")
91
+ about_hidevs()
92
+
93
+ if __name__ == '__main__':
94
+ main()