reflexive 0.1.9__py3-none-any.whl → 1.0.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reflexive/__init__.py +5 -9
- reflexive/analyse.py +431 -0
- reflexive/cfg.py +118 -0
- reflexive/session.py +265 -0
- reflexive/util.py +125 -0
- reflexive/{visual/display.py → visualise.py} +22 -22
- {reflexive-0.1.9.dist-info → reflexive-1.0.14.dist-info}/METADATA +1 -1
- reflexive-1.0.14.dist-info/RECORD +12 -0
- reflexive/analyse/__init__.py +0 -0
- reflexive/analyse/aws_nlp.py +0 -196
- reflexive/analyse/general.py +0 -128
- reflexive/analyse/reflexive_expressions.py +0 -124
- reflexive/aws_connect/__init__.py +0 -0
- reflexive/aws_connect/comprehend.py +0 -205
- reflexive/aws_connect/s3.py +0 -89
- reflexive/common/__init__.py +0 -0
- reflexive/common/local.py +0 -48
- reflexive/common/parameters.py +0 -77
- reflexive/common/util.py +0 -108
- reflexive/visual/__init__.py +0 -0
- reflexive-0.1.9.dist-info/RECORD +0 -20
- {reflexive-0.1.9.dist-info → reflexive-1.0.14.dist-info}/LICENSE +0 -0
- {reflexive-0.1.9.dist-info → reflexive-1.0.14.dist-info}/LICENSE.txt +0 -0
- {reflexive-0.1.9.dist-info → reflexive-1.0.14.dist-info}/WHEEL +0 -0
- {reflexive-0.1.9.dist-info → reflexive-1.0.14.dist-info}/top_level.txt +0 -0
reflexive/common/util.py
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Utility functions
|
|
3
|
-
from sklearn.preprocessing import MinMaxScaler
|
|
4
|
-
|
|
5
|
-
class Util:
|
|
6
|
-
|
|
7
|
-
def __init__(self):
|
|
8
|
-
self.name = "Util"
|
|
9
|
-
|
|
10
|
-
def sort_dict_by_value(self,d):
|
|
11
|
-
return dict(sorted(d.items(), key=lambda x:x[1], reverse=True))
|
|
12
|
-
|
|
13
|
-
def filter_dict_by_value(self,ngrams,min_val=3):
|
|
14
|
-
filtered_ngrams = {}
|
|
15
|
-
for k,v in ngrams.items():
|
|
16
|
-
if v >=min_val:
|
|
17
|
-
filtered_ngrams[k] = v
|
|
18
|
-
return filtered_ngrams
|
|
19
|
-
|
|
20
|
-
# Function to write dictionaries to both json and csv
|
|
21
|
-
def writeDictJsonCSV(self,dictionary,path_file):
|
|
22
|
-
with open(f"{path_file}.json",'w') as fp:
|
|
23
|
-
fp.write(json.dumps(dictionary))
|
|
24
|
-
|
|
25
|
-
ngram_df = pd.DataFrame.from_dict(dictionary,orient='index')
|
|
26
|
-
ngram_df.to_csv(f"{path_file}.csv")
|
|
27
|
-
|
|
28
|
-
# Input a series and output a list of lists with each maxn elements
|
|
29
|
-
def series_to_chunked_list(self,series,maxn=25):
|
|
30
|
-
l = list(series)
|
|
31
|
-
return self.__chunk_list(l,maxn)
|
|
32
|
-
|
|
33
|
-
# Chunk a list into a list of lists with maxn elements
|
|
34
|
-
def __chunk_list(self,l,maxn=25):
|
|
35
|
-
return [l[i:i + maxn] for i in range(0, len(l), maxn)]
|
|
36
|
-
|
|
37
|
-
# Count named entities
|
|
38
|
-
def count_entities(self,entities):
|
|
39
|
-
counts = []
|
|
40
|
-
for k,v in entities.items():
|
|
41
|
-
counts.append((k,len(v)))
|
|
42
|
-
return sorted(counts, key=lambda x: x[1], reverse=True)
|
|
43
|
-
|
|
44
|
-
# Function for calculating proportions of features
|
|
45
|
-
def ratios(self,elements):
|
|
46
|
-
etotal = sum([v[1] for v in elements])
|
|
47
|
-
if etotal==0:
|
|
48
|
-
return elements
|
|
49
|
-
else:
|
|
50
|
-
proportioned = []
|
|
51
|
-
for element in elements:
|
|
52
|
-
prop_val = round((element[1]/etotal),4)
|
|
53
|
-
proportioned.append((element[0],prop_val))
|
|
54
|
-
return proportioned
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
# Count labels associated with strings
|
|
59
|
-
def count_labels(self,string_labels):
|
|
60
|
-
counts = dict()
|
|
61
|
-
for rt in string_labels:
|
|
62
|
-
counts[rt[1]] = counts.setdefault(rt[1],0) + 1
|
|
63
|
-
return sorted(counts.items(), key=lambda x: x[1], reverse=True)
|
|
64
|
-
|
|
65
|
-
def count_keys(self,key_count_dict):
|
|
66
|
-
counts = dict()
|
|
67
|
-
for k,v in key_count_dict.items():
|
|
68
|
-
counts[k] = counts.setdefault(k,0) + v
|
|
69
|
-
return sorted(counts.items(), key=lambda x: x[1], reverse=True)
|
|
70
|
-
|
|
71
|
-
# Total the values in list of tuples
|
|
72
|
-
def tuple_values_total(self,tuples):
|
|
73
|
-
tvs = [t[1] for t in tuples]
|
|
74
|
-
return sum(tvs)
|
|
75
|
-
|
|
76
|
-
#### SCALING AND NORMALISING
|
|
77
|
-
|
|
78
|
-
# Outliers
|
|
79
|
-
|
|
80
|
-
def outlier_fence(self,series):
|
|
81
|
-
bounds = {}
|
|
82
|
-
stats = series.describe()
|
|
83
|
-
iqr = stats['75%'] - stats['25%']
|
|
84
|
-
bounds["IQR"]=iqr
|
|
85
|
-
upper = stats['75%']+1.5*iqr
|
|
86
|
-
bounds["UPPER"]=upper
|
|
87
|
-
lower = stats['25%']-1.5*iqr
|
|
88
|
-
bounds["LOWER"]=lower
|
|
89
|
-
return bounds
|
|
90
|
-
|
|
91
|
-
# MinMax Scaling
|
|
92
|
-
def scale_min_max(self,df_cols):
|
|
93
|
-
scaler = MinMaxScaler()
|
|
94
|
-
return scaler.fit_transform(df_cols)
|
|
95
|
-
|
|
96
|
-
# Normalise domain term counts
|
|
97
|
-
def normalise_domain_counts(self,domain_counts,text_size):
|
|
98
|
-
norms = {}
|
|
99
|
-
for k,v in domain_counts.items():
|
|
100
|
-
norms[k] = round(v*text_size,3)
|
|
101
|
-
return norms
|
|
102
|
-
|
|
103
|
-
def normalise_scaled(self,df,feature,norm_feature = 'text_scaled'):
|
|
104
|
-
tempdf = df[[feature,norm_feature]].copy()
|
|
105
|
-
tempdf['norm_scaled'] = tempdf.apply(lambda r: round(r[feature]/(r[norm_feature]+0.01),4),axis=1)
|
|
106
|
-
return tempdf['norm_scaled']
|
|
107
|
-
|
|
108
|
-
|
reflexive/visual/__init__.py
DELETED
|
File without changes
|
reflexive-0.1.9.dist-info/RECORD
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
reflexive/__init__.py,sha256=DXmbgl_xMxd9Flqx3LXfbuYmYaJqzbDjB6r4mcPx75Y,292
|
|
2
|
-
reflexive/analyse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
reflexive/analyse/aws_nlp.py,sha256=7uRZg4lRt6t33wAA-ZaKCWKWrA8aQJn31GwFpl8FWqQ,8355
|
|
4
|
-
reflexive/analyse/general.py,sha256=ZPHkJcwwiV0CZQYa7JX9qjM5fm41MCPAq58GjtEtLKY,4388
|
|
5
|
-
reflexive/analyse/reflexive_expressions.py,sha256=YGd346EH78KMOrzfAyP07o7DOvfQF9mybDSc4bZuoio,5121
|
|
6
|
-
reflexive/aws_connect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
reflexive/aws_connect/comprehend.py,sha256=eGbjf2Njy2KBTWd33GGrwFIk5e9GcKfUETBr_6mSvY0,7706
|
|
8
|
-
reflexive/aws_connect/s3.py,sha256=l20haGTMmUPe_HjSi9jVu5oeyNC8VcVTD7X-CvDq1-o,3517
|
|
9
|
-
reflexive/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
reflexive/common/local.py,sha256=euhMmdRnL5c5d_Co2f2ehNP7Lv43T571tDCWQzpKaF4,1752
|
|
11
|
-
reflexive/common/parameters.py,sha256=o0Yw3dvSdVvEC46Q1a_QK0mr7uDIb_SCmUYWUyspSM0,3305
|
|
12
|
-
reflexive/common/util.py,sha256=OIfdQpkg3WLz0Ymm3OYlvOEE_ZGlI4KQHc8PYPb4vn8,3458
|
|
13
|
-
reflexive/visual/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
reflexive/visual/display.py,sha256=XiRC3Asx9Ed3xCNCt3_DlbF45JcifNbXH_B44jxqqp0,3886
|
|
15
|
-
reflexive-0.1.9.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
16
|
-
reflexive-0.1.9.dist-info/LICENSE.txt,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
17
|
-
reflexive-0.1.9.dist-info/METADATA,sha256=2y2QHK_2H-b3jXDbsgfl07pPxtLjPtU_fyDkpRrv-98,12037
|
|
18
|
-
reflexive-0.1.9.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
19
|
-
reflexive-0.1.9.dist-info/top_level.txt,sha256=pOMr-QGleRBRCFBozgvM-UUUmOjD_-naJfu1522E2V8,10
|
|
20
|
-
reflexive-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|