<commit_before>from unittest import TestCase

from wallace.predictive_models.ols_linear_regression import OLSLinearRegression, TrainedOLSLinearRegression
from wallace.dataset import Dataset, DatasetVariable

class OLSRegressionTest(TestCase):
    def test_training_ols_on_simple_dataset(self):
        settings = {}
        parameter_set = {}
        dependent_variable = DatasetVariable(0)
        independent_variables = [DatasetVariable(1)]
        regression = OLSLinearRegression(settings, parameter_set, dependent_variable, independent_variables)

        data_matrix = [[1,1], [2,2], [3,3], [4,4]]
        dataset = Dataset(data_matrix)

        trained = regression.train(dataset)
        array = trained.predict(dataset)

        self.assertEqual(1, array[0])
        self.assertEqual(2, array[1])
        self.assertEqual(3, array[2])
        self.assertEqual(4, array[3])<commit_msg>Adding another ols regression test.<commit_after>from unittest import TestCase

from wallace.predictive_models.ols_linear_regression import OLSLinearRegression, TrainedOLSLinearRegression
from wallace.dataset import Dataset, DatasetVariable

class OLSRegressionTest(TestCase):
    def test_training_ols_on_simple_dataset(self):
        settings = {}
        parameter_set = {}
        dependent_variable = DatasetVariable(0)
        independent_variables = [DatasetVariable(1)]
        regression = OLSLinearRegression(settings, parameter_set, dependent_variable, independent_variables)

        data_matrix = [[1,1], [2,2], [3,3], [4,4]]
        dataset = Dataset(data_matrix)

        trained = regression.train(dataset)
        array = trained.predict(dataset)

        self.assertEqual(1, array[0])
        self.assertEqual(2, array[1])
        self.assertEqual(3, array[2])
        self.assertEqual(4, array[3])

    def test_training_ols_on_simple_dataset_two_variables(self):
        settings = {}
        parameter_set = {}
        dependent_variable = DatasetVariable(0)
        independent_variables = [DatasetVariable(1), DatasetVariable(2)]
        regression = OLSLinearRegression(settings, parameter_set, dependent_variable, independent_variables)

        data_matrix = [[1,1,2], [2,2,3], [3,3,4], [4,4,5]]
        dataset = Dataset(data_matrix)

        trained = regression.train(dataset)
        array = trained.predict(dataset)

        self.assertAlmostEqual(1, array[0])
        self.assertAlmostEqual(2, array[1])
        self.assertAlmostEqual(3, array[2])
        self.assertAlmostEqual(4, array[3])
{'fraction_non_alphanumeric': 0.10250297973778308, 'fraction_numerical': 0.023440603893524037, 'mean_word_length': 3.768939393939394, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6267380', 'n_tokens_mistral': 738, 'n_tokens_neox': 721, 'n_words': 132}