code
stringlengths
17
6.64M
class PointnetSAModule(PointnetSAModuleMSG): 'Pointnet set abstrction layer\n\n Parameters\n ----------\n npoint : int\n Number of features\n radius : float\n Radius of ball\n nsample : int\n Number of samples in the ball query\n mlp : list\n Spec of the pointnet befo...
class PointnetSAModuleVotes(nn.Module): ' Modified based on _PointnetSAModuleBase and PointnetSAModuleMSG\n with extra support for returning point indices for getting their GT votes ' def __init__(self, *, mlp: List[int], npoint: int=None, radius: float=None, nsample: int=None, bn: bool=True, use_xyz: boo...
class PointnetSAModuleMSGVotes(nn.Module): ' Modified based on _PointnetSAModuleBase and PointnetSAModuleMSG\n with extra support for returning point indices for getting their GT votes ' def __init__(self, *, mlps: List[List[int]], npoint: int, radii: List[float], nsamples: List[int], bn: bool=True, use_x...
class PointnetFPModule(nn.Module): 'Propigates the features of one set to another\n\n Parameters\n ----------\n mlp : list\n Pointnet module parameters\n bn : bool\n Use batchnorm\n ' def __init__(self, *, mlp: List[int], bn: bool=True): super().__init__() self.ml...
class PointnetLFPModuleMSG(nn.Module): ' Modified based on _PointnetSAModuleBase and PointnetSAModuleMSG\n learnable feature propagation layer.' def __init__(self, *, mlps: List[List[int]], radii: List[float], nsamples: List[int], post_mlp: List[int], bn: bool=True, use_xyz: bool=True, sample_uniformly: b...
def test_interpolation_grad(): batch_size = 1 feat_dim = 2 m = 4 feats = torch.randn(batch_size, feat_dim, m, requires_grad=True).float().cuda() def interpolate_func(inputs): idx = torch.from_numpy(np.array([[[0, 1, 2], [1, 2, 3]]])).int().cuda() weight = torch.from_numpy(np.array...
class SharedMLP(nn.Sequential): def __init__(self, args: List[int], *, bn: bool=False, activation=nn.ReLU(inplace=True), preact: bool=False, first: bool=False, name: str=''): super().__init__() for i in range((len(args) - 1)): self.add_module((name + 'layer{}'.format(i)), Conv2d(args[...
class _BNBase(nn.Sequential): def __init__(self, in_size, batch_norm=None, name=''): super().__init__() self.add_module((name + 'bn'), batch_norm(in_size)) nn.init.constant_(self[0].weight, 1.0) nn.init.constant_(self[0].bias, 0)
class BatchNorm1d(_BNBase): def __init__(self, in_size: int, *, name: str=''): super().__init__(in_size, batch_norm=nn.BatchNorm1d, name=name)
class BatchNorm2d(_BNBase): def __init__(self, in_size: int, name: str=''): super().__init__(in_size, batch_norm=nn.BatchNorm2d, name=name)
class BatchNorm3d(_BNBase): def __init__(self, in_size: int, name: str=''): super().__init__(in_size, batch_norm=nn.BatchNorm3d, name=name)
class _ConvBase(nn.Sequential): def __init__(self, in_size, out_size, kernel_size, stride, padding, activation, bn, init, conv=None, batch_norm=None, bias=True, preact=False, name=''): super().__init__() bias = (bias and (not bn)) conv_unit = conv(in_size, out_size, kernel_size=kernel_siz...
class Conv1d(_ConvBase): def __init__(self, in_size: int, out_size: int, *, kernel_size: int=1, stride: int=1, padding: int=0, activation=nn.ReLU(inplace=True), bn: bool=False, init=nn.init.kaiming_normal_, bias: bool=True, preact: bool=False, name: str=''): super().__init__(in_size, out_size, kernel_siz...
class Conv2d(_ConvBase): def __init__(self, in_size: int, out_size: int, *, kernel_size: Tuple[(int, int)]=(1, 1), stride: Tuple[(int, int)]=(1, 1), padding: Tuple[(int, int)]=(0, 0), activation=nn.ReLU(inplace=True), bn: bool=False, init=nn.init.kaiming_normal_, bias: bool=True, preact: bool=False, name: str=''...
class Conv3d(_ConvBase): def __init__(self, in_size: int, out_size: int, *, kernel_size: Tuple[(int, int, int)]=(1, 1, 1), stride: Tuple[(int, int, int)]=(1, 1, 1), padding: Tuple[(int, int, int)]=(0, 0, 0), activation=nn.ReLU(inplace=True), bn: bool=False, init=nn.init.kaiming_normal_, bias: bool=True, preact: ...
class FC(nn.Sequential): def __init__(self, in_size: int, out_size: int, *, activation=nn.ReLU(inplace=True), bn: bool=False, init=None, preact: bool=False, name: str=''): super().__init__() fc = nn.Linear(in_size, out_size, bias=(not bn)) if (init is not None): init(fc.weight...
def set_bn_momentum_default(bn_momentum): def fn(m): if isinstance(m, (nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d)): m.momentum = bn_momentum return fn
class BNMomentumScheduler(object): def __init__(self, model, bn_lambda, last_epoch=(- 1), setter=set_bn_momentum_default): if (not isinstance(model, nn.Module)): raise RuntimeError("Class '{}' is not a PyTorch nn Module".format(type(model).__name__)) self.model = model self.se...
def conv_branch_init(conv, branches): weight = conv.weight n = weight.size(0) k1 = weight.size(1) k2 = weight.size(2) nn.init.normal_(weight, 0, math.sqrt((2.0 / (((n * k1) * k2) * branches)))) nn.init.constant_(conv.bias, 0)
def conv_init(conv): nn.init.kaiming_normal_(conv.weight, mode='fan_out') nn.init.constant_(conv.bias, 0)
def bn_init(bn, scale): nn.init.constant_(bn.weight, scale) nn.init.constant_(bn.bias, 0)
class unit_tcn(nn.Module): def __init__(self, in_channels, out_channels, kernel_size=9, stride=1): super(unit_tcn, self).__init__() pad = int(((kernel_size - 1) / 2)) self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=(kernel_size, 1), padding=(pad, 0), stride=(stride, 1)) ...
class unit_gcn(nn.Module): def __init__(self, in_channels, out_channels, A, coff_embedding=4, num_subset=3): super(unit_gcn, self).__init__() inter_channels = (out_channels // coff_embedding) self.inter_c = inter_channels self.PA = nn.Parameter(torch.from_numpy(A.astype(np.float32...
class TCN_GCN_unit(nn.Module): def __init__(self, in_channels, out_channels, A, stride=1, residual=True): super(TCN_GCN_unit, self).__init__() self.gcn1 = unit_gcn(in_channels, out_channels, A) self.tcn1 = unit_tcn(out_channels, out_channels, stride=stride) self.relu = nn.ReLU() ...
class SceneGraphSkeleton(nn.Module): def __init__(self, num_attribute_concepts, num_output_vocab, include_fully_connected=True, num_class=224, num_point=22, num_person=1, graph_args=dict(), in_channels=3): super(SceneGraphSkeleton, self).__init__() self.graph = AGCNGraph(**graph_args) A =...
def run_gpt(questions, prompts, temperature: float=1.0, use_user_message: bool=False): query_str = '\n'.join(['<text>{}</text>'.format(q) for q in questions]) response = None for i in range(10): try: response = openai.ChatCompletion.create(model='gpt-3.5-turbo', messages=[{'role': ('us...
def fix_parentheses(string): stack = list() output_string = '' for i in range(len(string)): if (string[i] == '('): stack.append(i) output_string += string[i] elif (string[i] == ')'): if (len(stack) == 0): pass else: ...
def extract_from_gpt(results_str, expected_batch_size: int): results = [] for result_str in results_str.split('<code>')[1:]: result_str = result_str.split('</code>')[0] result_str = result_str.strip() if result_str.startswith('describe('): result_str = re.sub('describe\\(([...
def main(): parser = jacinle.JacArgumentParser() parser.add_argument('--dataset', type=str, default='clevr', choices=['clevr', 'referit']) parser.add_argument('--questions', type=str, required=True) parser.add_argument('--output', type=str, required=True) parser.add_argument('--prompt', type=str, ...
def run_gpt(questions, prompts): query_str = '\n'.join(['<text>{}</text>'.format(q) for q in questions]) while True: try: response = openai.ChatCompletion.create(model='gpt-4', temperature=0.7, messages=[{'role': 'system', 'content': prompts['system']}, {'role': 'user', 'content': (prompts...
def fix_parentheses(string): stack = list() output_string = '' for i in range(len(string)): if (string[i] == '('): stack.append(i) output_string += string[i] elif (string[i] == ')'): if (len(stack) == 0): pass else: ...
def main(): parser = jacinle.JacArgumentParser() parser.add_argument('--dataset', type=str, default='clevr', choices=['clevr-rpms', 'clevr-puzzles', 'clevr-refexps', 'referit']) parser.add_argument('--questions', type=str, required=True) parser.add_argument('--output', type=str, required=True) par...
def main(args): questions = jacinle.load(args.input)['questions'] output = dict() for q in questions: question_str = q['question'] program = q['program'] fol_program_str = transform(program) output[question_str] = fol_program_str print(question_str) print(fo...
@dataclass class QueryXProgram(object): full_program: str object_program: str
def get_op_type(op): if ('type' in op): return op['type'] return op['function']
def transform(program): index_to_result = dict() variable_counter = 0 for (i, op) in enumerate(program): op_type = get_op_type(op) if (op_type == 'scene'): variable_counter += 1 index_to_result[i] = ('', f'x{variable_counter}') elif (op_type in ('filter_size...
def filter(scene, name, input_): if (name == 'object'): return input_ attribute = g_concept2attribute[name] return {i for i in input_ if (scene['objects'][i][attribute] == name)}
def multi_filter(scene, names, input_=None): if (input_ is None): input_ = range(len(scene['objects'])) for name in names.split(): input_ = filter(scene, name, input_) return input_
def relate(scene, name, input_): if (len(input_) != 1): raise ValueError() input_ = list(input_)[0] return set(scene['relationships'][name][input_])
def execute(scene, slot_dict): objs_for_i = dict() for i in range(1, (4 + 1)): objs_for_i[i] = multi_filter(scene, slot_dict[f'OBJ{i}']) for objs in itertools.product(objs_for_i[1], objs_for_i[2], objs_for_i[3], objs_for_i[4]): succ = True for rel_i in range(5): if (f'R...
def gen_all_filter_ops(): for x in itertools.product((g_attribute_concepts['size'] + ['']), (g_attribute_concepts['color'] + ['']), (g_attribute_concepts['material'] + ['']), (g_attribute_concepts['shape'] + ['object'])): (yield ' '.join((x for x in x if x)))
def gen_all_relate_ops(): return ['left', 'right', 'front', 'behind']
def check_filter_unique(scene, x): input_ = range(len(scene['objects'])) return (len(multi_filter(scene, x, input_)) == 1)
def gen_filter_string(f, vname): return ' and '.join([f'{method}({vname})' for method in f.split() if (method != 'object')])
def get_possible_relations(scene, x, y): return [r for r in g_all_relate_ops if (x in scene['relationships'][r][y])]
def gen(scene, nr_objects, nr_relations, make_wrong=False): if (len(scene['objects']) < 8): return None object_to_nonunique = defaultdict(list) for f in g_all_filter_ops: objects = multi_filter(scene, f) if (len(objects) > 1): for obj in objects: object_...
def gen_sentence_and_program(slot_dict): fmt = 'Can you find four objects from the image such that: ' constraints = list() program_parts = list() for i in range(1, (4 + 1)): d = slot_dict[f'OBJ{i}'] if (d[0] in 'aeoiu'): constraints.append(f'object {i} is an {d}') e...
def main(): scenes = jacinle.load_json(args.scenes_json)['scenes'] puzzles = list() for (scene_index, scene) in enumerate(jacinle.tqdm(scenes)): if (len(puzzles) == 100): break wrong = bool(random.choice(range(2))) desired_answer = (not wrong) sol = gen(scene, 4...
def filter(scene, name, input_): if (name == 'object'): return input_ attribute = g_concept2attribute[name] return {i for i in input_ if (scene['objects'][i][attribute] == name)}
def multi_filter(scene, names, input_): for name in names.split(): input_ = filter(scene, name, input_) return input_
def relate(scene, name, input_): if (len(input_) != 1): raise ValueError() input_ = list(input_)[0] return set(scene['relationships'][name][input_])
def execute(scene, program, template_slots): stack = list() for token in program.split(): if (token == 'S'): stack.append(set(range(len(scene['objects'])))) elif (token == 'AND'): stack.append((stack.pop() & stack.pop())) elif token.startswith('OBJ'): ...
def gen_all_filter_ops(): for x in itertools.product((g_attribute_concepts['size'] + ['']), (g_attribute_concepts['color'] + ['']), (g_attribute_concepts['material'] + ['']), (g_attribute_concepts['shape'] + ['object'])): (yield ' '.join((x for x in x if x)))
def gen_all_relate_ops(): return ['left', 'right', 'front', 'behind']
def check_filter_unique(scene, x): input_ = range(len(scene['objects'])) return (len(multi_filter(scene, x, input_)) == 1)
def gen_filter_string(f, vname): return ' and '.join([f'{method}({vname})' for method in f.split()])
def ground_program1(scene, unique_filters): program = 'S OBJ1' sentence_for_x = {} for f in unique_filters: slot_dict = {'OBJ1': f} try: obj = execute(scene, program, slot_dict) except ValueError: continue template = random.choice(g_templates_1) ...
def ground_program2(scene, unique_filters): program = 'S OBJ2 R1 OBJ1' program1 = ground_program1(scene, unique_filters) sentence_for_x = {} for (_, _, _, slot_dict1, obj2) in program1: for f in g_all_filter_ops: for r in g_all_relate_ops: slot_dict = {'OBJ1': f, 'O...
def ground_program3(scene, unique_filters): program = 'S OBJ3 R2 S OBJ2 R1 AND OBJ1' program1 = ground_program1(scene, unique_filters) sentence_for_x = {} for (_, _, _, slot_dict1, obj2) in program1: for (_, _, _, slot_dict2, obj3) in program1: if (obj2 == obj3): co...
def ground_program4(scene, unique_filters): program = 'S OBJ3 R2 S OBJ2 R1 OBJ1' program2 = ground_program2(scene, unique_filters) sentence_for_x = {} for (_, _, _, slot_dict2, obj2) in program2: for f in g_all_filter_ops: for r1 in g_all_relate_ops: slot_dict = {'O...
def random_sample_and_post(scene): unique_filters = [f for f in g_all_filter_ops if check_filter_unique(scene, f)] cat = (random.choice(range(4)) + 1) func = globals()[f'ground_program{cat}'] for i in range(4): sols = list(func(scene, unique_filters)) if (len(sols) == 0): c...
def main(): scenes = jacinle.load_json(args.scenes_json)['scenes'] refexps = list() for (scene_index, scene) in enumerate(jacinle.tqdm(scenes[:150])): rv = random_sample_and_post(scene) if (rv is None): continue (sentence, program, slot_program, slot_dict, obj) = rv ...
def filter(scene, name, input_): if (name == 'object'): return input_ attribute = g_concept2attribute[name] return {i for i in input_ if (scene['objects'][i][attribute] == name)}
def multi_filter(scene, names, input_): for name in names.split(): input_ = filter(scene, name, input_) return input_
def gen_description(rule1_cat, d1, rule2_cat, d2): cat_order = ['size', 'color', 'material', 'shape'] if (cat_order.index(rule1_cat) > cat_order.index(rule2_cat)): (rule1_cat, rule2_cat) = (rule2_cat, rule1_cat) (d1, d2) = (d2, d1) d = ((d1 + ' ') + d2) if (rule2_cat != 'shape'): ...
def main(): scenes = jacinle.load_json(args.scenes_json)['scenes'] def find_scene_matching(name, answer): for i in range(1000): scene_index = random.randint(0, (len(scenes) - 1)) scene = scenes[scene_index] res = multi_filter(scene, name, range(len(scene['objects']...
def main(): dataset = globals()[g_dataset_loaders[args.dataset]](args.data_dir) print('Dataset statistics:') print(' Length:', len(dataset)) print('Dataset examples:') jacinle.stprint(dataset[0], 'dataset[0]', max_depth=1) from IPython import embed embed()
def load_CLEVR(data_dir: str): from concepts.benchmark.clevr.dataset import make_dataset return make_dataset(scenes_json=osp.join(args.data_dir, 'scenes.json'), questions_json=osp.join(args.data_dir, 'questions.json'), image_root=osp.join(args.data_dir, 'images'), vocab_json=osp.join(args.data_dir, 'vocab.jso...
@dataclass class FunctionGroupSummary(object): signature: str count: int = 0 examples: dict = field(default_factory=dict)
def main(): domain = create_bare_domain() parser = create_default_parser(domain) all_codes = io.load_pkl(args.parsed_filename) all_rows = list() all_function_groups: dict[(str, FunctionGroupSummary)] = dict() all_types: dict[(str, list)] = dict() for (prompt, codes) in jacinle.tqdm_gofor(a...
def get_function_signature(function): argument_types = tuple((x.typename for x in function.ftype.argument_types)) return_type = function.ftype.return_type.typename return f'{argument_types} -> {return_type}'
def main(): domain = make_domain(args.parsed_filename) domain.print_summary() print('Summary:') print(' - # of types: {}'.format(len(domain.types))) print(' - # of functions: {}'.format(len(domain.functions))) function_groups = dict() for function in domain.functions.values(): ar...
@dataclass class FunctionGroupSummary(object): signature: str count: int = 0 examples: dict[(str, list[dict])] = field(default_factory=dict)
def main(): domain = create_bare_domain() parser = create_default_parser(domain) all_codes = io.load_pkl(args.parsed_filename) for (prompts, codes) in jacinle.tqdm_gofor(all_codes): for code in codes: try: _ = parser.parse_expression(code) except Excepti...
def main2(): domain = create_bare_domain() parser = create_default_parser(domain) if args.parsed_filename.endswith('.json'): all_codes = io.load_json(args.parsed_filename) else: all_codes = io.load_pkl(args.parsed_filename) expressions = list() for (prompt, codes) in jacinle.tq...
def prune_domain(old_domain: FunctionDomain) -> FunctionDomain: new_domain = create_bare_domain() for (name, function) in old_domain.functions.items(): if (name in new_domain.functions): continue print('Checking function: {} {}'.format(name, function)) ftype = function.ftyp...
def check_expr_validity(expression: E.Expression): if isinstance(expression, E.GeneralizedQuantificationExpression): if (expression.quantification_op in ('describe', 'count')): pass else: raise ValueError('Invalid quantification op: {}'.format(expression.quantification_op))...
def main(): if (not args.debug): args.dump_dir = ensure_path(osp.join('dumps', args.series_name, args.desc_name, args.expr, args.run_name)) args.ckpt_dir = ensure_path(osp.join(args.dump_dir, 'checkpoints')) args.vis_dir = ensure_path(osp.join(args.dump_dir, 'visualizations')) args...
def get_curriculum_dataset(epoch, train_dataset, validation_dataset): for (si, s) in enumerate(g_curriculum_strategy): if (g_curriculum_strategy[si][0] < epoch <= g_curriculum_strategy[(si + 1)][0]): (max_scene_size, max_program_size) = s[1:] if (args.curriculum in ('scene', 'all')...
def train_epoch(epoch, trainer, train_dataloader, meters): nr_iters = args.iters_per_epoch if (nr_iters == 0): nr_iters = len(train_dataloader) meters.update(epoch=epoch) trainer.trigger_event('epoch:before', trainer, epoch) train_iter = iter(train_dataloader) end = time.time() wit...
@jactorch.no_grad_func def validate_epoch(epoch, trainer, val_dataloader, meters): end = time.time() run_visualizer = False if (args.evaluate and (not args.debug)): run_visualizer = True import matplotlib.pyplot as plt from PIL import Image from jaclearn.visualize.html_table import HTM...
def update_meters(meters, monitors, prefix: str=None): for k in list(monitors.keys()): if ((k + '/n') in monitors): meters.update({k: monitors[k]}, n=monitors[(k + '/n')], prefix=prefix) del monitors[k] del monitors[(k + '/n')] meters.update(monitors, prefix=prefix)...
@jactorch.no_grad_func def validate_epoch_custom(epoch, trainer, val_dataloader, meters): end = time.time() run_visualizer = False if (args.evaluate and (not args.debug)): run_visualizer = True if (args.validation_visualize is False): run_visualizer = False import matplotlib.pyplot...
def main(): if (not args.debug): args.dump_dir = ensure_path(osp.join('dumps', args.series_name, args.desc_name, args.expr, args.run_name)) args.ckpt_dir = ensure_path(osp.join(args.dump_dir, 'checkpoints')) args.vis_dir = ensure_path(osp.join(args.dump_dir, 'visualizations')) args...
def train_epoch(epoch, trainer, train_dataloader, meters, output_vocab): nr_iters = args.iters_per_epoch if (nr_iters == 0): nr_iters = len(train_dataloader) meters.update(epoch=epoch) trainer.trigger_event('epoch:before', trainer, epoch) train_iter = iter(train_dataloader) end = time....
def validate_epoch(epoch, trainer, val_dataloader, meters, output_vocab): if (not args.debug): from jaclearn.visualize.html_table import HTMLTableVisualizer, HTMLTableColumnDesc vis = HTMLTableVisualizer(osp.join(args.vis_dir, f'episode_{epoch}'), f'Left @ Epoch {epoch}') link = '<a href="...
def main(): if (not args.debug): args.dump_dir = ensure_path(osp.join('dumps', args.series_name, args.desc_name, args.expr, args.run_name)) args.ckpt_dir = ensure_path(osp.join(args.dump_dir, 'checkpoints')) args.vis_dir = ensure_path(osp.join(args.dump_dir, 'visualizations')) args...
def train_epoch(epoch, trainer, train_dataloader, meters, all_scans_in_dict): nr_iters = args.iters_per_epoch if (nr_iters == 0): nr_iters = len(train_dataloader) meters.update(epoch=epoch) trainer.trigger_event('epoch:before', trainer, epoch) train_iter = iter(train_dataloader) end = ...
def decode_stimulus_string(s): '\n Split into scene_id, instance_label, # objects, target object id,\n distractors object id.\n :param s: the stimulus string\n ' if (len(s.split('-', maxsplit=4)) == 4): (scene_id, instance_label, n_objects, target_id) = s.split('-', maxsplit=4) dis...
def validate_epoch(epoch, trainer, val_dataloader, meters, all_scans_in_dict): if (not args.debug): from jaclearn.visualize.html_table import HTMLTableVisualizer, HTMLTableColumnDesc vis = HTMLTableVisualizer(osp.join(args.vis_dir, f'episode_{epoch}'), f'Left @ Epoch {epoch}') link = '<a h...
def test(): print('Loading toy dataset from JSON...') loader = DatasetLoader() gtDataset = loader.read_json('data/toydata/gt.json') print('>> {}'.format(gtDataset.phrases)) gtBoxList = gtDataset.boxes print('Loading toy predictions from JSON...') predDataset = loader.read_json('data/toydat...
class Dataset(object): ' A class for representing a Dataset\n\t' def __init__(self): self._instances = [] def add_instance(self, propertyDict): ' Append an instance to the dataset.\n\t\t\n\t\tParameters\n\t\t----------\n\t\tpropertyDict : dict\n\t\t\ta dictionary containing the following...
class DatasetLoader(): ' Utility/factory class to load a Dataset object from a preformatted text or json file\n\t' def __init__(self): pass def read_text(self, filePath): ' Loads a Dataset object from a text file.\n\t\t\n\t\tParameters\n\t\t----------\n\t\tfilePath : str\n\t\t\tPath to t...
class Evaluator(object): ' Utility class for evaluating phrase localization\n\t' def __init__(self): pass def compute_iou(self, predictedBoxList, gtBoxList): ' Computes list of areas of IoU for all given instances.\n\n\t\tParameters\n\t\t----------\n\t\tpredictedBoxList : list\n\t\t\t[[x...
def test(): ' Toy example for testing the evaluation script\n\t' queryList = ['my first phrase', 'my second phrase'] imageList = ['0001.jpg', '0002.jpg'] gtBoxList = [[1, 1, 30, 30], [50, 50, 100, 200]] iouThreshold = 0.5 predictedBoxList = [[31, 31, 30, 30], [50, 50, 100, 200]] evaluator ...
def get_dataset(name: str) -> pd.DataFrame: 'Load a processed dataset based on a name' return pd.read_csv(f'data/processed/{name}/data.csv').dropna()
def preprocess_enron() -> None: 'Clean and rename the dataset and save it in data/processed' Path('data/raw/enron').mkdir(parents=True, exist_ok=True) Path('data/processed/enron').mkdir(parents=True, exist_ok=True) url = 'https://github.com/MWiechmann/enron_spam_data/raw/master/enron_spam_data.zip' ...
def preprocess_ling() -> None: 'Clean and rename the dataset and save it in data/processed' Path('data/raw/ling').mkdir(parents=True, exist_ok=True) Path('data/processed/ling').mkdir(parents=True, exist_ok=True) url = 'https://github.com/oreilly-japan/ml-security-jp/raw/master/ch02/lingspam_public.tar...
def preprocess_sms() -> None: 'Clean and rename the dataset and save it in data/processed' Path('data/raw/sms').mkdir(parents=True, exist_ok=True) Path('data/processed/sms').mkdir(parents=True, exist_ok=True) url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/00228/smsspamcollection.zip'...
def preprocess_spamassassin() -> None: 'Clean and rename the dataset and save it in data/processed' Path('data/raw/spamassassin').mkdir(parents=True, exist_ok=True) Path('data/processed/spamassassin').mkdir(parents=True, exist_ok=True) urls = ['https://spamassassin.apache.org/old/publiccorpus/20030228...