comparison plot_regression_performance.py @ 1:389227fa1864 draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/plotly_regression_performance_plots commit 2473a53fde6d8e646e90d2a5201999c8c6a48695
author bgruening
date Wed, 09 Jan 2019 02:55:46 -0500
parents 0800a1b66bbd
children
comparison
equal deleted inserted replaced
0:0800a1b66bbd 1:389227fa1864
1 import argparse 1 import argparse
2 import pandas as pd 2 import pandas as pd
3 import numpy as np
3 import plotly 4 import plotly
4 import plotly.graph_objs as go 5 import plotly.graph_objs as go
5 6
6 7
7 def main(infile_input, infile_output): 8 def main(infile_input, infile_output):
45 46
46 # scatter plot 47 # scatter plot
47 max_tv = int(max(true_values)) 48 max_tv = int(max(true_values))
48 x_y_values = list(range(0, max_tv)) 49 x_y_values = list(range(0, max_tv))
49 50
51 true_mean = np.mean(true_values)
52 res_true_predicted = np.sum((true_values - predicted_values) ** 2)
53 res_total = np.sum((true_values - true_mean) ** 2)
54 r2 = 1 - (res_true_predicted / float(res_total))
55 rmse = np.sqrt(np.mean([(x - y) ** 2 for x, y in zip(true_values, predicted_values)]))
56
50 trace_x_eq_y = go.Scatter( 57 trace_x_eq_y = go.Scatter(
51 x=x_y_values, 58 x=x_y_values,
52 y=x_y_values, 59 y=x_y_values,
53 mode='lines', 60 mode='lines',
54 name='X = Y curve' 61 name='X = Y curve'
60 mode='markers', 67 mode='markers',
61 name='True and predicted values' 68 name='True and predicted values'
62 ) 69 )
63 70
64 layout_true_pred = go.Layout( 71 layout_true_pred = go.Layout(
65 title='True vs predicted values', 72 title='True vs predicted values (RMSE: %s, R2: %s)' % (str(np.round(rmse, 2)), str(np.round(r2, 2))),
66 xaxis=dict(title='True values'), 73 xaxis=dict(title='True values'),
67 yaxis=dict(title='Predicted values') 74 yaxis=dict(title='Predicted values')
68 ) 75 )
69 76
70 data_true_pred = [trace_true_pred, trace_x_eq_y] 77 data_true_pred = [trace_true_pred, trace_x_eq_y]