File size: 2,247 Bytes
957a109
 
8720981
64f9029
957a109
 
 
 
 
 
 
64f9029
 
957a109
 
 
 
 
 
e8e5ad9
957a109
 
 
 
 
64f9029
957a109
 
64f9029
 
 
 
 
957a109
 
 
 
 
 
 
 
 
 
 
 
64f9029
957a109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pandas as pd
import pickle
import streamlit as st
# Load the trained model from data.pkl (assuming it's a custom model without sklearn)
def load_model():
  with open('data.pkl', 'rb') as file:
    model = pickle.load(file)
  return model

# Define the prediction function using the loaded model
def predict_user_profile(inputs):
  # Preprocess the input data (assuming your model doesn't require LabelEncoder)
  # ... (modify this section based on your specific model's preprocessing needs)

  # Create a DataFrame from the user input dictionary
  df = pd.DataFrame.from_dict([inputs])

  # Select the relevant feature columns used during model training
  feature_columns_to_use = ['statuses_count', 'followers_count', 'friends_count',
                            'favourites_count','listed_count']  # Assuming language isn't used
  df_features = df[feature_columns_to_use]

  # Load the pre-trained model
  model = load_model()

  # Make predictions using the loaded model (assuming your model has a predict method)
  prediction = model.predict(df_features)

  # Return the predicted class label (modify based on your model's output)
  if prediction > 0.5:  # Assuming a threshold for genuine classification
    return "Genuine"
  else:
    return "Fake"

# Create the Streamlit app
st.title('User Profile Classifier')
st.write('Predict whether a user profile is genuine or fake.')

# Create input fields for user data
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")
# Remove language input since it's not used in this version

# Create a dictionary to store user inputs
user_input = {
  "statuses_count": statuses_count,
  "followers_count": followers_count,
  "friends_count": friends_count,
  "favourites_count": favourites_count,
  "listed_count": listed_count,
  "name": name,
}

# Predict if the user clicks the button
if st.button("Predict"):
  prediction = predict_user_profile(user_input)
  st.write(f"Prediction: {prediction}")