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

Improve performance of data processing #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
24 changes: 15 additions & 9 deletions data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,20 +1003,18 @@ def process_one_file(
y[i] = target
X_int[i] = np.array(line[1:14], dtype=np.int32)
if max_ind_range > 0:
X_cat[i] = np.array(
list(map(lambda x: int(x, 16) % max_ind_range, line[14:])),
X_cat[i] = np.fromiter(
map(lambda x: int(x, 16) % max_ind_range, line[14:]),
dtype=np.int32
)
else:
X_cat[i] = np.array(
list(map(lambda x: int(x, 16), line[14:])),
X_cat[i] = np.fromiter(
map(lambda x: int(x, 16), line[14:]),
dtype=np.int32
)

# count uniques
if dataset_multiprocessing:
for j in range(26):
convertDicts_day[j][X_cat[i][j]] = 1
# debug prints
if float(i)/num_data_in_split*100 > percent+1:
percent = int(float(i)/num_data_in_split*100)
Expand All @@ -1033,8 +1031,6 @@ def process_one_file(
end="\n",
)
else:
for j in range(26):
convertDicts[j][X_cat[i][j]] = 1
# debug prints
print(
"Load %d/%d Split: %d Label True: %d Stored: %d"
Expand All @@ -1049,6 +1045,16 @@ def process_one_file(
)
i += 1

if dataset_multiprocessing:
for j in range(26):
unique_cats = np.unique(X_cat[:, j])
for category in unique_cats:
convertDicts_day[j][category] = 1
else:
for j in range(26):
unique_cats = np.unique(X_cat[:, j])
for category in unique_cats:
convertDicts[j][category] = 1
# store num_data_in_split samples or extras at the end of file
# count uniques
# X_cat_t = np.transpose(X_cat)
Expand Down Expand Up @@ -1146,7 +1152,7 @@ def process_one_file(
if not path.exists(dict_file_j):
np.savez_compressed(
dict_file_j,
unique=np.array(list(convertDicts[j]), dtype=np.int32)
unique=np.fromiter(convertDicts[j].keys(), dtype=np.int32)
)
counts[j] = len(convertDicts[j])
# store (uniques and) counts
Expand Down