antitheft159 commited on
Commit
871e5fc
·
verified ·
1 Parent(s): 6677d9f

Upload 2 files

Browse files
IG_Fake_Account_Detector.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
ig_fake_account_detector.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """IG Fake Account Detector
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/11AvA8ysxhTbkhDXq-Sn2HnnKRgdGeT9U
8
+ """
9
+
10
+ # Commented out IPython magic to ensure Python compatibility.
11
+ import numpy as np
12
+ import pandas as pd
13
+ import seaborn as sns
14
+ import plotly.express as px
15
+ import matplotlib.pyplot as plt
16
+ from matplotlib import style
17
+ # %matplotlib inline
18
+ import warnings
19
+ warnings.filterwarnings('ignore')
20
+
21
+ df = pd.read_csv('/content/final-v1.csv')
22
+
23
+ df.head(5)
24
+
25
+ df.tail(5)
26
+
27
+ df.shape
28
+
29
+ df.columns
30
+
31
+ print(df)
32
+ print('dimensions:')
33
+ print(df.shape)
34
+ print('Information:')
35
+ df.info()
36
+
37
+ print(df.apply(lambda col: col.unique()))
38
+
39
+ df.nunique()
40
+
41
+ df.corr()
42
+
43
+ df.isnull().sum()
44
+
45
+ df.describe().T
46
+
47
+ df.drop(["has_guides"],axis=1,inplace=True)
48
+ df.drop(["edge_follow"],axis=1,inplace=True)
49
+ df.drop(["has_channel"],axis=1,inplace=True)
50
+ df.drop(["edge_followed_by"],axis=1,inplace=True)
51
+
52
+ df.head(5)
53
+
54
+ account = df.groupby("is_business_account")
55
+ account = account.size()
56
+ account
57
+
58
+ plt.pie(account.values , labels = ("Business Account", "Personal Account"), autopct='%1.1f%%',colors=['Lavender','lightgreen'], radius = 1, textprops = {"fontsize" : 16})
59
+ plt.title("Account Type", c="Blue")
60
+ plt.show()
61
+
62
+ account1 = df.groupby("is_private")
63
+ account1 = account1.size()
64
+ account1
65
+
66
+ plt.pie(account1.values, labels = ("Private", "Public"), autopct='%1.1f%%', colors=['pink', 'skyblue'], radius = 1.2, textprops = {"fontsize" : 16})
67
+ plt.title("Account Type", c="Blue")
68
+ plt.show()
69
+
70
+ fake_account_counts = df['is_fake'].value_counts()
71
+ labels = ['Yes', 'No']
72
+ colors = ['Skyblue', 'lightgreen']
73
+ explode = (0.1, 0)
74
+
75
+ plt.figure(figsize=(6, 4))
76
+ plt.pie(fake_account_counts, labels=labels, colors=colors, autopct='%1.1f%%', startangle=140, pctdistance=0.85, explode=explode)
77
+ plt.title('Fake Accounts Distribution', fontsize=16)
78
+
79
+
80
+ centre_circle = plt.Circle((0,0),0.70,fc='white')
81
+ fig = plt.gcf()
82
+ fig.gca().add_artist(centre_circle)
83
+ plt.axis('equal')
84
+ plt.show()
85
+
86
+ def barplot(column, horizontal):
87
+ plt.figure(figsize=(4, 4))
88
+ sns.countplot(x=column, data=df, palette='viridis')
89
+ plt.xlabel(column)
90
+ plt.ylabel("Fake")
91
+ plt.title(f"Users have Business Account", fontweight='bold')
92
+ plt.xticks(rotation=45)
93
+ sns.despine()
94
+ plt.tight_layout()
95
+ plt.show()
96
+
97
+ barplot('is_business_account', True)
98
+
99
+ def barplot(column, horizontal):
100
+ plt.figure(figsize=(4, 4))
101
+ sns.countplot(x=column, data=df, palette='viridis')
102
+ plt.xlabel(column)
103
+ plt.ylabel("Fake")
104
+ plt.title(f"Private Account", fontweight='bold')
105
+ plt.xticks(rotation=45)
106
+ sns.despine()
107
+ plt.tight_layout()
108
+ plt.show()
109
+
110
+ barplot('is_private', True)
111
+
112
+ def barplot(column, horizontal):
113
+ plt.figure(figsize=(4, 4))
114
+ sns.countplot(x=column, data=df, palette='viridis')
115
+ plt.xlabel(column)
116
+ plt.ylabel("Fake")
117
+ plt.title(f"User name has number", fontweight='bold')
118
+ plt.xticks(rotation=45)
119
+ sns.despine()
120
+ plt.tight_layout()
121
+ plt.show()
122
+
123
+ barplot('username_has_number', True)
124
+
125
+ def barplot(column, horizontal):
126
+ plt.figure(figsize=(4, 4))
127
+ sns.countplot(x=column, data=df, palette='viridis')
128
+ plt.xlabel(column)
129
+ plt.ylabel("Fake")
130
+ plt.title(f"User's full Name Has Number", fontweight='bold')
131
+ plt.xticks(rotation=45)
132
+ sns.despine()
133
+ plt.tight_layout()
134
+ plt.show()
135
+
136
+ barplot('full_name_has_number', True)
137
+
138
+ def barplot(column, horizontal):
139
+ plt.figure(figsize=(4, 4))
140
+ sns.countplot(x=column, data=df, palette='viridis')
141
+ plt.xlabel(column)
142
+ plt.ylabel("Fake")
143
+ plt.title(f"Users are Joined Recently", fontweight='bold')
144
+ plt.xticks(rotation=45)
145
+ sns.despine()
146
+ plt.tight_layout()
147
+ plt.show()
148
+
149
+ barplot('is_joined_recently', True)
150
+
151
+ def barplot(column, horizontal):
152
+ plt.figure(figsize=(6, 6))
153
+ sns.countplot(x=column, data=df, palette='viridis')
154
+ plt.xlabel(column)
155
+ plt.ylabel("Fake")
156
+ plt.title(f"User's full name length", fontweight='bold')
157
+ plt.xticks(rotation=45)
158
+ sns.despine()
159
+ plt.tight_layout()
160
+ plt.show()
161
+
162
+ barplot('username_length', True)