0% found this document useful (0 votes)
20 views12 pages

Instagram Fake Profile Detection AI

This code provides a summary of a document describing code that uses artificial intelligence techniques to detect fake Instagram profiles. It uses deep learning models trained on Instagram profile data to analyze features of new profiles and predict whether they are authentic. The code builds a neural network model using TensorFlow and Keras, trains it on labeled profile data, then implements a graphical user interface for users to input profile features and get predictions from the trained model.

Uploaded by

aryasurve1210
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views12 pages

Instagram Fake Profile Detection AI

This code provides a summary of a document describing code that uses artificial intelligence techniques to detect fake Instagram profiles. It uses deep learning models trained on Instagram profile data to analyze features of new profiles and predict whether they are authentic. The code builds a neural network model using TensorFlow and Keras, trains it on labeled profile data, then implements a graphical user interface for users to input profile features and get predictions from the trained model.

Uploaded by

aryasurve1210
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Diploma all branch projects avilable….contact now… sahidshaikh850@gmail.

com

Instagram fake
account detection

That provided code utilizes artificial intelligence (AI) techniques, specifically deep learning, to predict
the authenticity of Instagram profiles. Here's how AI is used in the code:

1. Deep Learning Model The code uses TensorFlow and Keras, which are libraries for building deep
learning models. Specifically, it constructs a deep neural network (DNN) model using the Sequential
API from Keras. Deep learning is a subset of AI that involves training neural networks to learn
patterns and make predictions from data.

2. Model Training: The deep learning model is trained on a dataset containing features of Instagram
profiles and their corresponding labels (indicating whether they are fake or not). During training,
the model learns the underlying patterns in the data, enabling it to make predictions on new,
unseen data.

3. Prediction: Once the model is trained, it is used to predict the authenticity of new Instagram
profiles. Users input various features of an Instagram profile into the GUI, and the trained
model predicts whether the profile is likely to be fake or not based on these features. This
prediction process is driven by the AI model's learned patterns and decision-making
capabilities.

Overall, the code employs AI techniques, specifically deep learning, to develop a predictive model for
detecting fake Instagram profiles.

1. Importing Libraries: The script imports necessary libraries including pandas, numpy, scikit-
learn, TensorFlow, Tkinter, and PIL (Python Imaging Library).

2. Data Preprocessing: The training data is loaded from a CSV file named insta_train.csv. It
preprocesses the data by splitting it into features (X_train) and target labels (y_train). It then scales
the features using StandardScaler.

3. Model Building and Training: A deep learning model is constructed using Keras Sequential API. It
consists of several dense layers with ReLU activation functions and dropout layers for
regularization.
Diploma all branch projects mehidid850@[Link]
Diploma all branch projects avilable….contact now… sahidshaikh850@[Link]

The model is compiled with Adam optimizer and categorical cross-entropy loss function. It is trained
on the preprocessed training data for 50 epochs.

4. GUI Setup: A Tkinter window is created for the GUI. The background image is loaded and
displayed using PIL and Tkinter. Entry fields are created for users to input the features of an
Instagram profile
they want to predict.

5. Prediction Function: There's a function named predict_instagram_profile() that collects user


inputs from the GUI entry fields, converts them into a DataFrame, scales them, and then uses the
trained model to predict whether the provided Instagram profile is fake or not. The prediction result
is displayed using a message box.

6. GUI Widgets: Entry fields are created for each feature, allowing users to input the relevant data.
A "Predict" button triggers the prediction function when clicked.

7. Main Loop: The Tkinter main loop ([Link]()) is initiated to keep the GUI running
and responsive to user interactions.

import pandas as pd

import numpy as np

from [Link] import StandardScaler

from [Link] import Sequential

from [Link] import Dense, Dropout

import tkinter as tk

from tkinter import ttk

from tkinter import

messagebox import tensorflow

as tf

from PIL import Image, ImageTk

Absolutely, let's break down the code line by line:

```python

import pandas as pd

import numpy as np

from [Link] import StandardScaler

from [Link] import Sequential

from [Link] import Dense, Dropout

import tkinter as tk

from tkinter import ttk


Diploma all branch projects mehidid850@[Link]
Diploma all branch projects avilable….contact now… sahidshaikh850@[Link]

from tkinter import

messagebox import tensorflow

as tf

from PIL import Image, ImageTk

```

1. `import pandas as pd`: Imports the pandas library with the alias pd.

