-
Notifications
You must be signed in to change notification settings - Fork 90
Add split functionality to synthetic_data #268
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,25 @@ def __init__(self, name, root=_DEFAULT_DATADIR, download=True): | |
self.index = self.data['u'] | ||
self.lam = self.data['lam'] | ||
|
||
|
||
def split(self, split): | ||
tot_len = len(self.neural) | ||
train_idx = np.arange(tot_len)[:int(tot_len*0.8)] | ||
valid_idx = np.arange(tot_len)[int(tot_len*0.8):] | ||
|
||
if split == 'train': | ||
self.neural = self.neural[train_idx] | ||
self.index = self.index[train_idx] | ||
self.idx = train_idx | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method modifies the instance state by setting self.idx, but this attribute is not defined in init. This could lead to inconsistent state if split() is called multiple times or if other code expects self.idx to always exist. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
elif split == 'valid': | ||
self.neural = self.neural[valid_idx] | ||
self.index = self.index[valid_idx] | ||
self.idx = valid_idx | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method modifies the instance state by setting self.idx, but this attribute is not defined in init. This could lead to inconsistent state if split() is called multiple times or if other code expects self.idx to always exist. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
elif split == 'all': | ||
pass | ||
else: | ||
raise ValueError(f"{split} not supported") | ||
|
||
@property | ||
def input_dimension(self): | ||
return self.neural.size(1) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The hardcoded 0.8 split ratio should be extracted as a configurable parameter or class constant to improve maintainability and allow for different split ratios.
Copilot uses AI. Check for mistakes.