def test_log_mse_random_arrays_finite_values(self, y_true, y_pred): log_mse_value = log_mse(y_true, y_pred) expected_log_mse = self._correct_log_mse(y_true, y_pred) print(y_true) print(y_pred) assert expected_log_mse == log_mse_value
def test_log_mse_dataframe(self): y_true = pd.DataFrame([0, 1, 2, 3, 4, 5]) y_pred = pd.DataFrame([1, 4, 5, 10, 4, 1]) log_mse_value = np.round(log_mse(y_true, y_pred), decimals=2) expected_log_mse = 0.67 assert expected_log_mse == log_mse_value
def test_log_mse_array(self): y_true = np.array([0, 1, 2, 3, 4, 5]) y_pred = np.array([1, 4, 5, 10, 4, 1]) log_mse_value = np.round(log_mse(y_true, y_pred), decimals=2) expected_log_mse = 0.67 assert expected_log_mse == log_mse_value
def test_log_mse_list(self): y_true = [0, 1, 2, 3, 4, 5] y_pred = [1, 4, 5, 10, 4, 1] log_mse_value = np.round(log_mse(y_true, y_pred), decimals=2) expected_log_mse = 0.67 assert expected_log_mse == log_mse_value
def _correct_rmsle(self, y_true, y_pred): y_true = np.array(y_true) y_pred = np.array(y_pred) return np.sqrt(log_mse(y_true, y_pred))
def test_log_mse_negative_values(self): y_true = np.array([0, 1, 2, 3, 4, -5]) y_pred = np.array([0, 0, 0, 0, 0, 0]) with pytest.raises(ValueError): log_mse(y_true, y_pred)
def test_infinite_values(self): y_true = np.random.random(4) y_pred = [0, np.inf, 2, 3] with pytest.raises(ValueError): log_mse(y_true, y_pred)
def test_nan_values(self): y_true = [np.nan, 1, 2, 3] y_pred = np.random.random(4) with pytest.raises(ValueError): log_mse(y_true, y_pred)
def test_wrong_vector_length(self): y_true = np.random.random(5) y_pred = np.random.random(4) with pytest.raises(ValueError): log_mse(y_true, y_pred)