2. `import numpy as np`: Imports the numpy library with the alias np.

3. `from [Link] import StandardScaler`: Imports the StandardScaler class from


the preprocessing module of scikit-learn.

4. `from [Link] import Sequential`: Imports the Sequential class from the
models module of TensorFlow's Keras API.

5. `from [Link] import Dense, Dropout`: Imports the Dense and Dropout
classes from the layers module of TensorFlow's Keras API.

6. `import tkinter as tk`: Imports the tkinter library with the alias tk, used for building GUIs.

7. `from tkinter import ttk`: Imports ttk (themed tk) module from tkinter, used for creating
themed widgets.

8. `from tkinter import messagebox`: Imports the messagebox module from tkinter, used
for displaying message boxes.

9. `import tensorflow as tf`: Imports TensorFlow library with the alias tf.

10. `from PIL import Image, ImageTk`: Imports the Image and ImageTk modules from the
PIL (Python Imaging Library).

The code provided uses several technologies and libraries for different purposes. Here's a
breakdown of the technologies used:

1. Python: The core programming language used for developing the entire script.

2. Pandas: A powerful data manipulation library in Python used for data analysis and manipulation.
It is used here for loading and preprocessing the training data.

3. NumPy: A fundamental package for scientific computing with Python, used for
numerical operations and array manipulation.

Diploma all branch projects mehidid850@[Link]


Diploma all branch projects avilable….contact now… sahidshaikh850@[Link]

4. Scikit-learn: A machine learning library in Python that provides simple and efficient tools for
data mining and data analysis. It is used here for preprocessing the data and scaling features using
StandardScaler.

5. TensorFlow: An open-source deep learning library developed by Google used for building and
training neural network models. The Keras API within TensorFlow is used to build and train the deep
learning model for predicting Instagram profiles.

6. Tkinter: The standard GUI (Graphical User Interface) toolkit included with Python, used
for creating the GUI window, widgets, and event handling.

7. PIL (Python Imaging Library): A library for adding image processing capabilities to Python. It
is used here for loading and displaying background images in the Tkinter GUI.

These technologies work together to create a machine learning model for predicting
the authenticity of Instagram profiles, integrated into a user-friendly GUI using Tkinter.

code line by line, explaining the purpose and functionality of each line:

```python
import pandas as pd
```
This line imports the pandas library and gives it an alias `pd`, which is commonly used for data
manipulation and analysis.

Diploma all branch projects mehidid850@[Link]


Diploma all branch projects avilable….contact now… sahidshaikh850@[Link]

```python
import numpy as np
```
This line imports the numpy library and gives it an alias `np`, which is used for numerical
computing and array operations
```python
from [Link] import StandardScaler
```
This line imports the `StandardScaler` class from the `preprocessing` module of the scikit-learn
library. The `StandardScaler` is used for standardizing features by removing the mean and scaling to
unit variance.
```python
from [Link] import Sequential
```
This line imports the `Sequential` class from the `models` module of the TensorFlow Keras API.
`Sequential` is a linear stack of layers used for building deep learning models.
```python
from [Link] import Dense, Dropout
```
This
```python
import tkinter as tk
This line imports the `tkinter` library, which is the standard GUI (Graphical User Interface) toolkit for
Python.
from tkinter import ttk
This line imports the `ttk` module from `tkinter`, which provides themed widget classes for creating
GUI applications.
from tkinter import messagebox
This line imports the `messagebox` module from `tkinter`, which is used to display message boxes in
the GUI.
import tensorflow as tf
This line imports the TensorFlow library with the alias `tf`, which is an open-source deep learning
framework developed by Google.
from PIL import Image, ImageTk
This line imports the `Image` and `ImageTk` modules from the Python Imaging Library (PIL), which
are used for handling images in various formats.

Diploma all branch projects mehidid850@[Link]


Diploma all branch projects avilable….contact now… sahidshaikh850@[Link]

These lines at the beginning of the script import all the necessary libraries and modules required for
data preprocessing, model building, GUI development, and image handling.

```python
# Function to predict Instagram profile
def predict_instagram_profile():
# Create dictionary to store user input
data = {}
```
This defines a function named `predict_instagram_profile()` that will be used to predict whether an
Instagram profile is fake or not. It initializes an empty dictionary `data` to store user input for various
features of the Instagram profile.
```python
# Prompt user for input for each feature
for feature in ['profile pic', 'nums/length username', 'fullname words', 'nums/length fullname',
'name==username',
'description length', 'external URL', 'private', '#posts', '#followers', '#follows']:
data[feature] = float(entries[feature].get())
```
This loop iterates over a list of features of an Instagram profile. For each feature, it retrieves the user
input from the corresponding entry field in the GUI (`entries`) and converts it to a float before
storing it in the `data` dictionary.
```python
# Convert dictionary to DataFrame
user_data = [Link]([data])
```This line converts the `data` dictionary into a pandas DataFrame called `user_data`.
```python
# Convert numeric columns to numeric, ignoring non-numeric values
user_data = user_data.apply(pd.to_numeric, errors='ignore')
```
This line converts the columns of the `user_data` DataFrame to numeric data types, ignoring non-
numeric values.
```python

