text stringlengths 1 93.6k |
|---|
npzfile = d_path + ((d_file + "_day") if dataset == "kaggle" else d_file)
|
# trafile = d_path + ((d_file + "_fea") if dataset == "kaggle" else "fea")
|
# check if pre-processed data is available
|
data_ready = True
|
if memory_map:
|
for i in range(days):
|
reo_data = d_path + npzfile + "_{0}_reordered.npz".format(i)
|
if not path.exists(str(reo_data)):
|
data_ready = False
|
else:
|
if not path.exists(str(pro_data)):
|
data_ready = False
|
# pre-process data if needed
|
# WARNNING: when memory mapping is used we get a collection of files
|
if data_ready:
|
print("Reading pre-processed data=%s" % (str(pro_data)))
|
file = str(pro_data)
|
else:
|
print("Reading raw data=%s" % (str(raw_path)))
|
file = getCriteoAdData(
|
raw_path,
|
o_filename,
|
max_ind_range,
|
sub_sample_rate,
|
days,
|
data_split,
|
randomize,
|
dataset == "kaggle",
|
memory_map
|
)
|
return file, days
|
if __name__ == "__main__":
|
### import packages ###
|
import argparse
|
### parse arguments ###
|
parser = argparse.ArgumentParser(
|
description="Preprocess Criteo dataset"
|
)
|
# model related parameters
|
parser.add_argument("--max-ind-range", type=int, default=-1)
|
parser.add_argument("--data-sub-sample-rate", type=float, default=0.0) # in [0, 1]
|
parser.add_argument("--data-randomize", type=str, default="total") # or day or none
|
parser.add_argument("--memory-map", action="store_true", default=False)
|
parser.add_argument("--data-set", type=str, default="kaggle") # or terabyte
|
parser.add_argument("--raw-data-file", type=str, default="")
|
parser.add_argument("--processed-data-file", type=str, default="")
|
args = parser.parse_args()
|
loadDataset(
|
args.data_set,
|
args.max_ind_range,
|
args.data_sub_sample_rate,
|
args.data_randomize,
|
"train",
|
args.raw_data_file,
|
args.processed_data_file,
|
args.memory_map
|
)
|
# <FILESEP>
|
# Copyright 2023 NNAISENSE SA
|
#
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
# you may not use this file except in compliance with the License.
|
# You may obtain a copy of the License at
|
#
|
# http://www.apache.org/licenses/LICENSE-2.0
|
#
|
# Unless required by applicable law or agreed to in writing, software
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# See the License for the specific language governing permissions and
|
# limitations under the License.
|
import math
|
import os
|
import pathlib
|
import pickle
|
import zipfile
|
from typing import Union
|
import numpy as np
|
import requests
|
import torch
|
import torchvision
|
from matplotlib import pyplot as plt
|
from omegaconf import DictConfig
|
from torch.utils.data import Dataset, random_split
|
from torchvision import transforms
|
from torchvision.utils import make_grid
|
from utils_model import quantize
|
TEXT8_CHARS = list("_abcdefghijklmnopqrstuvwxyz")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.