self, sparse_data: List[Dict[int, float]]
) -> Tuple[torch.Tensor, torch.Tensor]:
dense_data = torch.ones([len(sparse_data), len(self.feature_id_to_index)])
dense_presence = torch.zeros(
[len(sparse_data), len(self.feature_id_to_index)]
).byte()
for i, feature_map in enumerate(sparse_data):
assert (
feature_map is not None
), f"Please make sure that features are not NULL; row {i}"
After Change
state_features_df = pd.DataFrame(sparse_data).fillna(missing_value)
// Add columns identified by normalization, but not present in batch
for col in self.sorted_features:
if col not in state_features_df.columns:
state_features_df[col] = missing_value
values = torch.from_numpy(
state_features_df[self.sorted_features].values
).float()
if self.set_missing_value_to_zero: