Skip to content
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a684ac4
work in progress
ravinkohli Feb 8, 2021
a6a8471
in progress
ravinkohli Feb 8, 2021
2b0c0e0
Working network embedding
ravinkohli Feb 15, 2021
9be86a5
ADD tests for network embedding
ravinkohli Feb 15, 2021
1adc9a4
Removed ordinal encoder
ravinkohli Feb 15, 2021
ae6bb44
Removed ordinal encoder
ravinkohli Feb 15, 2021
8783240
Add seed for test_losses for reproducibility
ravinkohli Feb 15, 2021
761fb75
Addressed comments
ravinkohli Feb 17, 2021
1e1a7e9
Fix merge conflicts
ravinkohli Feb 22, 2021
4bcbd88
fix flake
ravinkohli Feb 22, 2021
adcfc75
Merge refactor_development
ravinkohli Feb 23, 2021
d6d3dcd
Merge branch 'ravinkohli-embedding_layer' into embedding_layer
ravinkohli Feb 23, 2021
aa83d6d
fix test import training
ravinkohli Feb 23, 2021
cbc7e09
ADD_109
franchuterivera Feb 23, 2021
9dd447f
No print allow
franchuterivera Feb 23, 2021
20a874f
Fix tests and move to boston
ravinkohli Feb 23, 2021
7eed312
Debug issue with python 3.6
ravinkohli Feb 25, 2021
cb3b398
Debug for python3.6
ravinkohli Feb 26, 2021
007be7d
Run only debug file
ravinkohli Feb 26, 2021
d406b2a
Merge branch 'embedding_layer' of https://github.com/ravinkohli/Auto-…
ravinkohli Feb 26, 2021
b1e25d2
work in progress
ravinkohli Feb 8, 2021
f41eae1
in progress
ravinkohli Feb 8, 2021
6222399
Working network embedding
ravinkohli Feb 15, 2021
b96e32a
ADD tests for network embedding
ravinkohli Feb 15, 2021
ece6353
Removed ordinal encoder
ravinkohli Feb 15, 2021
70b0a79
Removed ordinal encoder
ravinkohli Feb 15, 2021
48d7a85
Addressed comments
ravinkohli Feb 17, 2021
a92fcaf
fix flake
ravinkohli Feb 22, 2021
a11ee8e
fix test import training
ravinkohli Feb 23, 2021
789bd8d
Fix tests and move to boston
ravinkohli Feb 23, 2021
85e178f
Debug issue with python 3.6
ravinkohli Feb 25, 2021
ddf198b
Run only debug file
ravinkohli Feb 26, 2021
a073f06
Debug for python3.6
ravinkohli Feb 26, 2021
e4599e9
Merge from origin
ravinkohli Feb 26, 2021
e625ee7
print paths of parent dir
ravinkohli Feb 26, 2021
9164bc2
Trying to run examples
ravinkohli Feb 26, 2021
f1beb14
Trying to run examples
ravinkohli Feb 27, 2021
af17afc
Add success model
ravinkohli Mar 1, 2021
d64e4fd
Added parent directory for printing paths
ravinkohli Mar 1, 2021
1602933
Try no autouse
franchuterivera Mar 1, 2021
c8d98ba
print log file to see if backend is saving num run
ravinkohli Mar 1, 2021
76fcd76
Setup logger in backend
ravinkohli Mar 1, 2021
ffc1620
handle nans in categorical columns (#118)
ravinkohli Mar 1, 2021
55ec853
Merge pull request #112 from franchuterivera/refactor_development_ADD…
ravinkohli Mar 1, 2021
3f39f58
try without embeddings
ravinkohli Mar 1, 2021
715d277
work in progress
ravinkohli Feb 8, 2021
d68a391
in progress
ravinkohli Feb 8, 2021
02dc064
Working network embedding
ravinkohli Feb 15, 2021
37cd8c5
ADD tests for network embedding
ravinkohli Feb 15, 2021
a3c1625
Removed ordinal encoder
ravinkohli Feb 15, 2021
b8896ad
Removed ordinal encoder
ravinkohli Feb 15, 2021
e0bfb0b
Addressed comments
ravinkohli Feb 17, 2021
23f6777
fix flake
ravinkohli Feb 22, 2021
4c1f33f
fix test import training
ravinkohli Feb 23, 2021
8c4233c
Fix tests and move to boston
ravinkohli Feb 23, 2021
18b5771
Debug issue with python 3.6
ravinkohli Feb 25, 2021
d839b5d
Run only debug file
ravinkohli Feb 26, 2021
de1d4c3
Debug for python3.6
ravinkohli Feb 26, 2021
e0a488a
work in progress
ravinkohli Feb 8, 2021
7368908
in progress
ravinkohli Feb 8, 2021
00789ac
Working network embedding
ravinkohli Feb 15, 2021
6a02fe4
ADD tests for network embedding
ravinkohli Feb 15, 2021
3f7c2cc
print paths of parent dir
ravinkohli Feb 26, 2021
f765347
Trying to run examples
ravinkohli Feb 26, 2021
6ad8550
Trying to run examples
ravinkohli Feb 27, 2021
011c0ef
Add success model
ravinkohli Mar 1, 2021
1efc39a
Added parent directory for printing paths
ravinkohli Mar 1, 2021
3d54db8
print log file to see if backend is saving num run
ravinkohli Mar 1, 2021
6c5e8be
Setup logger in backend
ravinkohli Mar 1, 2021
8734384
try without embeddings
ravinkohli Mar 1, 2021
8941c95
no embedding for python 3.6
ravinkohli Mar 2, 2021
6de97e1
merge
ravinkohli Mar 2, 2021
5aec1e1
Deleted debug example
ravinkohli Mar 2, 2021
36ae93c
Fix test for evaluation
ravinkohli Mar 2, 2021
c9ef56e
Deleted utils file
ravinkohli Mar 4, 2021
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
150 changes: 150 additions & 0 deletions examples/example_tmp_for_debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
"""
Example file to be deleted
"""
import os

import sklearn.datasets

from autoPyTorch.api.tabular_classification import TabularClassificationTask
from autoPyTorch.datasets.resampling_strategy import (
CrossValTypes,
)

from pathlib import Path


class DisplayablePath(object):
display_filename_prefix_middle = '├──'
display_filename_prefix_last = '└──'
display_parent_prefix_middle = ' '
display_parent_prefix_last = '│ '

def __init__(self, path, parent_path, is_last):
self.path = Path(str(path))
self.parent = parent_path
self.is_last = is_last
if self.parent:
self.depth = self.parent.depth + 1
else:
self.depth = 0

@property
def displayname(self):
if self.path.is_dir():
return self.path.name + '/'
return self.path.name

@classmethod
def make_tree(cls, root, parent=None, is_last=False, criteria=None):
root = Path(str(root))
criteria = criteria or cls._default_criteria

displayable_root = cls(root, parent, is_last)
yield displayable_root

children = sorted(list(path
for path in root.iterdir()
if criteria(path)),
key=lambda s: str(s).lower())
count = 1
for path in children:
is_last = count == len(children)
if path.is_dir():
yield from cls.make_tree(path,
parent=displayable_root,
is_last=is_last,
criteria=criteria)
else:
yield cls(path, displayable_root, is_last)
count += 1

@classmethod
def _default_criteria(cls, path):
return True

@property
def displayname(self):
if self.path.is_dir():
return self.path.name + '/'
return self.path.name

def displayable(self):
if self.parent is None:
return self.displayname

_filename_prefix = (self.display_filename_prefix_last
if self.is_last
else self.display_filename_prefix_middle)

parts = ['{!s} {!s}'.format(_filename_prefix,
self.displayname)]

parent = self.parent
while parent and parent.parent is not None:
parts.append(self.display_parent_prefix_middle
if parent.is_last
else self.display_parent_prefix_last)
parent = parent.parent

return ''.join(reversed(parts))


openml_id = 40981
resampling_strategy = CrossValTypes.k_fold_cross_validation
X, y = sklearn.datasets.fetch_openml(
data_id=int(openml_id),
return_X_y=True, as_frame=True
)
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(
X, y, random_state=1)


if __name__ == '__main__':
# Search for a good configuration
estimator = TabularClassificationTask(
temporary_directory='./tmp',
delete_tmp_folder_after_terminate=False,
resampling_strategy=resampling_strategy,
)

estimator.search(
X_train=X_train, y_train=y_train,
X_test=X_test, y_test=y_test,
optimize_metric='accuracy',
total_walltime_limit=150,
func_eval_time_limit=50,
traditional_per_total_budget=0
)

# Search for an existing run key in disc. A individual model might have
# a timeout and hence was not written to disc
for i, (run_key, value) in enumerate(estimator.run_history.data.items()):
if i == 0:
# Ignore dummy run
continue
if 'SUCCESS' not in str(value.status):
continue

run_key_model_run_dir = estimator._backend.get_numrun_directory(
estimator.seed, run_key.config_id, run_key.budget)
if os.path.exists(run_key_model_run_dir):
break

model_file = os.path.join(
run_key_model_run_dir,
f"{estimator.seed}.{run_key.config_id}.{run_key.budget}.cv_model"
)

print(model_file)

paths = DisplayablePath.make_tree(os.path.dirname(run_key_model_run_dir))
for path in paths:
print(path.displayable())

# printing log file
tmp_dir = estimator._backend.temporary_directory
log_file = os.path.join(tmp_dir, "AutoPyTorch:{}:{}.log".format(estimator.dataset_name, estimator.seed))
f = open(log_file, 'r')
lines = f.readlines()
for line in lines:
print(line)
2 changes: 1 addition & 1 deletion test/test_pipeline/components/setup/test_setup_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def embedding(request):
'classification_categorical_only',
'classification_numerical_and_categorical'], indirect=True)
class TestNetworks:
def test_pipeline_fit(self, fit_dictionary_tabular, backbone, head):
def test_pipeline_fit(self, fit_dictionary_tabular, embedding, backbone, head):
"""This test makes sure that the pipeline is able to fit
every combination of network embedding, backbone, head"""

