MCPcopy Create free account
hub / github.com/catboost/catboost / MetricVisualizer

Class MetricVisualizer

catboost/python-package/catboost/widget/ipythonwidget.py:24–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23
24class MetricVisualizer(MetricWidget):
25 def __init__(self, train_dirs, subdirs=False):
26 super(self.__class__, self).__init__()
27 if isinstance(train_dirs, str):
28 train_dirs = [train_dirs]
29 if subdirs:
30 train_subdirs = []
31 for train_dir in train_dirs:
32 train_subdirs.extend(self._get_subdirectories(train_dir))
33 train_dirs = train_subdirs
34 self._train_dirs = train_dirs[:]
35 self._names = []
36 curdir = os.path.abspath(os.path.curdir)
37 for train_dir in train_dirs:
38 abspath = os.path.abspath(train_dir)
39 self._names.append(os.path.basename(abspath) if abspath != curdir else 'current')
40 self._need_to_stop = Event()
41 self._update_after_stop_signal = False
42
43 def start(self):
44 display(self)
45 self._update_data()
46 while not self._need_to_stop.wait(1.0):
47 self._update_data()
48
49 if self._update_after_stop_signal:
50 self._update_data()
51
52 def _run_update(self):
53 self.thread = Thread(target=self.start, args=())
54 self.thread.start()
55
56 def _stop_update(self):
57 self._update_after_stop_signal = True
58 self._need_to_stop.set()
59 self.thread.join()
60
61 def _get_subdirectories(self, a_dir):
62 return [os.path.join(a_dir, name) for name in os.listdir(a_dir) if os.path.isdir(os.path.join(a_dir, name))]
63
64 def _update_data(self):
65 data = {}
66 dirs = [{'name': name, 'path': path} for name, path in zip(self._names, self._train_dirs)]
67
68 all_completed = True
69 for dir_info in dirs:
70 path = dir_info.get('path')
71 content = self._update_data_from_dir(path)
72
73 if not content:
74 continue
75
76 data[path] = {
77 'path': path,
78 'name': dir_info.get('name'),
79 'content': content
80 }
81

Callers 2

_get_catboost_widgetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected