6 Copyright (C) e2its - All Rights Reserved 7 * Unauthorized copying of this file, via any medium is strictly prohibited 8 * Proprietary and confidential 10 * This file is part of gDayF project. 12 * Written by Jose L. Sanchez <e2its.es@gmail.com>, 2016-2019 15 from hashlib
import md5
as md5
16 from hashlib
import sha256
as sha256
17 from pandas
import read_json
18 from json
import dumps
19 from copy
import deepcopy
20 from numpy.random
import rand
28 if hash_type ==
'MD5':
30 return md5(open(filename,
'rb').read()).hexdigest()
33 elif hash_type ==
'SHA256':
35 return sha256(open(filename,
'rb').read()).hexdigest()
45 return read_json(json_string, orient=orient)
53 json_string = dumps(ordered_dict)
62 if list1[0]
is None or list2[0]
is None:
63 return list1[0]
is None and list2[0]
is None 64 elif len(list1) != len(list2):
67 for i
in range(0, len(list1)):
68 if not compare_dict(list1[i], list2[i]):
79 if list1
is None or list2
is None:
80 return list1
is None and list2
is None 81 elif len(list1) != len(list2):
84 for i
in range(0, len(list1)):
85 if not (list1[i] == list2[i]):
90 return list(model[
'model_parameters'].keys())[0]
97 return deepcopy(model[
'normalizations_set'])
105 df[
'train'] = rand(len(df)) < train_perc
106 train = df[df.train == 1].drop(
'train', axis=1)
107 test = df[df.train == 0].drop(
'train', axis=1)
def compare_sorted_list_dict(list1, list2)
Function oriented compare two normalizations_sets based on cmp functions Need to be sorted in same or...
def hash_key(hash_type, filename)
Function oriented to get the hash_key for a file.
def decode_ordered_dict_to_dataframe(ordered_dict, orient='split')
Function oriented convert a OrderedDict() dataframe string structure on pandas.dataframe() ...
def decode_json_to_dataframe(json_string, orient='split')
Function oriented convert a json dataframe string structure on pandas.dataframe() ...
def get_model_ns(model)
Function to get normalization_sets structure from ar.json model description.
def compare_list_ordered_dict(list1, list2)
Function oriented compare two normalizations_sets based on hash_key(json transformations) ...
def get_model_fw(model)
Function to get framework from ar.json model description.
def pandas_split_data(df, train_perc=0.9)
Function to get pandas dataframe split without copy.
def xstr(s)
Function to return empty string if String variable is None.