|
import pandas as pd |
|
import pickle |
|
import streamlit as st |
|
|
|
def load_model(): |
|
with open('data.pkl', 'rb') as file: |
|
model = pickle.load(file) |
|
return model |
|
|
|
|
|
def predict_user_profile(inputs): |
|
|
|
|
|
|
|
|
|
df = pd.DataFrame.from_dict([inputs]) |
|
|
|
|
|
feature_columns_to_use = ['statuses_count', 'followers_count', 'friends_count', |
|
'favourites_count','listed_count'] |
|
df_features = df[feature_columns_to_use] |
|
|
|
|
|
model = load_model() |
|
|
|
|
|
prediction = model.predict(df_features) |
|
|
|
|
|
if prediction > 0.5: |
|
return "Genuine" |
|
else: |
|
return "Fake" |
|
|
|
|
|
st.title('User Profile Classifier') |
|
st.write('Predict whether a user profile is genuine or fake.') |
|
|
|
|
|
statuses_count = st.number_input("Statuses Count", min_value=0) |
|
followers_count = st.number_input("Followers Count", min_value=0) |
|
friends_count = st.number_input("Friends Count", min_value=0) |
|
favourites_count = st.number_input("Favourites Count", min_value=0) |
|
listed_count = st.number_input("Listed Count", min_value=0) |
|
name = st.text_input("Name") |
|
|
|
|
|
|
|
user_input = { |
|
"statuses_count": statuses_count, |
|
"followers_count": followers_count, |
|
"friends_count": friends_count, |
|
"favourites_count": favourites_count, |
|
"listed_count": listed_count, |
|
"name": name, |
|
} |
|
|
|
|
|
if st.button("Predict"): |
|
prediction = predict_user_profile(user_input) |
|
st.write(f"Prediction: {prediction}") |
|
|