likelihood 1.2.14__py3-none-any.whl → 1.2.16__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.
- likelihood/models/deep/autoencoders.py +39 -16
- likelihood/tools/tools.py +8 -1
- {likelihood-1.2.14.dist-info → likelihood-1.2.16.dist-info}/METADATA +3 -1
- {likelihood-1.2.14.dist-info → likelihood-1.2.16.dist-info}/RECORD +7 -7
- {likelihood-1.2.14.dist-info → likelihood-1.2.16.dist-info}/LICENSE +0 -0
- {likelihood-1.2.14.dist-info → likelihood-1.2.16.dist-info}/WHEEL +0 -0
- {likelihood-1.2.14.dist-info → likelihood-1.2.16.dist-info}/top_level.txt +0 -0
|
@@ -6,12 +6,11 @@ import numpy as np
|
|
|
6
6
|
import pandas as pd
|
|
7
7
|
import tensorflow as tf
|
|
8
8
|
from pandas.core.frame import DataFrame
|
|
9
|
-
from tensorflow.keras.models import Model
|
|
10
9
|
|
|
11
10
|
from likelihood.tools import OneHotEncoder
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
class AutoClassifier(Model):
|
|
13
|
+
class AutoClassifier(tf.keras.Model):
|
|
15
14
|
"""
|
|
16
15
|
An auto-classifier model that automatically determines the best classification strategy based on the input data.
|
|
17
16
|
|
|
@@ -23,6 +22,10 @@ class AutoClassifier(Model):
|
|
|
23
22
|
|
|
24
23
|
Methods:
|
|
25
24
|
__init__(self, input_shape, num_classes, units, activation): Initializes an AutoClassifier instance with the given parameters.
|
|
25
|
+
build(self, input_shape): Builds the model architecture based on input_shape.
|
|
26
|
+
call(self, x): Defines the forward pass of the model.
|
|
27
|
+
get_config(self): Returns the configuration of the model.
|
|
28
|
+
from_config(cls, config): Recreates an instance of AutoClassifier from its configuration.
|
|
26
29
|
"""
|
|
27
30
|
|
|
28
31
|
def __init__(self, input_shape, num_classes, units, activation):
|
|
@@ -39,39 +42,61 @@ class AutoClassifier(Model):
|
|
|
39
42
|
The number of neurons in each hidden layer.
|
|
40
43
|
activation : `str`
|
|
41
44
|
The type of activation function to use for the neural network layers.
|
|
42
|
-
|
|
43
|
-
Returns
|
|
44
|
-
-------
|
|
45
|
-
None
|
|
46
45
|
"""
|
|
47
46
|
super(AutoClassifier, self).__init__()
|
|
47
|
+
self.input_shape = input_shape
|
|
48
|
+
self.num_classes = num_classes
|
|
48
49
|
self.units = units
|
|
49
|
-
self.
|
|
50
|
+
self.activation = activation
|
|
51
|
+
|
|
52
|
+
self.encoder = None
|
|
53
|
+
self.decoder = None
|
|
54
|
+
self.classifier = None
|
|
50
55
|
|
|
56
|
+
def build(self, input_shape):
|
|
51
57
|
self.encoder = tf.keras.Sequential(
|
|
52
58
|
[
|
|
53
|
-
tf.keras.layers.Dense(units=units, activation=activation),
|
|
54
|
-
tf.keras.layers.Dense(units=int(units / 2), activation=activation),
|
|
59
|
+
tf.keras.layers.Dense(units=self.units, activation=self.activation),
|
|
60
|
+
tf.keras.layers.Dense(units=int(self.units / 2), activation=self.activation),
|
|
55
61
|
]
|
|
56
62
|
)
|
|
57
63
|
|
|
58
64
|
self.decoder = tf.keras.Sequential(
|
|
59
65
|
[
|
|
60
|
-
tf.keras.layers.Dense(units=units, activation=activation),
|
|
61
|
-
tf.keras.layers.Dense(units=input_shape, activation=activation),
|
|
66
|
+
tf.keras.layers.Dense(units=self.units, activation=self.activation),
|
|
67
|
+
tf.keras.layers.Dense(units=self.input_shape, activation=self.activation),
|
|
62
68
|
]
|
|
63
69
|
)
|
|
64
70
|
|
|
65
71
|
self.classifier = tf.keras.Sequential(
|
|
66
|
-
[tf.keras.layers.Dense(num_classes, activation="softmax")]
|
|
72
|
+
[tf.keras.layers.Dense(self.num_classes, activation="softmax")]
|
|
67
73
|
)
|
|
68
74
|
|
|
69
75
|
def call(self, x):
|
|
70
76
|
encoded = self.encoder(x)
|
|
71
77
|
decoded = self.decoder(encoded)
|
|
72
78
|
combined = tf.concat([decoded, encoded], axis=1)
|
|
73
|
-
|
|
74
|
-
return
|
|
79
|
+
classification = self.classifier(combined)
|
|
80
|
+
return classification
|
|
81
|
+
|
|
82
|
+
def get_config(self):
|
|
83
|
+
config = {
|
|
84
|
+
"input_shape": self.input_shape,
|
|
85
|
+
"num_classes": self.num_classes,
|
|
86
|
+
"units": self.units,
|
|
87
|
+
"activation": self.activation,
|
|
88
|
+
}
|
|
89
|
+
base_config = super(AutoClassifier, self).get_config()
|
|
90
|
+
return dict(list(base_config.items()) + list(config.items()))
|
|
91
|
+
|
|
92
|
+
@classmethod
|
|
93
|
+
def from_config(cls, config):
|
|
94
|
+
return cls(
|
|
95
|
+
input_shape=config["input_shape"],
|
|
96
|
+
num_classes=config["num_classes"],
|
|
97
|
+
units=config["units"],
|
|
98
|
+
activation=config["activation"],
|
|
99
|
+
)
|
|
75
100
|
|
|
76
101
|
|
|
77
102
|
def call_existing_code(
|
|
@@ -210,8 +235,6 @@ def setup_model(
|
|
|
210
235
|
X = X.to_numpy()
|
|
211
236
|
X = np.asarray(X).astype(np.float32)
|
|
212
237
|
|
|
213
|
-
y = pd.DataFrame(y, columns=["class_0", "class_1"])
|
|
214
|
-
y = y.to_numpy()
|
|
215
238
|
y = np.asarray(y).astype(np.float32)
|
|
216
239
|
|
|
217
240
|
input_shape = X.shape[1]
|
likelihood/tools/tools.py
CHANGED
|
@@ -815,7 +815,10 @@ class DataFrameEncoder:
|
|
|
815
815
|
self._df[i] = self._df[i].apply(
|
|
816
816
|
self._code_transformation_to, dictionary_list=encode_dict
|
|
817
817
|
)
|
|
818
|
-
|
|
818
|
+
if len(self._df[i].unique()) > 1:
|
|
819
|
+
median_value = len(self._df[i].unique()) // 2
|
|
820
|
+
else:
|
|
821
|
+
median_value = 1.0
|
|
819
822
|
if norm_method == "median":
|
|
820
823
|
self._df[i] = self._df[i].astype("float64")
|
|
821
824
|
self._df[i] = self._df[i] / median_value
|
|
@@ -842,6 +845,8 @@ class DataFrameEncoder:
|
|
|
842
845
|
print("Configuration detected")
|
|
843
846
|
if len(self.median_list) == len(self._encode_columns):
|
|
844
847
|
median_mode = True
|
|
848
|
+
else:
|
|
849
|
+
median_mode = False
|
|
845
850
|
for num, colname in enumerate(self._encode_columns):
|
|
846
851
|
if self._df[colname].dtype == "object":
|
|
847
852
|
encode_dict = self.encoding_list[num]
|
|
@@ -859,6 +864,8 @@ class DataFrameEncoder:
|
|
|
859
864
|
df_decoded = self._df.copy()
|
|
860
865
|
if len(self.median_list) == len(self._encode_columns):
|
|
861
866
|
median_mode = True
|
|
867
|
+
else:
|
|
868
|
+
median_mode = False
|
|
862
869
|
try:
|
|
863
870
|
number_of_columns = len(self.decoding_list[j])
|
|
864
871
|
for i in self._encode_columns:
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: likelihood
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.16
|
|
4
4
|
Summary: A package that performs the maximum likelihood algorithm.
|
|
5
5
|
Home-page: https://github.com/jzsmoreno/likelihood/
|
|
6
6
|
Author: J. A. Moreno-Guerra
|
|
7
7
|
Author-email: jzs.gm27@gmail.com
|
|
8
|
+
Maintainer: Jafet Castañeda
|
|
9
|
+
Maintainer-email: jafetcc17@gmail.com
|
|
8
10
|
Classifier: Programming Language :: Python :: 3
|
|
9
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
12
|
Classifier: Operating System :: OS Independent
|
|
@@ -7,12 +7,12 @@ likelihood/models/regression.py,sha256=9cakyGlJCEO6WfpoKLh3GxdXQeQp7cUvJIkQ5odT0
|
|
|
7
7
|
likelihood/models/simulation.py,sha256=KYdVjt2PaLo04g8kBsRGQJ5AKMBaQVUH3orZE_TXTy8,2960
|
|
8
8
|
likelihood/models/utils.py,sha256=VtEj07lV-GRoWraQgpfjU0jTt1Ntf9MXgYwe6XYQh20,1552
|
|
9
9
|
likelihood/models/deep/__init__.py,sha256=-KIPippVaMqgG8mEgYjNxYQdqOUcFhUuKhbVe8TTCfo,28
|
|
10
|
-
likelihood/models/deep/autoencoders.py,sha256=
|
|
10
|
+
likelihood/models/deep/autoencoders.py,sha256=wgra29Wjyh4KOMdOVEhWLtfqTFvjKeOVf1GthomB7PE,8857
|
|
11
11
|
likelihood/tools/__init__.py,sha256=MCjsCWfBNKE2uMN0VizDN1uFzZ_md0X2WZeBdWhrCR8,50
|
|
12
12
|
likelihood/tools/numeric_tools.py,sha256=EQD959b56aovi4PI_og0BITgyUONgDUU9LG9YqNgX70,7554
|
|
13
|
-
likelihood/tools/tools.py,sha256=
|
|
14
|
-
likelihood-1.2.
|
|
15
|
-
likelihood-1.2.
|
|
16
|
-
likelihood-1.2.
|
|
17
|
-
likelihood-1.2.
|
|
18
|
-
likelihood-1.2.
|
|
13
|
+
likelihood/tools/tools.py,sha256=B1_xRZeO2fUSCVUvdkhlB6zO9dGzIglSknydLv7VCEc,41627
|
|
14
|
+
likelihood-1.2.16.dist-info/LICENSE,sha256=XWHWt9egYEUHGPTnlcZfJKLPmysacOwdiLj_-J7Z9ew,1066
|
|
15
|
+
likelihood-1.2.16.dist-info/METADATA,sha256=5htpwpnzwy5Y0sU103sm_K8Yt5xhMjjmLf1a3rx_40s,2463
|
|
16
|
+
likelihood-1.2.16.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
|
17
|
+
likelihood-1.2.16.dist-info/top_level.txt,sha256=KDiBLr870YTxqLFqObTOSrTK10uw8dFsITSNLlte3PA,11
|
|
18
|
+
likelihood-1.2.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|