likelihood 1.2.25__tar.gz → 1.3.0__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 (25) hide show
  1. {likelihood-1.2.25 → likelihood-1.3.0}/PKG-INFO +1 -1
  2. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/graph/graph.py +3 -3
  3. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/graph/nn.py +1 -1
  4. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/models/deep/autoencoders.py +22 -3
  5. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/models/simulation.py +0 -6
  6. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/models/utils.py +3 -11
  7. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood.egg-info/PKG-INFO +1 -1
  8. {likelihood-1.2.25 → likelihood-1.3.0}/LICENSE +0 -0
  9. {likelihood-1.2.25 → likelihood-1.3.0}/README.md +0 -0
  10. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/__init__.py +0 -0
  11. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/graph/__init__.py +0 -0
  12. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/main.py +0 -0
  13. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/models/__init__.py +0 -0
  14. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/models/deep/__init__.py +0 -0
  15. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/models/hmm.py +0 -0
  16. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/models/regression.py +0 -0
  17. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/tools/__init__.py +0 -0
  18. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/tools/numeric_tools.py +0 -0
  19. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood/tools/tools.py +0 -0
  20. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood.egg-info/SOURCES.txt +0 -0
  21. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood.egg-info/dependency_links.txt +0 -0
  22. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood.egg-info/requires.txt +0 -0
  23. {likelihood-1.2.25 → likelihood-1.3.0}/likelihood.egg-info/top_level.txt +0 -0
  24. {likelihood-1.2.25 → likelihood-1.3.0}/setup.cfg +0 -0
  25. {likelihood-1.2.25 → likelihood-1.3.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: likelihood
3
- Version: 1.2.25
3
+ Version: 1.3.0
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
@@ -45,8 +45,8 @@ class DynamicGraph(FeatureSelection):
45
45
 
46
46
  def draw(self, name="graph.html", **kwargs) -> None:
47
47
  """Display the network using HTML format"""
48
- spring_length = kwargs["spring_length"] if "spring_length" in kwargs else 500
49
- node_distance = kwargs["node_distance"] if "node_distance" in kwargs else 100
48
+ spring_length = kwargs.get("spring_length", 500)
49
+ node_distance = kwargs.get("node_distance", 100)
50
50
  self.G.repulsion(node_distance=node_distance, spring_length=spring_length)
51
51
  self.G.show_buttons(filter_=["physics"])
52
52
  self.G.show(name)
@@ -89,5 +89,5 @@ if __name__ == "__main__":
89
89
  df["y"] = y
90
90
  # Instantiate DynamicGraph
91
91
  fs = DynamicGraph(df, n_importances=2)
92
- print(fs.fit())
92
+ fs.fit()
93
93
  fs.draw()
@@ -96,7 +96,7 @@ def cal_adjacency_matrix(
96
96
 
97
97
  assert len(df_categorical) > 0
98
98
 
99
- similarity = kwargs["similarity"] if "similarity" in kwargs else len(df_categorical.columns) - 1
99
+ similarity = kwargs.get("similarity", len(df_categorical.columns) - 1)
100
100
  assert similarity <= df_categorical.shape[1]
101
101
 
102
102
  adj_dict = {}
@@ -79,6 +79,8 @@ class AutoClassifier(tf.keras.Model):
79
79
  The activation function to use for the classifier layer. Default is "softmax". If the activation function is not a classification function, the model can be used in regression problems.
80
80
  num_layers : `int`
81
81
  The number of hidden layers in the classifier. Default is 1.
82
+ dropout : `float`
83
+ The dropout rate to use in the classifier. Default is None.
82
84
  """
83
85
  super(AutoClassifier, self).__init__()
84
86
  self.input_shape_parm = input_shape_parm
@@ -91,6 +93,7 @@ class AutoClassifier(tf.keras.Model):
91
93
  self.classifier = None
92
94
  self.classifier_activation = kwargs.get("classifier_activation", "softmax")
93
95
  self.num_layers = kwargs.get("num_layers", 1)
96
+ self.dropout = kwargs.get("dropout", None)
94
97
 
95
98
  def build(self, input_shape):
96
99
  self.encoder = tf.keras.Sequential(
@@ -113,6 +116,8 @@ class AutoClassifier(tf.keras.Model):
113
116
  self.classifier.add(
114
117
  tf.keras.layers.Dense(units=self.units, activation=self.activation)
115
118
  )
119
+ if self.dropout:
120
+ self.classifier.add(tf.keras.layers.Dropout(self.dropout))
116
121
  self.classifier.add(
117
122
  tf.keras.layers.Dense(units=self.num_classes, activation=self.classifier_activation)
118
123
  )
@@ -132,6 +137,7 @@ class AutoClassifier(tf.keras.Model):
132
137
  "activation": self.activation,
133
138
  "classifier_activation": self.classifier_activation,
134
139
  "num_layers": self.num_layers,
140
+ "dropout": self.dropout,
135
141
  }
136
142
  base_config = super(AutoClassifier, self).get_config()
137
143
  return dict(list(base_config.items()) + list(config.items()))
@@ -145,6 +151,7 @@ class AutoClassifier(tf.keras.Model):
145
151
  activation=config["activation"],
146
152
  classifier_activation=config["classifier_activation"],
147
153
  num_layers=config["num_layers"],
154
+ dropout=config["dropout"],
148
155
  )
149
156
 
150
157
 
@@ -156,6 +163,7 @@ def call_existing_code(
156
163
  input_shape_parm: None | int = None,
157
164
  num_classes: None | int = None,
158
165
  num_layers: int = 1,
166
+ **kwargs,
159
167
  ) -> AutoClassifier:
160
168
  """
161
169
  Calls an existing AutoClassifier instance.
@@ -180,12 +188,14 @@ def call_existing_code(
180
188
  `AutoClassifier`
181
189
  The AutoClassifier instance.
182
190
  """
191
+ dropout = kwargs.get("dropout", None)
183
192
  model = AutoClassifier(
184
193
  input_shape_parm=input_shape_parm,
185
194
  num_classes=num_classes,
186
195
  units=units,
187
196
  activation=activation,
188
197
  num_layers=num_layers,
198
+ dropout=dropout,
189
199
  )
190
200
  model.compile(
191
201
  optimizer=optimizer,
@@ -254,6 +264,11 @@ def build_model(
254
264
  if "num_layers" not in hyperparameters_keys
255
265
  else hyperparameters["num_layers"]
256
266
  )
267
+ dropout = (
268
+ hp.Float("dropout", min_value=0.1, max_value=0.9, sampling="log")
269
+ if "dropout" not in hyperparameters_keys
270
+ else hyperparameters["dropout"]
271
+ )
257
272
 
258
273
  model = call_existing_code(
259
274
  units=units,
@@ -263,6 +278,7 @@ def build_model(
263
278
  input_shape_parm=input_shape_parm,
264
279
  num_classes=num_classes,
265
280
  num_layers=num_layers,
281
+ dropout=dropout,
266
282
  )
267
283
  return model
268
284
 
@@ -408,10 +424,8 @@ class GetInsights:
408
424
  self.model = model
409
425
  self.encoder_layer = self.model.encoder.layers[0]
410
426
  self.decoder_layer = self.model.decoder.layers[0]
411
- self.classifier_layer = self.model.classifier.layers[-2]
412
427
  self.encoder_weights = self.encoder_layer.get_weights()[0]
413
428
  self.decoder_weights = self.decoder_layer.get_weights()[0]
414
- self.classifier_weights = self.classifier_layer.get_weights()[0]
415
429
  colors = dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS)
416
430
 
417
431
  by_hsv = sorted(
@@ -580,7 +594,12 @@ if __name__ == "__main__":
580
594
  y = np.asarray(y).astype(np.float32)
581
595
 
582
596
  model = AutoClassifier(
583
- input_shape_parm=X.shape[1], num_classes=3, units=27, activation="selu", num_layers=2
597
+ input_shape_parm=X.shape[1],
598
+ num_classes=3,
599
+ units=27,
600
+ activation="tanh",
601
+ num_layers=2,
602
+ dropout=0.2,
584
603
  )
585
604
  model.compile(
586
605
  optimizer="adam",
@@ -2,31 +2,25 @@ import pickle
2
2
  import warnings
3
3
  from typing import List, Tuple, Union
4
4
 
5
- import matplotlib.pyplot as plt
6
5
  import numpy as np
7
6
  import pandas as pd
8
7
  from pandas.core.frame import DataFrame
9
8
 
10
9
  from likelihood.tools import DataScaler, FeatureSelection, OneHotEncoder, cdf, check_nan_inf
11
10
 
12
- # Suppress RankWarning
13
11
  warnings.simplefilter("ignore", np.RankWarning)
14
12
 
15
13
 
16
14
  # --------------------------------------------------------------------------------------------------------------------------------------
17
15
  def categories_by_quartile(df: DataFrame, column: str) -> Tuple[str, str]:
18
- # Count the frequency of each category in the column
19
16
  freq = df[column].value_counts()
20
17
 
21
- # Calculate the 25th percentile (Q1) and 75th percentile (Q3)
22
18
  q1 = freq.quantile(0.25)
23
19
  q3 = freq.quantile(0.75)
24
20
 
25
- # Filter categories that are below the 25th percentile and above the 75th percentile
26
21
  least_frequent = freq[freq <= q1]
27
22
  most_frequent = freq[freq >= q3]
28
23
 
29
- # Get the least frequent category (25th percentile) and the most frequent category (75th percentile)
30
24
  least_frequent_category = least_frequent.idxmin() if not least_frequent.empty else None
31
25
  most_frequent_category = most_frequent.idxmax() if not most_frequent.empty else None
32
26
 
@@ -1,12 +1,10 @@
1
- import matplotlib.pyplot as plt
2
1
  import numpy as np
3
- from numpy import ndarray
4
2
 
5
3
  from likelihood.tools import cal_average
6
4
 
7
5
 
8
6
  class FeaturesArima:
9
- def forward(self, y_sum: ndarray, theta: list, mode: bool, noise: float):
7
+ def forward(self, y_sum: np.ndarray, theta: list, mode: bool, noise: float):
10
8
  if mode:
11
9
  y_vec = []
12
10
 
@@ -31,20 +29,14 @@ class FeaturesArima:
31
29
 
32
30
  return np.array(y_vec)
33
31
 
34
- def integrated(self, datapoints: ndarray):
32
+ def integrated(self, datapoints: np.ndarray):
35
33
  datapoints = self.datapoints
36
- # n = datapoints.shape[0]
37
-
38
- # y_sum = [
39
- # ((1.0 - datapoints[i - 1] / datapoints[i]) ** self.d) * datapoints[i]
40
- # for i in range(1, n)
41
- # ]
42
34
  y_sum = list(np.diff(datapoints, self.d))
43
35
  y_sum.insert(0, datapoints[0])
44
36
 
45
37
  return np.array(y_sum)
46
38
 
47
- def average(self, datapoints: ndarray):
39
+ def average(self, datapoints: np.ndarray):
48
40
  y_sum_average = cal_average(datapoints)
49
41
  y_sum_eps = datapoints - y_sum_average
50
42
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: likelihood
3
- Version: 1.2.25
3
+ Version: 1.3.0
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
File without changes
File without changes
File without changes
File without changes