mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +00:00
Remove pandas from HyperParameter optimizer requirements
This commit is contained in:
parent
189a2b54de
commit
1b3574a7ca
@ -18,14 +18,6 @@ from ..task import Task
|
|||||||
logger = getLogger('clearml.automation.optimization')
|
logger = getLogger('clearml.automation.optimization')
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
import pandas as pd
|
|
||||||
Task.add_requirements('pandas')
|
|
||||||
except ImportError:
|
|
||||||
pd = None
|
|
||||||
logger.warning('Pandas is not installed, summary table reporting will be skipped.')
|
|
||||||
|
|
||||||
|
|
||||||
class Objective(object):
|
class Objective(object):
|
||||||
"""
|
"""
|
||||||
Optimization ``Objective`` class to maximize / minimize over all experiments. This class will sample a specific
|
Optimization ``Objective`` class to maximize / minimize over all experiments. This class will sample a specific
|
||||||
@ -586,7 +578,7 @@ class SearchStrategy(object):
|
|||||||
Set the optimizer task object to be used to store/generate reports on the optimization process.
|
Set the optimizer task object to be used to store/generate reports on the optimization process.
|
||||||
Usually this is the current task of this process.
|
Usually this is the current task of this process.
|
||||||
|
|
||||||
:param Task task: The optimizer's current Task.
|
:param Task task: The optimizer`s current Task.
|
||||||
"""
|
"""
|
||||||
self._optimizer_task = task
|
self._optimizer_task = task
|
||||||
|
|
||||||
@ -656,9 +648,12 @@ class SearchStrategy(object):
|
|||||||
:param dict additional_filters: The additional task filters.
|
:param dict additional_filters: The additional task filters.
|
||||||
:return: A list of Task objects
|
:return: A list of Task objects
|
||||||
"""
|
"""
|
||||||
task_filter = {'parent': parent_task_id,
|
task_filter = {
|
||||||
# 'tags': [cls._tag],
|
'parent': parent_task_id,
|
||||||
'system_tags': ['-archived']}
|
# 'tags': [cls._tag],
|
||||||
|
# since we have auto archive we do not want to filter out archived tasks
|
||||||
|
# 'system_tags': ['-archived'],
|
||||||
|
}
|
||||||
task_filter.update(additional_filters or {})
|
task_filter.update(additional_filters or {})
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
@ -1453,20 +1448,23 @@ class HyperParameterOptimizer(object):
|
|||||||
mode='markers', xaxis='job #', yaxis='objective')
|
mode='markers', xaxis='job #', yaxis='objective')
|
||||||
|
|
||||||
# update summary table
|
# update summary table
|
||||||
if pd:
|
job_ids = list(completed_jobs.keys())
|
||||||
index = list(completed_jobs.keys())
|
job_ids_sorted_by_objective = sorted(
|
||||||
table = {'objective': [completed_jobs[i][0] for i in index],
|
job_ids, key=lambda x: completed_jobs[x][0], reverse=bool(self.objective_metric.sign >= 0))
|
||||||
'iteration': [completed_jobs[i][1] for i in index]}
|
# sort the columns except for 'objective', 'iteration'
|
||||||
columns = set([c for k, v in completed_jobs.items() for c in v[2].keys()])
|
columns = list(sorted(set([c for k, v in completed_jobs.items() for c in v[2].keys()])))
|
||||||
for c in sorted(columns):
|
# add the index column (task id) and the first two columns 'objective', 'iteration' then the rest
|
||||||
table.update({c: [completed_jobs[i][2].get(c, '') for i in index]})
|
table_values = [['task id', 'objective', 'iteration'] + columns]
|
||||||
|
|
||||||
df = pd.DataFrame(table, index=index)
|
table_values += \
|
||||||
df.sort_values(by='objective', ascending=bool(self.objective_metric.sign < 0), inplace=True)
|
[([job, completed_jobs[job][0], completed_jobs[job][1]] +
|
||||||
df.index.name = 'task id'
|
[completed_jobs[job][2].get(c, '') for c in columns]) for job in job_ids_sorted_by_objective]
|
||||||
task_logger.report_table(
|
task_logger.report_table(
|
||||||
"summary", "job", 0, table_plot=df,
|
"summary", "job", 0, table_plot=table_values,
|
||||||
extra_layout={"title": "objective: {}".format(title)})
|
extra_layout={"title": "objective: {}".format(title)})
|
||||||
|
# upload summary as artifact
|
||||||
|
if force:
|
||||||
|
self._task.upload_artifact(name='summary', artifact_object={'table': table_values})
|
||||||
|
|
||||||
def _report_remaining_budget(self, task_logger, counter):
|
def _report_remaining_budget(self, task_logger, counter):
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
|
Loading…
Reference in New Issue
Block a user