python/methylnet/hyperparameter_scans.py
def find_top_jobs(hyperparameter_input_csv,hyperparameter_output_log, n_top_jobs, crossover_p=0, val_loss_column='min_val_loss'):
	"""Finds top performing jobs from hyper parameter scan to rerun and cross-over parameters.

	Parameters
	----------
	hyperparameter_input_csv : str
		CSV file containing hyperparameter inputs.
	hyperparameter_output_log : str
		CSV file containing prior runs.
	n_top_jobs : int
		Number of top jobs to select
	crossover_p : float
		Rate of cross over of reused hyperparameters
	val_loss_column : str
		Loss column used to select top jobs

	Returns
	-------
	list
		List of list of new parameters for jobs to run.

	"""

	custom_jobs = pd.read_csv(hyperparameter_input_csv)
	hyperparam_output = pd.read_csv(hyperparameter_output_log)[['job_name',val_loss_column]]
	best_outputs = hyperparam_output.sort_values(val_loss_column,ascending=True).iloc[:n_top_jobs,:]
	custom_jobs = custom_jobs[np.isin(custom_jobs['--job_name'].values,best_outputs['job_name'].values)]
	if custom_jobs.shape[0]==0 and best_outputs.shape[0]>0:
		custom_jobs = best_outputs.rename(columns={'--{}'.format(k):k for k in list(best_outputs)})[list(custom_jobs)]
		custom_jobs.loc[:,'--hidden_layer_topology']=custom_jobs.loc[:,'--hidden_layer_topology'].map(lambda x: x.replace('[','').replace(']',''))
	custom_jobs.loc[:,'--job_name']='False'
	if crossover_p:
		for j in range(1,custom_jobs.shape[1]):
			vals=custom_jobs.iloc[:,j].unique()
			for i in range(custom_jobs.shape[0]):
				if np.random.rand() <= crossover_p:
					custom_jobs.iloc[i,j]=np.random.choice(vals)
	return [custom_jobs]
Finds top performing jobs from hyper parameter scan to rerun and cross-over parameters.

	Parameters
	----------
	hyperparameter_input_csv : str
		CSV file containing hyperparameter inputs.
	hyperparameter_output_log : str
		CSV file containing prior runs.
	n_top_jobs : int
		Number of top jobs to select
	crossover_p : float
		Rate of cross over of reused hyperparameters
	val_loss_column : str
		Loss column used to select top jobs

	Returns
	-------
	list
		List of list of new parameters for jobs to run.

	
Finds top performing jobs from hyper parameter scan to rerun and cross-over parameters.
Parameters

hyperparameter_input_csv : str
CSV file containing hyperparameter inputs.
hyperparameter_output_log : str
CSV file containing prior runs.
n_top_jobs : int
Number of top jobs to select
crossover_p : float
Rate of cross over of reused hyperparameters
val_loss_column : str
Loss column used to select top jobs

Returns

list
List of list of new parameters for jobs to run.
Finds top performing jobs from hyper parameter scan to rerun and cross - over parameters . Parameters hyperparameter_input_csv : str CSV file containing hyperparameter inputs . hyperparameter_output_log : str CSV file containing prior runs . n_top_jobs : int Number of top jobs to select crossover_p : float Rate of cross over of reused hyperparameters val_loss_column : str Loss column used to select top jobs Returns list List of list of new parameters for jobs to run .
def find_top_jobs(hyperparameter_input_csv,hyperparameter_output_log, n_top_jobs, crossover_p=0, val_loss_column='min_val_loss'):
	custom_jobs = pd.read_csv(hyperparameter_input_csv)
	hyperparam_output = pd.read_csv(hyperparameter_output_log)[['job_name',val_loss_column]]
	best_outputs = hyperparam_output.sort_values(val_loss_column,ascending=True).iloc[:n_top_jobs,:]
	custom_jobs = custom_jobs[np.isin(custom_jobs['--job_name'].values,best_outputs['job_name'].values)]
	if custom_jobs.shape[0]==0 and best_outputs.shape[0]>0:
		custom_jobs = best_outputs.rename(columns={'--{}'.format(k):k for k in list(best_outputs)})[list(custom_jobs)]
		custom_jobs.loc[:,'--hidden_layer_topology']=custom_jobs.loc[:,'--hidden_layer_topology'].map(lambda x: x.replace('[','').replace(']',''))
	custom_jobs.loc[:,'--job_name']='False'
	if crossover_p:
		for j in range(1,custom_jobs.shape[1]):
			vals=custom_jobs.iloc[:,j].unique()
			for i in range(custom_jobs.shape[0]):
				if np.random.rand() <= crossover_p:
					custom_jobs.iloc[i,j]=np.random.choice(vals)
	return [custom_jobs]
def find_top_jobs ( hyperparameter_input_csv , hyperparameter_output_log , n_top_jobs , crossover_p = 0 , val_loss_column = 'min_val_loss' ) : custom_jobs = pd . read_csv ( hyperparameter_input_csv ) hyperparam_output = pd . read_csv ( hyperparameter_output_log ) [ [ 'job_name' , val_loss_column ] ] best_outputs = hyperparam_output . sort_values ( val_loss_column , ascending = True ) . iloc [ : n_top_jobs , : ] custom_jobs = custom_jobs [ np . isin ( custom_jobs [ '--job_name' ] . values , best_outputs [ 'job_name' ] . values ) ] if custom_jobs . shape [ 0 ] == 0 and best_outputs . shape [ 0 ] > 0 : custom_jobs = best_outputs . rename ( columns = { '--{}' . format ( k ) : k for k in list ( best_outputs ) } ) [ list ( custom_jobs ) ] custom_jobs . loc [ : , '--hidden_layer_topology' ] = custom_jobs . loc [ : , '--hidden_layer_topology' ] . map ( lambda x : x . replace ( '[' , '' ) . replace ( ']' , '' ) ) custom_jobs . loc [ : , '--job_name' ] = 'False' if crossover_p : for j in range ( 1 , custom_jobs . shape [ 1 ] ) : vals = custom_jobs . iloc [ : , j ] . unique ( ) for i in range ( custom_jobs . shape [ 0 ] ) : if np . random . rand ( ) <= crossover_p : custom_jobs . iloc [ i , j ] = np . random . choice ( vals ) return [ custom_jobs ]
Finds top performing jobs from hyper parameter scan to rerun and cross-over parameters.
Finds top performing jobs from hyper parameter scan to rerun and cross - over parameters .
"""Finds top performing jobs from hyper parameter scan to rerun and cross-over parameters.

	Parameters
	----------
	hyperparameter_input_csv : str
		CSV file containing hyperparameter inputs.
	hyperparameter_output_log : str
		CSV file containing prior runs.
	n_top_jobs : int
		Number of top jobs to select
	crossover_p : float
		Rate of cross over of reused hyperparameters
	val_loss_column : str
		Loss column used to select top jobs

	Returns
	-------
	list
		List of list of new parameters for jobs to run.

	"""
hyperparameter_input_csv
hyperparameter_output_log
n_top_jobs
crossover_p
val_loss_column