-
Notifications
You must be signed in to change notification settings - Fork 0
/
Visuals.py
78 lines (63 loc) · 1.66 KB
/
Visuals.py
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
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 22 15:05:39 2022
@author: KTong
"""
import seaborn as sns
import matplotlib.pyplot as plt
class Visualisation():
def __init__(self):
pass
def cont_plot(self,df,num_features):
'''
Creates plots for numerical data.
Parameters
----------
df : pandas Dataframe
Dataset.
num_features : list
Column names of numerical features.
Returns
-------
seaborn.distplot().
'''
for i in num_features:
plt.figure()
sns.distplot(df[i])
plt.show()
def cat_plot(self,df,cat_features):
'''
Creates plots for categorical data.
Parameters
----------
df : pandas Dataframe
Dataset.
cat_features : list
Column names of categorical features.
Returns
-------
seaborn.countplot().
'''
for i in cat_features:
plt.figure(figsize=(12,10))
sns.countplot(df[i])
plt.show()
def cat_group_plot(self,df,cat_features,target):
'''
Creates plots for categorical data base on group by target feature.
Parameters
----------
df : pandas Dataframe
Dataset.
cat_features : list
Column names of categorical features.
target : string
Target feature.
Returns
-------
seaborn.countplot(,hue=).
'''
for i in cat_features:
plt.figure(figsize=(12,10))
sns.countplot(df[i],hue=(df[target]))
plt.show()