Skip to content

Commit

Permalink
mixtures were excluded from list of serizalization & bug with extensi…
Browse files Browse the repository at this point in the history
…ons fixed
  • Loading branch information
Roman223 committed Nov 22, 2023
1 parent 6c27969 commit a72c75d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion bamt/networks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ def save(self, bn_name, models_dir: str = "models_dir"):
to_serialize = {}
# separate logit and gaussian nodes from distributions to serialize bn's models
for node_name in distributions.keys():
if "Mixture" in self[node_name].type:
continue
if self[node_name].type.startswith("Gaussian"):
if not distributions[node_name]["regressor"]:
continue
Expand Down Expand Up @@ -491,7 +493,7 @@ def save(self, bn_name, models_dir: str = "models_dir"):
"parameters": distributions,
"weights": new_weights,
}
return self._save_to_file(bn_name, outdict)
return self._save_to_file(f"{bn_name}.json", outdict)

def load(self, input_dir: str, models_dir: str = "/"):
"""
Expand Down
8 changes: 4 additions & 4 deletions tests/sendingRegressors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Permeability",
"Depth",
]
]
].dropna()

encoder = pp.LabelEncoder()
discretizer = pp.KBinsDiscretizer(n_bins=5, encode="ordinal", strategy="quantile")
Expand All @@ -32,9 +32,9 @@

discretized_data, est = p.apply(hack_data)

bn = HybridBN()
bn = HybridBN(has_logit=True)
info = p.info
#

# with open(r"C:\Users\Roman\Desktop\mymodels\mynet.json") as f:
# net_data = json.load(f)

Expand All @@ -56,7 +56,7 @@

bn.fit_parameters(hack_data)

# bn.save("mynet.json")
# bn.save("mynet")

print(bn.sample(100).shape)
bn.get_info(as_df=False)

0 comments on commit a72c75d

Please sign in to comment.