Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sample training data after splitting #83

Merged
merged 1 commit into from
May 28, 2024
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
14 changes: 13 additions & 1 deletion nmrcraft/data/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def load_data(self) -> pd.DataFrame:
Preprocessed data (pandas.DataFrame): The preprocessed dataset.
"""
self.dataset = filename_to_ligands(self.dataset)
self.dataset = self.dataset.sample(frac=self.dataset_size)
self.choose_geometry()
return self.split_and_preprocess()

Expand Down Expand Up @@ -193,6 +192,19 @@ def split_and_preprocess(
random_state=self.random_state,
)

# Further sample the training data to reduce its size
train_size = int(len(y_train) * self.dataset_size)
if train_size < 1:
train_size = 1 # Ensure at least one sample

indices = np.arange(len(y_train))
np.random.shuffle(indices)
indices = indices[:train_size]

X_train_NMR = X_train_NMR[indices]
X_train_Structural = X_train_Structural[indices]
y_train = y_train[indices]

# Scale numerical features (the NMR tensor)
scaler = StandardScaler()
X_train_NMR_scaled = scaler.fit_transform(X_train_NMR)
Expand Down
Loading