IGFakeAccountDetector / ig_fake_account_detector.py
antitheft159's picture
Upload 2 files
871e5fc verified
# -*- coding: utf-8 -*-
"""IG Fake Account Detector
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/11AvA8ysxhTbkhDXq-Sn2HnnKRgdGeT9U
"""
# Commented out IPython magic to ensure Python compatibility.
import numpy as np
import pandas as pd
import seaborn as sns
import plotly.express as px
import matplotlib.pyplot as plt
from matplotlib import style
# %matplotlib inline
import warnings
warnings.filterwarnings('ignore')
df = pd.read_csv('/content/final-v1.csv')
df.head(5)
df.tail(5)
df.shape
df.columns
print(df)
print('dimensions:')
print(df.shape)
print('Information:')
df.info()
print(df.apply(lambda col: col.unique()))
df.nunique()
df.corr()
df.isnull().sum()
df.describe().T
df.drop(["has_guides"],axis=1,inplace=True)
df.drop(["edge_follow"],axis=1,inplace=True)
df.drop(["has_channel"],axis=1,inplace=True)
df.drop(["edge_followed_by"],axis=1,inplace=True)
df.head(5)
account = df.groupby("is_business_account")
account = account.size()
account
plt.pie(account.values , labels = ("Business Account", "Personal Account"), autopct='%1.1f%%',colors=['Lavender','lightgreen'], radius = 1, textprops = {"fontsize" : 16})
plt.title("Account Type", c="Blue")
plt.show()
account1 = df.groupby("is_private")
account1 = account1.size()
account1
plt.pie(account1.values, labels = ("Private", "Public"), autopct='%1.1f%%', colors=['pink', 'skyblue'], radius = 1.2, textprops = {"fontsize" : 16})
plt.title("Account Type", c="Blue")
plt.show()
fake_account_counts = df['is_fake'].value_counts()
labels = ['Yes', 'No']
colors = ['Skyblue', 'lightgreen']
explode = (0.1, 0)
plt.figure(figsize=(6, 4))
plt.pie(fake_account_counts, labels=labels, colors=colors, autopct='%1.1f%%', startangle=140, pctdistance=0.85, explode=explode)
plt.title('Fake Accounts Distribution', fontsize=16)
centre_circle = plt.Circle((0,0),0.70,fc='white')
fig = plt.gcf()
fig.gca().add_artist(centre_circle)
plt.axis('equal')
plt.show()
def barplot(column, horizontal):
plt.figure(figsize=(4, 4))
sns.countplot(x=column, data=df, palette='viridis')
plt.xlabel(column)
plt.ylabel("Fake")
plt.title(f"Users have Business Account", fontweight='bold')
plt.xticks(rotation=45)
sns.despine()
plt.tight_layout()
plt.show()
barplot('is_business_account', True)
def barplot(column, horizontal):
plt.figure(figsize=(4, 4))
sns.countplot(x=column, data=df, palette='viridis')
plt.xlabel(column)
plt.ylabel("Fake")
plt.title(f"Private Account", fontweight='bold')
plt.xticks(rotation=45)
sns.despine()
plt.tight_layout()
plt.show()
barplot('is_private', True)
def barplot(column, horizontal):
plt.figure(figsize=(4, 4))
sns.countplot(x=column, data=df, palette='viridis')
plt.xlabel(column)
plt.ylabel("Fake")
plt.title(f"User name has number", fontweight='bold')
plt.xticks(rotation=45)
sns.despine()
plt.tight_layout()
plt.show()
barplot('username_has_number', True)
def barplot(column, horizontal):
plt.figure(figsize=(4, 4))
sns.countplot(x=column, data=df, palette='viridis')
plt.xlabel(column)
plt.ylabel("Fake")
plt.title(f"User's full Name Has Number", fontweight='bold')
plt.xticks(rotation=45)
sns.despine()
plt.tight_layout()
plt.show()
barplot('full_name_has_number', True)
def barplot(column, horizontal):
plt.figure(figsize=(4, 4))
sns.countplot(x=column, data=df, palette='viridis')
plt.xlabel(column)
plt.ylabel("Fake")
plt.title(f"Users are Joined Recently", fontweight='bold')
plt.xticks(rotation=45)
sns.despine()
plt.tight_layout()
plt.show()
barplot('is_joined_recently', True)
def barplot(column, horizontal):
plt.figure(figsize=(6, 6))
sns.countplot(x=column, data=df, palette='viridis')
plt.xlabel(column)
plt.ylabel("Fake")
plt.title(f"User's full name length", fontweight='bold')
plt.xticks(rotation=45)
sns.despine()
plt.tight_layout()
plt.show()
barplot('username_length', True)