likelihood 1.2.14__tar.gz → 1.2.16__tar.gz

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.
Files changed (23) hide show
  1. {likelihood-1.2.14 → likelihood-1.2.16}/PKG-INFO +3 -1
  2. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/models/deep/autoencoders.py +39 -16
  3. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/tools/tools.py +8 -1
  4. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood.egg-info/PKG-INFO +3 -1
  5. {likelihood-1.2.14 → likelihood-1.2.16}/setup.py +2 -0
  6. {likelihood-1.2.14 → likelihood-1.2.16}/LICENSE +0 -0
  7. {likelihood-1.2.14 → likelihood-1.2.16}/README.md +0 -0
  8. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/__init__.py +0 -0
  9. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/graph/__init__.py +0 -0
  10. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/graph/graph.py +0 -0
  11. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/main.py +0 -0
  12. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/models/__init__.py +0 -0
  13. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/models/deep/__init__.py +0 -0
  14. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/models/regression.py +0 -0
  15. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/models/simulation.py +0 -0
  16. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/models/utils.py +0 -0
  17. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/tools/__init__.py +0 -0
  18. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood/tools/numeric_tools.py +0 -0
  19. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood.egg-info/SOURCES.txt +0 -0
  20. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood.egg-info/dependency_links.txt +0 -0
  21. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood.egg-info/requires.txt +0 -0
  22. {likelihood-1.2.14 → likelihood-1.2.16}/likelihood.egg-info/top_level.txt +0 -0
  23. {likelihood-1.2.14 → likelihood-1.2.16}/setup.cfg +0 -0
@@ -1,10 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: likelihood
3
- Version: 1.2.14
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
@@ -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.shape = input_shape
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
- classifier = self.classifier(combined)
74
- return classifier
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]
@@ -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
- median_value = len(self._df[i].unique()) // 2
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.14
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
@@ -21,6 +21,8 @@ setuptools.setup(
21
21
  version=about["__version__"],
22
22
  author="J. A. Moreno-Guerra",
23
23
  author_email="jzs.gm27@gmail.com",
24
+ maintainer="Jafet Castañeda",
25
+ maintainer_email="jafetcc17@gmail.com",
24
26
  description="A package that performs the maximum likelihood algorithm.",
25
27
  py_modules=["likelihood"],
26
28
  long_description=long_description,
File without changes
File without changes
File without changes