Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pickle
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import streamlit as st
|
| 4 |
+
|
| 5 |
+
# Load the trained model
|
| 6 |
+
model = pickle.load(open("data.pkl", "rb"))
|
| 7 |
+
|
| 8 |
+
# Define a function to predict user data
|
| 9 |
+
def predict_user_data(user_data):
|
| 10 |
+
user_df = pd.DataFrame(user_data, index=[0])
|
| 11 |
+
user_df = extract_features(user_df) # Assuming the extract_features function is defined elsewhere in your code
|
| 12 |
+
prediction = model.predict(user_df)[0]
|
| 13 |
+
return prediction
|
| 14 |
+
|
| 15 |
+
# Streamlit app layout
|
| 16 |
+
st.title("Fake or Genuine User Classifier")
|
| 17 |
+
|
| 18 |
+
# Get user input
|
| 19 |
+
user_statuses_count = st.number_input("Statuses Count", min_value=0)
|
| 20 |
+
user_followers_count = st.number_input("Followers Count", min_value=0)
|
| 21 |
+
user_friends_count = st.number_input("Friends Count", min_value=0)
|
| 22 |
+
user_favourites_count = st.number_input("Favourites Count", min_value=0)
|
| 23 |
+
user_listed_count = st.number_input("Listed Count", min_value=0)
|
| 24 |
+
user_name = st.text_input("Name")
|
| 25 |
+
|
| 26 |
+
# Get user input as a dictionary
|
| 27 |
+
user_data = {
|
| 28 |
+
"statuses_count": user_statuses_count,
|
| 29 |
+
"followers_count": user_followers_count,
|
| 30 |
+
"friends_count": user_friends_count,
|
| 31 |
+
"favourites_count": user_favourites_count,
|
| 32 |
+
"listed_count": user_listed_count,
|
| 33 |
+
"name": user_name,
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
# Predict if the user clicks the button
|
| 37 |
+
if st.button("Classify User"):
|
| 38 |
+
prediction = predict_user_data(user_data)
|
| 39 |
+
if prediction == 1:
|
| 40 |
+
st.success("The user is likely Genuine.")
|
| 41 |
+
else:
|
| 42 |
+
st.warning("The user is likely Fake.")
|
| 43 |
+
|