likelihood 1.2.21__py3-none-any.whl → 1.2.22__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/graph/nn.py CHANGED
@@ -1,9 +1,14 @@
1
+ import os
2
+
3
+ os.environ["TF_ENABLE_ONEDNN_OPTS"] = "0"
4
+ import logging
1
5
  import warnings
2
6
  from typing import List, Tuple
3
7
 
4
8
  import numpy as np
5
9
  import pandas as pd
6
10
  import tensorflow as tf
11
+ from IPython.display import clear_output
7
12
  from numpy import ndarray
8
13
  from pandas.core.frame import DataFrame
9
14
  from sklearn.metrics import f1_score
@@ -11,6 +16,10 @@ from sklearn.model_selection import train_test_split
11
16
 
12
17
  from likelihood.tools import generate_feature_yaml
13
18
 
19
+ logging.getLogger("tensorflow").setLevel(logging.ERROR)
20
+
21
+ tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
22
+
14
23
 
15
24
  def compare_similarity(arr1: ndarray, arr2: ndarray) -> int:
16
25
  """Compares the similarity between two arrays of categories.
@@ -180,14 +189,6 @@ class VanillaGNN(tf.keras.Model):
180
189
  self.gnn2 = VanillaGNNLayer(self.dim_h, self.dim_h)
181
190
  self.gnn3 = VanillaGNNLayer(self.dim_h, self.dim_out)
182
191
 
183
- def build(self, input_shape):
184
- super(VanillaGNN, self).build(input_shape)
185
- dummy_input = tf.keras.Input(shape=input_shape[1:])
186
- dummy_adjacency = tf.sparse.SparseTensor(
187
- indices=[[0, 0]], values=[1.0], dense_shape=[input_shape[0], input_shape[0]]
188
- )
189
- _ = self(dummy_input, dummy_adjacency)
190
-
191
192
  def call(self, x, adjacency):
192
193
  h = self.gnn1(x, adjacency)
193
194
  h = tf.nn.tanh(h)
@@ -289,10 +290,11 @@ class VanillaGNN(tf.keras.Model):
289
290
  train_losses.append(train_loss)
290
291
  train_f1_scores.append(train_f1)
291
292
 
292
- if epoch % 2 == 0:
293
+ if epoch % 5 == 0:
293
294
  val_loss, val_f1 = self.evaluate(X_test, adjacency_test, y_test)
294
295
  val_losses.append(val_loss)
295
296
  val_f1_scores.append(val_f1)
297
+ clear_output(wait=True)
296
298
  print(
297
299
  f"Epoch {epoch:>3} | Train Loss: {train_loss:.3f} | Train F1: {train_f1:.3f} | Val Loss: {val_loss:.3f} | Val F1: {val_f1:.3f}"
298
300
  )
@@ -327,9 +329,9 @@ if __name__ == "__main__":
327
329
  model = VanillaGNN(dim_in=data.x.shape[1], dim_h=8, dim_out=len(iris_df["species"].unique()))
328
330
  print("Before training F1:", model.test(data))
329
331
  model.fit(data, epochs=200, batch_size=32, test_size=0.5)
330
- model.save("./best_model.keras")
332
+ model.save("./best_model", save_format="tf")
331
333
  print("After training F1:", model.test(data))
332
- best_model = tf.keras.models.load_model("./best_model.keras")
334
+ best_model = tf.keras.models.load_model("./best_model")
333
335
 
334
336
  print("After loading F1:", best_model.test(data))
335
337
  df_results = pd.DataFrame()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: likelihood
3
- Version: 1.2.21
3
+ Version: 1.2.22
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
@@ -13,24 +13,24 @@ Classifier: Operating System :: OS Independent
13
13
  Requires-Python: >=3.10
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
- Requires-Dist: black[jupyter] ==24.1.1
17
- Requires-Dist: mypy-extensions ==1.0.0
18
- Requires-Dist: types-openpyxl ==3.1.0.15
19
- Requires-Dist: pydocstyle ==6.3.0
20
- Requires-Dist: flake8 ==6.0.0
21
- Requires-Dist: isort ==5.12.0
22
- Requires-Dist: mypy ==1.4.1
23
- Requires-Dist: numpy <2.0.0
16
+ Requires-Dist: black[jupyter]==24.1.1
17
+ Requires-Dist: mypy-extensions==1.0.0
18
+ Requires-Dist: types-openpyxl==3.1.0.15
19
+ Requires-Dist: pydocstyle==6.3.0
20
+ Requires-Dist: flake8==6.0.0
21
+ Requires-Dist: isort==5.12.0
22
+ Requires-Dist: mypy==1.4.1
23
+ Requires-Dist: numpy<2.0.0
24
24
  Requires-Dist: matplotlib
25
25
  Requires-Dist: pyyaml
26
26
  Requires-Dist: pandas
27
27
  Requires-Dist: corner
28
28
  Provides-Extra: full
29
- Requires-Dist: networkx ; extra == 'full'
30
- Requires-Dist: pyvis ; extra == 'full'
31
- Requires-Dist: tensorflow ==2.15.0 ; extra == 'full'
32
- Requires-Dist: keras-tuner ; extra == 'full'
33
- Requires-Dist: scikit-learn ; extra == 'full'
29
+ Requires-Dist: networkx; extra == "full"
30
+ Requires-Dist: pyvis; extra == "full"
31
+ Requires-Dist: tensorflow==2.15.0; extra == "full"
32
+ Requires-Dist: keras-tuner; extra == "full"
33
+ Requires-Dist: scikit-learn; extra == "full"
34
34
 
35
35
  ![likelihood](https://raw.githubusercontent.com/RodolfoFerro/likelihood/main/likelihood.png)
36
36
 
@@ -2,7 +2,7 @@ likelihood/__init__.py,sha256=5C0hapdsk85XZhN_rssRAEFpkRRuKNtj6cyRbqD2_gM,994
2
2
  likelihood/main.py,sha256=fcCkGOOWKjfvw2tLVqjuKPV8t0rVCIT9FlbYcOv4EYo,7974
3
3
  likelihood/graph/__init__.py,sha256=6TuFDfmXTwpLyHl7_KqBfdzW6zqHjGzIFvymjFPlvjI,21
4
4
  likelihood/graph/graph.py,sha256=wKJqgxXiSbnvzyW3SjhQVrqp00yKMHf3ph6CIDNVhNM,2891
5
- likelihood/graph/nn.py,sha256=XqTnAHzXP0jSdLd0IOFjVZUZTcQU-XppsZLmJrG2GMo,12372
5
+ likelihood/graph/nn.py,sha256=jBgb2SMUwM5OBatkIxH2I-_hH1ok5aw2fwXq5a1VAEg,12306
6
6
  likelihood/models/__init__.py,sha256=e6nB4w47w0Q9DrAFeP3OcUgcoHOtf7Il4mBhgf4AARg,52
7
7
  likelihood/models/regression.py,sha256=9cakyGlJCEO6WfpoKLh3GxdXQeQp7cUvJIkQ5odT0TA,9404
8
8
  likelihood/models/simulation.py,sha256=mdgQPg_LEY5svPaF4TFv-DoQRE2oP2ig_uXnwINtewM,4039
@@ -12,8 +12,8 @@ likelihood/models/deep/autoencoders.py,sha256=2P--nS96XwMi44q0OIxvIp6Mdbt-B4LqwC
12
12
  likelihood/tools/__init__.py,sha256=MCjsCWfBNKE2uMN0VizDN1uFzZ_md0X2WZeBdWhrCR8,50
13
13
  likelihood/tools/numeric_tools.py,sha256=FA44kbiAcxcquz1el_g3Pqsp5ii8XFkAIrsMs5bGkj0,11445
14
14
  likelihood/tools/tools.py,sha256=O39aPxTNsaBVSJFIkNsUESNSkfG4C7GG77wcR51a8IQ,42543
15
- likelihood-1.2.21.dist-info/LICENSE,sha256=XWHWt9egYEUHGPTnlcZfJKLPmysacOwdiLj_-J7Z9ew,1066
16
- likelihood-1.2.21.dist-info/METADATA,sha256=G3reOFrns927OS-FhndEABT5Xa2BJj8GTrNVOJ9F4fU,2518
17
- likelihood-1.2.21.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
18
- likelihood-1.2.21.dist-info/top_level.txt,sha256=KDiBLr870YTxqLFqObTOSrTK10uw8dFsITSNLlte3PA,11
19
- likelihood-1.2.21.dist-info/RECORD,,
15
+ likelihood-1.2.22.dist-info/LICENSE,sha256=XWHWt9egYEUHGPTnlcZfJKLPmysacOwdiLj_-J7Z9ew,1066
16
+ likelihood-1.2.22.dist-info/METADATA,sha256=_7sP0uqn2Qt-HCsWwVtqVML8K9Mite9BDktrT1BX_6I,2504
17
+ likelihood-1.2.22.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
18
+ likelihood-1.2.22.dist-info/top_level.txt,sha256=KDiBLr870YTxqLFqObTOSrTK10uw8dFsITSNLlte3PA,11
19
+ likelihood-1.2.22.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.5.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5