Skip to content
Open
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
10 changes: 6 additions & 4 deletions ncpi/Inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ def process_batch(batch):
# Transform the features
if scaler is not None:
feat = scaler.transform(feat.reshape(1, -1))
# else:
# feat = feat.reshape(-1, 1)

# Check that feat has no NaN or Inf values
if np.all(np.isfinite(feat)):
Expand Down Expand Up @@ -482,7 +484,7 @@ def process_batch(batch):
return batch_index, predictions

model_path = os.path.join(result_dir, 'model.pkl')
# scaler_path = os.path.join(result_dir, 'scaler.pkl')
scaler_path = os.path.join(result_dir, 'scaler.pkl')
density_estimator_path = os.path.join(result_dir, 'density_estimator.pkl')

if not os.path.exists(model_path):
Expand All @@ -493,9 +495,9 @@ def process_batch(batch):
model = pickle.load(file)

# # Load or assign the scaler
# if scaler is not None:
# with open(scaler_path, 'rb') as file:
# scaler = pickle.load(file)
if scaler is None and os.path.exists(scaler_path):
with open(scaler_path, 'rb') as file:
scaler = pickle.load(file)

# Load density_estimator and build posterior if SBI
if self.model[1] == 'sbi':
Expand Down