Expand Down
71 changes: 71 additions & 0 deletions test/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from pathlib import Path


class DisplayablePath(object):
display_filename_prefix_middle = '├──'
display_filename_prefix_last = '└──'
display_parent_prefix_middle = ' '
display_parent_prefix_last = '│ '

def __init__(self, path, parent_path, is_last):
self.path = Path(str(path))
self.parent = parent_path
self.is_last = is_last
if self.parent:
self.depth = self.parent.depth + 1
else:
self.depth = 0

@property
def displayname(self):
if self.path.is_dir():
return self.path.name + '/'
return self.path.name

@classmethod
def make_tree(cls, root, parent=None, is_last=False, criteria=None):
root = Path(str(root))
criteria = criteria or cls._default_criteria

displayable_root = cls(root, parent, is_last)
yield displayable_root

children = sorted(list(path
for path in root.iterdir()
if criteria(path)),
key=lambda s: str(s).lower())
count = 1
for path in children:
is_last = count == len(children)
if path.is_dir():
yield from cls.make_tree(path,
parent=displayable_root,
is_last=is_last,
criteria=criteria)
else:
yield cls(path, displayable_root, is_last)
count += 1

@classmethod
def _default_criteria(cls, path):
return True

def displayable(self):
if self.parent is None:
return self.displayname

_filename_prefix = (self.display_filename_prefix_last
if self.is_last
else self.display_filename_prefix_middle)

parts = ['{!s} {!s}'.format(_filename_prefix,
self.displayname)]

parent = self.parent
while parent and parent.parent is not None:
parts.append(self.display_parent_prefix_middle
if parent.is_last
else self.display_parent_prefix_last)
parent = parent.parent

return ''.join(reversed(parts))