File size: 3,968 Bytes
871e5fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# -*- 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)