Diploma all branch projects mehidid850@[Link]


Diploma all branch projects avilable….contact now… sahidshaikh850@[Link]

# Scaling user data


user_data_scaled = [Link](user_data)
```
This line scales the user data using the `scaler` object, which was previously fitted to the training
data.

```python
# Predict user data
user_pred = [Link](user_data_scaled)
user_pred_label = "Fake" if [Link](user_pred) == 1 else "Not Fake"
[Link]("Prediction", f"The provided Instagram profile is likely
{user_pred_label}.")
```
This section predicts the authenticity of the provided Instagram profile. It uses the trained deep
learning model (`model`) to predict the class label for the user data. The prediction result is displayed
in a message box indicating whether the profile is likely to be fake or not.
The subsequent lines of code load the training dataset, preprocess the data, build and train the deep
learning model, set up the GUI, create input fields for each feature, and define a "Predict" button
that triggers the prediction function when clicked.

This function `predict_instagram_profile()` is used to predict whether an Instagram profile is fake


or not. It collects user input for various features of the profile, converts it into a DataFrame, scales
the data, predicts the authenticity using the trained model, and displays the prediction result in a
message box.

```python
# Load the training dataset
instagram_df_train = pd.read_csv(r'D:\finfake\Fake-Instagram-Profile-Detection-main - Copy (3) -
Copy\insta_train.csv')
```
This line loads the training dataset from a CSV file using pandas.

```python
# Preparing Data to Train the Model

Diploma all branch projects mehidid850@[Link]


Diploma all branch projects avilable….contact now… sahidshaikh850@[Link]

# Training dataset (inputs)


X_train = instagram_df_train.drop(columns=['fake'])

# Training dataset (Outputs)


y_train = instagram_df_train['fake']

# Scaling the data before training the model


scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
y_train = [Link].to_categorical(y_train, num_classes=2)
```
These lines prepare the training data for the model. It separates the features (X_train) and target
labels (y_train), scales the features using StandardScaler, and converts the target labels into
categorical format using TensorFlow's `to_categorical()` function.

```python
# Building and Training Deep Learning Model
model = Sequential([
Dense(50, input_dim=11, activation='relu'),
Dense(150, activation='relu'),
Dropout(0.3),
Dense(150, activation='relu'),
Dropout(0.3),
Dense(25, activation='relu'),
Dropout(0.3),
Dense(2, activation='softmax')
])

[Link](optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])

epochs_hist = [Link](X_train_scaled, y_train, epochs=50, verbose=1, validation_split=0.1)


```
These lines build and train the deep learning model using TensorFlow's Keras API. The model consists
of several dense layers with ReLU activation functions and dropout layers for regularization. It's

Diploma all branch projects mehidid850@[Link]


Diploma all branch projects avilable….contact now… sahidshaikh850@[Link]

compiled with the Adam optimizer and categorical cross-entropy loss function, and then trained on
the preprocessed training data for 50 epochs.

```python
# GUI Setup
root =
[Link]()
[Link]("Fake Instagram Profile Detection")
[Link]("400x400")

# Load and display background image


background_image = [Link](r'C:\final_year_project\images\[Link]')
background_photo = [Link](background_image)
background_label = [Link](root, image=background_photo)
background_label.place(relwidth=1, relheight=1)

# Create input fields for each feature


entries = {}
for i, feature in enumerate(['profile pic', 'nums/length username', 'fullname words', 'nums/length
fullname', 'name==username',
'description length', 'external URL', 'private', '#posts', '#followers', '#follows']):
label = [Link](root, text=feature)
[Link](row=i, column=0, padx=10, pady=5)
entry = [Link](root)
[Link](row=i, column=1, padx=10, pady=5)
entries[feature] = entry

# Button to predict
predict_button = [Link](root, text="Predict", command=predict_instagram_profile)
predict_button.grid(row=11, column=0, columnspan=2, pady=10)

[Link]()
```
These lines set up the GUI using Tkinter. It creates a window with a title "Fake Instagram Profile
Detection" and size 400x400. It loads and displays a background image. It creates input fields for

Diploma all branch projects mehidid850@[Link]


Diploma all branch projects avilable….contact now… sahidshaikh850@[Link]

each feature of an Instagram profile, and a "Predict" button that triggers the
`predict_instagram_profile()` function when clicked. Finally, it starts the Tkinter main loop to run the
GUI application.

Diploma all branch projects mehidid850@[Link]

Common questions

Powered by AI

The deep learning architecture includes several dense layers with ReLU activation functions and dropout for regularization. Dense layers are chosen for their fully connected nature, which allows the model to learn complex representations of input data. ReLU is a popular activation function due to its ability to introduce non-linearities while avoiding saturation, thereby speeding up training. Dropout layers are included to prevent overfitting by randomly deactivating neurons during training, which promotes more generalizable learning patterns .

Using a validation split allows the model to be evaluated on a portion of the data that it has not been trained on during each epoch, which helps in monitoring overfitting. It provides insight into how the model will perform on unseen data by simulating new input conditions, aiding in the adjustment of hyperparameters and architecture during development. This enhances the robustness and efficiency of the model in practical usage scenarios, like predicting Instagram profile authenticity .

The Tkinter-based GUI collects user inputs regarding the Instagram profile features. These inputs are transformed into a DataFrame and scaled before being fed into the trained machine learning model. The interaction is user-friendly: users enter features into entry fields in the GUI, and a prediction is made when the 'Predict' button is clicked, utilizing the `predict_instagram_profile()` function to determine if the profile is fake or not .

The Sequential API from Keras allows the construction of the model layer-by-layer, which provides a clear and accessible way to design and stack layers linearly. This is advantageous in the fake Instagram profile detection model as it consists of several dense layers, enabling the developer to easily add and test different network architectures, activation functions, and regularization techniques, like dropout, to enhance performance .

Training the model for 50 epochs allows sufficient learning opportunities, enabling convergence towards optimal weights and enhancing predictive performance. However, prolonged training might lead to overfitting, where the model is too tailored to the training data. Although dropout is utilized to mitigate this, continuous monitoring via validation loss is necessary to avoid such pitfalls. Additionally, longer training times require more computation, potentially increasing development costs unless effectively managed .

StandardScaler is used to standardize the features by removing the mean and scaling to unit variance. This ensures that the data follows a normal distribution which can improve the performance and training speed of the deep learning model by normalizing input features .

Dropout is used to prevent overfitting in neural networks by randomly setting a fraction of input units to zero at each update during training time. This forces the model to learn more robust features and prevents it from relying too heavily on any single feature, which can be crucial in high-dimensional prediction tasks like distinguishing fake from real profiles where the model could otherwise memorize the training data .

TensorFlow and Keras provide a robust, high-level interface to build deep learning models with ease. TensorFlow offers scalability and cross-platform deployment, essential for complex models that require substantial computing power, while Keras simplifies model construction with intuitive APIs like Sequential, enabling rapid prototyping and testing of different architectures. Their integration facilitates streamlined development and deployment of AI solutions such as the Instagram fake profile detection system .

The input data is collected from the user via the GUI and stored in a dictionary. Each feature is obtained from entries simulating Instagram profile attributes (e.g., 'profile pic', 'nums/length username'). This data is then converted into a pandas DataFrame and scaled using a StandardScaler previously fitted to the training data. This standardized user input data is then fed into the deep learning model to predict if the profile is fake or not .

The process involves several steps: First, a deep neural network model is constructed using TensorFlow and Keras, which are libraries for building deep learning models. The model is trained on a dataset of Instagram profile features and their labels indicating authenticity (fake or not). The training involves learning patterns and decision-making capabilities from the provided data. Once trained, the model predicts the authenticity of new profiles entered through a GUI, using the features provided by users. The prediction utilizes the learned patterns to classify the profiles as fake or not .

You might also like