likelihood 1.2.18__tar.gz → 1.2.20__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.
- {likelihood-1.2.18 → likelihood-1.2.20}/PKG-INFO +1 -1
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/models/deep/autoencoders.py +10 -5
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood.egg-info/PKG-INFO +1 -1
- {likelihood-1.2.18 → likelihood-1.2.20}/LICENSE +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/README.md +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/__init__.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/graph/__init__.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/graph/graph.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/graph/nn.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/main.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/models/__init__.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/models/deep/__init__.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/models/regression.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/models/simulation.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/models/utils.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/tools/__init__.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/tools/numeric_tools.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood/tools/tools.py +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood.egg-info/SOURCES.txt +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood.egg-info/dependency_links.txt +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood.egg-info/requires.txt +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/likelihood.egg-info/top_level.txt +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/setup.cfg +0 -0
- {likelihood-1.2.18 → likelihood-1.2.20}/setup.py +0 -0
|
@@ -6,11 +6,13 @@ import keras_tuner
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
import pandas as pd
|
|
8
8
|
import tensorflow as tf
|
|
9
|
+
from likelihood.tools import OneHotEncoder
|
|
9
10
|
from pandas.core.frame import DataFrame
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
|
|
12
13
|
|
|
13
14
|
|
|
15
|
+
@tf.keras.utils.register_keras_serializable(package="Custom", name="AutoClassifier")
|
|
14
16
|
class AutoClassifier(tf.keras.Model):
|
|
15
17
|
"""
|
|
16
18
|
An auto-classifier model that automatically determines the best classification strategy based on the input data.
|
|
@@ -54,7 +56,7 @@ class AutoClassifier(tf.keras.Model):
|
|
|
54
56
|
self.decoder = None
|
|
55
57
|
self.classifier = None
|
|
56
58
|
|
|
57
|
-
def build(self,
|
|
59
|
+
def build(self, input_shape):
|
|
58
60
|
self.encoder = tf.keras.Sequential(
|
|
59
61
|
[
|
|
60
62
|
tf.keras.layers.Dense(units=self.units, activation=self.activation),
|
|
@@ -187,7 +189,7 @@ def setup_model(
|
|
|
187
189
|
train_size: float = 0.7,
|
|
188
190
|
seed=None,
|
|
189
191
|
train_mode: bool = True,
|
|
190
|
-
filepath: str = "./my_dir/best_model
|
|
192
|
+
filepath: str = "./my_dir/best_model",
|
|
191
193
|
**kwargs,
|
|
192
194
|
) -> AutoClassifier:
|
|
193
195
|
"""Setup model for training and tuning.
|
|
@@ -236,6 +238,7 @@ def setup_model(
|
|
|
236
238
|
verbose = kwargs["verbose"] if "verbose" in kwargs else True
|
|
237
239
|
|
|
238
240
|
X = data.drop(columns=target)
|
|
241
|
+
input_sample = X.sample(1)
|
|
239
242
|
y = data[target]
|
|
240
243
|
# Verify if there are categorical columns in the dataframe
|
|
241
244
|
assert (
|
|
@@ -260,8 +263,9 @@ def setup_model(
|
|
|
260
263
|
y_encoder = OneHotEncoder()
|
|
261
264
|
y = y_encoder.encode(y.to_list())
|
|
262
265
|
X = X.to_numpy()
|
|
266
|
+
input_sample.to_numpy()
|
|
263
267
|
X = np.asarray(X).astype(np.float32)
|
|
264
|
-
|
|
268
|
+
input_sample = np.asarray(input_sample).astype(np.float32)
|
|
265
269
|
y = np.asarray(y).astype(np.float32)
|
|
266
270
|
|
|
267
271
|
input_shape_parm = X.shape[1]
|
|
@@ -284,9 +288,10 @@ def setup_model(
|
|
|
284
288
|
tuner.search(X, y, epochs=epochs, validation_split=validation_split)
|
|
285
289
|
models = tuner.get_best_models(num_models=2)
|
|
286
290
|
best_model = models[0]
|
|
291
|
+
best_model(input_sample)
|
|
287
292
|
|
|
288
293
|
# save model
|
|
289
|
-
best_model.save(filepath)
|
|
294
|
+
best_model.save(filepath, save_format="tf")
|
|
290
295
|
|
|
291
296
|
if verbose:
|
|
292
297
|
tuner.results_summary()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|