b6f83ab5a36233c57b19aa38f28d58a80b19c3ba,ludwig/modules/metric_modules.py,R2Score,update_state,#R2Score#,62
Before Change
def update_state(self, y, y_hat):
self.sum_y += np.sum(y)
self.sum_y_squared += np.sum(y ** 2)
self.sum_y_hat += np.sum(y_hat)
self.sum_y_hat_squared += np.sum(y_hat ** 2)
self.sum_y_y_hat += np.sum(y * y_hat)
self.N += y.shape[0]
After Change
)
def update_state(self, y, y_hat):
y = tf.cast(y, dtype=tf.float32)
y_hat = tf.cast(y_hat, dtype=tf.float32)
self.sum_y.assign_add(tf.reduce_sum(y))
self.sum_y_squared.assign_add(tf.reduce_sum(y ** 2))
self.sum_y_hat.assign_add(tf.reduce_sum(y_hat))
self.sum_y_hat_squared.assign_add(tf.reduce_sum(y_hat ** 2))
self.sum_y_y_hat.assign_add(tf.reduce_sum(y * y_hat))
self.N.assign_add(y.shape[0])
def result(self):
y_bar = self.sum_y / self.N
tot_ss = self.sum_y_squared - 2.0 * y_bar * self.sum_y \
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: uber/ludwig
Commit Name: b6f83ab5a36233c57b19aa38f28d58a80b19c3ba
Time: 2020-08-14
Author: jimthompson5802@gmail.com
File Name: ludwig/modules/metric_modules.py
Class Name: R2Score
Method Name: update_state
Project Name: uber/ludwig
Commit Name: b6f83ab5a36233c57b19aa38f28d58a80b19c3ba
Time: 2020-08-14
Author: jimthompson5802@gmail.com
File Name: ludwig/modules/metric_modules.py
Class Name: R2Score
Method Name: update_state
Project Name: uber/ludwig
Commit Name: b6f83ab5a36233c57b19aa38f28d58a80b19c3ba
Time: 2020-08-14
Author: jimthompson5802@gmail.com
File Name: ludwig/modules/metric_modules.py
Class Name: ErrorScore
Method Name: update_state