python/methylnet/predictions.py
def regression_report(results_pickle,output_dir):
	"""Generate regression report that gives concise results from regression tasks."""
	# FIXME expand functionality
	import matplotlib
	matplotlib.use('Agg')
	import matplotlib.pyplot as plt
	import seaborn as sns
	sns.set(style="whitegrid")
	os.makedirs(output_dir,exist_ok=True)
	results_dict=pickle.load(open(results_pickle,'rb'))
	for k in results_dict:
		df_pred=pd.DataFrame(results_dict[k]['y_pred']).melt()
		df_pred=df_pred.rename(columns=dict(value='y_pred',variable='outcome_vars'))
		df_true=pd.DataFrame(results_dict[k]['y_true']).melt()
		df_true=df_true.rename(columns=dict(value='y_true',variable='true_vars'))
		df=pd.concat([df_pred,df_true],axis=1)
		#print(df)
		df=df[['outcome_vars','y_pred','y_true']]
		plt.figure()
		sns.lmplot(x="y_pred", y="y_true", col="outcome_vars", hue="outcome_vars",data=df, col_wrap=2)
		plt.savefig(os.path.join(output_dir,'{}_regression_results.png'.format(k)),dpi=300)
Generate regression report that gives concise results from regression tasks.
Generate regression report that gives concise results from regression tasks.
Generate regression report that gives concise results from regression tasks .
def regression_report(results_pickle,output_dir):
	import matplotlib
	matplotlib.use('Agg')
	import matplotlib.pyplot as plt
	import seaborn as sns
	sns.set(style="whitegrid")
	os.makedirs(output_dir,exist_ok=True)
	results_dict=pickle.load(open(results_pickle,'rb'))
	for k in results_dict:
		df_pred=pd.DataFrame(results_dict[k]['y_pred']).melt()
		df_pred=df_pred.rename(columns=dict(value='y_pred',variable='outcome_vars'))
		df_true=pd.DataFrame(results_dict[k]['y_true']).melt()
		df_true=df_true.rename(columns=dict(value='y_true',variable='true_vars'))
		df=pd.concat([df_pred,df_true],axis=1)
		df=df[['outcome_vars','y_pred','y_true']]
		plt.figure()
		sns.lmplot(x="y_pred", y="y_true", col="outcome_vars", hue="outcome_vars",data=df, col_wrap=2)
		plt.savefig(os.path.join(output_dir,'{}_regression_results.png'.format(k)),dpi=300)
def regression_report ( results_pickle , output_dir ) : import matplotlib matplotlib . use ( 'Agg' ) import matplotlib . pyplot as plt import seaborn as sns sns . set ( style = "whitegrid" ) os . makedirs ( output_dir , exist_ok = True ) results_dict = pickle . load ( open ( results_pickle , 'rb' ) ) for k in results_dict : df_pred = pd . DataFrame ( results_dict [ k ] [ 'y_pred' ] ) . melt ( ) df_pred = df_pred . rename ( columns = dict ( value = 'y_pred' , variable = 'outcome_vars' ) ) df_true = pd . DataFrame ( results_dict [ k ] [ 'y_true' ] ) . melt ( ) df_true = df_true . rename ( columns = dict ( value = 'y_true' , variable = 'true_vars' ) ) df = pd . concat ( [ df_pred , df_true ] , axis = 1 ) df = df [ [ 'outcome_vars' , 'y_pred' , 'y_true' ] ] plt . figure ( ) sns . lmplot ( x = "y_pred" , y = "y_true" , col = "outcome_vars" , hue = "outcome_vars" , data = df , col_wrap = 2 ) plt . savefig ( os . path . join ( output_dir , '{}_regression_results.png' . format ( k ) ) , dpi = 300 )
Generate regression report that gives concise results from regression tasks.
Generate regression report that gives concise results from regression tasks .
"""Generate regression report that gives concise results from regression tasks.""" # FIXME expand functionality #print(df)
results_pickle
output_dir