<commit_before>import milk.supervised.gridsearch
import milk.supervised.svm
import tests.data.german.german

def test_gridsearch():
    data = tests.data.german.german.load()
    features = data['data']
    labels = data['label']
    G = milk.supervised.gridsearch.gridsearch(
            milk.supervised.svm.svm_raw(),
            params={'C':[.01,.1,1.,10.],
                    'kernel':[milk.supervised.svm.rbf_kernel(0.1),milk.supervised.svm.rbf_kernel(1.)]
            })
    model = G.train(features,labels)
    reslabels = [model.apply(f) for f in features]
    assert len(reslabels) == len(features)
test_gridsearch.slow = True


def test_all_assignements():
    assert len(list(milk.supervised.gridsearch._allassignments({'C': [0,1], 'kernel' : ['a','b','c']}))) == 2 * 3
<commit_msg>Another testing speedup by using milksets.wine<commit_after>import milk.supervised.gridsearch
import milk.supervised.svm

def test_gridsearch():
    from milksets import wine
    features, labels = wine.load()
    selected = (labels < 2)
    features = features[selected]
    labels = labels[selected]

    G = milk.supervised.gridsearch.gridsearch(
            milk.supervised.svm.svm_raw(),
            params={'C':[.01,.1,1.,10.],
                    'kernel':[milk.supervised.svm.rbf_kernel(0.1),milk.supervised.svm.rbf_kernel(1.)]
            })
    model = G.train(features,labels)
    reslabels = [model.apply(f) for f in features]
    assert len(reslabels) == len(features)
test_gridsearch.slow = True


def test_all_assignements():
    assert len(list(milk.supervised.gridsearch._allassignments({'C': [0,1], 'kernel' : ['a','b','c']}))) == 2 * 3

{'fraction_non_alphanumeric': 0.15767131594906003, 'fraction_numerical': 0.01637355973317162, 'mean_word_length': 3.3882978723404253, 'pattern_counts': {'":': 0, '<': 4, '<?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': '4299733', 'n_tokens_mistral': 575, 'n_tokens_neox': 548, 'n_words': 93}