Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion chebai_graph/preprocessing/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ def enc_if_not_none(encode, value):
assert len(encoded_values) == len(idents) == len(features)
torch.save(
[
{property.name: torch.cat(feat), "ident": id}
{
property.name: property.encoder.compress(
torch.cat(feat)
),
"ident": id,
}
for feat, id in zip(encoded_values, idents)
if feat is not None
],
Expand Down Expand Up @@ -352,11 +357,15 @@ def load_processed_data(
"""
base_data = super().load_processed_data(kind, filename)
base_df = pd.DataFrame(base_data)
base_df["ident"] = base_df["ident"].astype(str)

for property in self.properties:
property_data = torch.load(
self.get_property_path(property), weights_only=False
)

for entry in property_data:
entry[property.name] = property.encoder.decompress(entry[property.name])
if len(property_data[0][property.name].shape) > 1:
property.encoder.set_encoding_length(
property_data[0][property.name].shape[1]
Expand All @@ -366,6 +375,7 @@ def load_processed_data(
property_df.rename(
columns={property.name: f"{property.name}"}, inplace=True
)
property_df["ident"] = property_df["ident"].astype(str)
base_df = base_df.merge(property_df, on="ident", how="left")

base_df["features"] = base_df.apply(
Expand Down Expand Up @@ -451,6 +461,7 @@ def load_processed_data(
"""
base_data = super().load_processed_data(kind, filename)
base_df = pd.DataFrame(base_data)
base_df["ident"] = base_df["ident"].astype(str)
props_categories = {
"AllNodeTypeProperties": [],
"FGNodeTypeProperties": [],
Expand Down Expand Up @@ -505,12 +516,15 @@ def load_processed_data(
property_data = torch.load(
self.get_property_path(property), weights_only=False
)
for entry in property_data:
entry[property.name] = property.encoder.decompress(entry[property.name])
if len(property_data[0][property.name].shape) > 1:
property.encoder.set_encoding_length(
property_data[0][property.name].shape[1]
)

property_df = pd.DataFrame(property_data)
property_df["ident"] = property_df["ident"].astype(str)
property_df.rename(
columns={property.name: f"{property.name}"}, inplace=True
)
Expand Down
Loading