Exemplo n.º 1
0
    def setup_class(cls):
        model = ScikitLearnModel('TestModel', [OneHotFeature()],
                                 TestOfferSample)

        train_samples = [
            TestOfferSample.fromjson({
                'entityid': str(i),
                'TestModelLabel': i % 2
            }) for i in xrange(0, 10000)
        ]
        test_samples = [
            TestOfferSample.fromjson({
                'entityid': str(i),
                'TestModelLabel': i % 2
            }) for i in xrange(10000, 12000)
        ]

        DataSet.remove('bootstrapped_training')
        DataSet.bootstrap('bootstrapped_training',
                          model,
                          train_samples,
                          part_size=2000,
                          numclasses=2)
        DataSet.remove('bootstrapped_test')
        DataSet.bootstrap('bootstrapped_test',
                          model,
                          test_samples,
                          part_size=2000,
                          numclasses=2)
Exemplo n.º 2
0
    def setup_class(cls):
        model = SimpleKerasModel('TestModel', [OneHotFeature()],
                                 TestOfferSample)

        train_samples = [
            TestOfferSample.fromjson({
                'entityid':
                str(i),
                'TestModelLabel': [0, 1] if i % 2 == 0 else [1, 0]
            }) for i in xrange(0, 10000)
        ]
        test_samples = [
            TestOfferSample.fromjson({
                'entityid':
                str(i),
                'TestModelLabel': [0, 1] if i % 2 == 0 else [1, 0]
            }) for i in xrange(10000, 12000)
        ]

        DataSet.remove('batching_train')
        DataSet.bootstrap('batching_train',
                          model,
                          train_samples,
                          part_size=2000)
        DataSet.remove('batching_test')
        DataSet.bootstrap('batching_test', model, test_samples, part_size=2000)
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
import sys
import logging

import iwlearn.mongo as mongo
from iwlearn.training import DataSet

from tutorial.common.samples import RelocationUserSample
from tutorial.common.rules import RelocationRule

if __name__ == "__main__":
    logging.basicConfig(stream=sys.stdout, level=logging.INFO)

    mongo.setmongouri('mongodb://localhost:27017/')

    DataSet.remove('train')
    DataSet.generate('train',
                     RelocationRule(),
                     numclasses=2,
                     filter={'entityid': {
                         '$regex': r'^user[0-9]*?[0-7]$'
                     }})

    DataSet.remove('test')
    DataSet.generate('test',
                     RelocationRule(),
                     numclasses=2,
                     filter={'entityid': {
                         '$regex': r'^user[0-9]*?[8-9]$'
                     }})
Exemplo n.º 4
0
# -*- coding: utf-8 -*-
import sys
import logging

import iwlearn.mongo as mongo
from iwlearn.training import DataSet

from tutorial.common.models import RelocationModelHyper

if __name__ == "__main__":
    logging.basicConfig(stream=sys.stdout, level=logging.INFO)

    mongo.setmongouri('mongodb://localhost:27017/')

    DataSet.remove('train-hyper')
    DataSet.generate('train-hyper', RelocationModelHyper(), numclasses=2, filter={'entityid': {'$regex': r'^user[0-9]*?[0-7]$'}})

    DataSet.remove('test-hyper')
    DataSet.generate('test-hyper', RelocationModelHyper(), numclasses=2, filter={'entityid': {'$regex': r'^user[0-9]*?[8-9]$'}})
Exemplo n.º 5
0
# -*- coding: utf-8 -*-
import sys
import logging

import iwlearn.mongo as mongo
from iwlearn.training import DataSet

from tutorial.common.models import RelocationModelPro

if __name__ == "__main__":
    logging.basicConfig(stream=sys.stdout, level=logging.INFO)

    mongo.setmongouri('mongodb://localhost:27017/')

    DataSet.remove('train-pro')
    DataSet.generate('train-pro',
                     RelocationModelPro(),
                     numclasses=2,
                     filter={'entityid': {
                         '$regex': r'^user[0-9]*?[0-7]$'
                     }})

    DataSet.remove('test-pro')
    DataSet.generate('test-pro',
                     RelocationModelPro(),
                     numclasses=2,
                     filter={'entityid': {
                         '$regex': r'^user[0-9]*?[8-9]$'
                     }})