<commit_before>import unittest

from autosklearn.pipeline.components.regression.random_forest import RandomForest
from autosklearn.pipeline.util import _test_regressor, _test_regressor_iterative_fit

import sklearn.metrics


class RandomForestComponentTest(unittest.TestCase):
    def test_default_configuration(self):
        for i in range(10):

            predictions, targets = _test_regressor(RandomForest)
            self.assertAlmostEqual(0.40965687834764064,
                sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))


    def test_default_configuration_sparse(self):
        for i in range(10):
            predictions, targets = _test_regressor(RandomForest, sparse=True)
            self.assertAlmostEqual(0.24147637508106434,
                sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))

    def test_default_configuration_iterative_fit(self):
        for i in range(10):
            predictions, targets = \
                _test_regressor_iterative_fit(RandomForest)
            self.assertAlmostEqual(0.40965687834764064,
                sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))<commit_msg>ADD test to test iterative fit sparse<commit_after>import unittest

from autosklearn.pipeline.components.regression.random_forest import RandomForest
from autosklearn.pipeline.util import _test_regressor, _test_regressor_iterative_fit

import sklearn.metrics


class RandomForestComponentTest(unittest.TestCase):
    def test_default_configuration(self):
        for i in range(10):

            predictions, targets = _test_regressor(RandomForest)
            self.assertAlmostEqual(0.41795829411621988,
                sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))

    def test_default_configuration_sparse(self):
        for i in range(10):
            predictions, targets = _test_regressor(RandomForest, sparse=True)
            self.assertAlmostEqual(0.24225685933770469,
                sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))

    def test_default_configuration_iterative_fit(self):
        for i in range(10):
            predictions, targets = \
                _test_regressor_iterative_fit(RandomForest)
            self.assertAlmostEqual(0.41795829411621988,
                sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))

    def test_default_configuration_iterative_fit_sparse(self):
        for i in range(10):
            predictions, targets = \
                _test_regressor_iterative_fit(RandomForest, sparse=True)
            self.assertAlmostEqual(0.24225685933770469,
                sklearn.metrics.r2_score(y_true=targets, y_pred=predictions))
{'fraction_non_alphanumeric': 0.07177389364075865, 'fraction_numerical': 0.054667162513945704, 'mean_word_length': 3.4316309719934104, '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': '2142370', 'n_tokens_mistral': 911, 'n_tokens_neox': 791, 'n_words': 122}