diff --git a/chebai_graph/preprocessing/datasets/base.py b/chebai_graph/preprocessing/datasets/base.py index 35b92fc..26bc507 100644 --- a/chebai_graph/preprocessing/datasets/base.py +++ b/chebai_graph/preprocessing/datasets/base.py @@ -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 ], @@ -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] @@ -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( @@ -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": [], @@ -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 )