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}")