How to use dt - 10 common examples

To help you get started, we’ve selected a few dt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github embali / windseed / djangotest / dt / views.py View on Github external
def index(request):
    page = int(request.GET.get('page', 1))

    records = Record.objects.filter(active=True).order_by('name')
    pages = Paginator(records, 48)

    '''
    records = pages.page(page).object_list
    '''
    records_pages = RecordPage.objects\
        .filter(page=page)\
        .select_related('record')

    return render(
        request,
        'records.html',
        dict(
            records=[record_page.record for record_page in records_pages],
            prev_page=pages.page(page).previous_page_number()
            if pages.page(page).has_previous() else None,
github embali / windseed / djangotest / dt / management / commands / records.py View on Github external
records = []

        Record.objects.all().delete()

        for i in range(1000000):
            if i % 2 == 0:
                active = True
            else:
                active = False
            records.append(Record(active=active, name='record %d' % i,
                                  description='description %d' % i))
        Record.objects.bulk_create(records)

        RecordPage.objects.all().delete()

        records = Record.objects.filter(active=True).order_by('name')
        paginator = Paginator(records, 48)

        records_pages = []
        for page in range(1, paginator.num_pages+1):
            for record in paginator.page(page).object_list:
                records_pages.append(RecordPage(record=record, page=page))

        RecordPage.objects.bulk_create(records_pages)
github embali / windseed / djangotest / dt / management / commands / records.py View on Github external
def handle(self, *args, **options):
        records = []

        Record.objects.all().delete()

        for i in range(1000000):
            if i % 2 == 0:
                active = True
            else:
                active = False
            records.append(Record(active=active, name='record %d' % i,
                                  description='description %d' % i))
        Record.objects.bulk_create(records)

        RecordPage.objects.all().delete()

        records = Record.objects.filter(active=True).order_by('name')
        paginator = Paginator(records, 48)

        records_pages = []
github embali / windseed / djangotest / dt / management / commands / records.py View on Github external
def handle(self, *args, **options):
        records = []

        Record.objects.all().delete()

        for i in range(1000000):
            if i % 2 == 0:
                active = True
            else:
                active = False
            records.append(Record(active=active, name='record %d' % i,
                                  description='description %d' % i))
        Record.objects.bulk_create(records)

        RecordPage.objects.all().delete()

        records = Record.objects.filter(active=True).order_by('name')
        paginator = Paginator(records, 48)

        records_pages = []
        for page in range(1, paginator.num_pages+1):
            for record in paginator.page(page).object_list:
                records_pages.append(RecordPage(record=record, page=page))

        RecordPage.objects.bulk_create(records_pages)
github embali / windseed / djangotest / dt / management / commands / records.py View on Github external
active = True
            else:
                active = False
            records.append(Record(active=active, name='record %d' % i,
                                  description='description %d' % i))
        Record.objects.bulk_create(records)

        RecordPage.objects.all().delete()

        records = Record.objects.filter(active=True).order_by('name')
        paginator = Paginator(records, 48)

        records_pages = []
        for page in range(1, paginator.num_pages+1):
            for record in paginator.page(page).object_list:
                records_pages.append(RecordPage(record=record, page=page))

        RecordPage.objects.bulk_create(records_pages)
github embali / windseed / djangotest / dt / management / commands / records.py View on Github external
def handle(self, *args, **options):
        records = []

        Record.objects.all().delete()

        for i in range(1000000):
            if i % 2 == 0:
                active = True
            else:
                active = False
            records.append(Record(active=active, name='record %d' % i,
                                  description='description %d' % i))
        Record.objects.bulk_create(records)

        RecordPage.objects.all().delete()

        records = Record.objects.filter(active=True).order_by('name')
        paginator = Paginator(records, 48)

        records_pages = []
        for page in range(1, paginator.num_pages+1):
            for record in paginator.page(page).object_list:
                records_pages.append(RecordPage(record=record, page=page))

        RecordPage.objects.bulk_create(records_pages)
github embali / windseed / djangotest / dt / management / commands / records.py View on Github external
active = False
            records.append(Record(active=active, name='record %d' % i,
                                  description='description %d' % i))
        Record.objects.bulk_create(records)

        RecordPage.objects.all().delete()

        records = Record.objects.filter(active=True).order_by('name')
        paginator = Paginator(records, 48)

        records_pages = []
        for page in range(1, paginator.num_pages+1):
            for record in paginator.page(page).object_list:
                records_pages.append(RecordPage(record=record, page=page))

        RecordPage.objects.bulk_create(records_pages)
github embali / windseed / djangotest / dt / views.py View on Github external
def index(request):
    page = int(request.GET.get('page', 1))

    records = Record.objects.filter(active=True).order_by('name')
    pages = Paginator(records, 48)

    '''
    records = pages.page(page).object_list
    '''
    records_pages = RecordPage.objects\
        .filter(page=page)\
        .select_related('record')

    return render(
        request,
        'records.html',
        dict(
            records=[record_page.record for record_page in records_pages],
            prev_page=pages.page(page).previous_page_number()
            if pages.page(page).has_previous() else None,
            next_page=pages.page(page).next_page_number()
            if pages.page(page).has_next() else None))
github embali / windseed / djangotest / dt / management / commands / records.py View on Github external
def handle(self, *args, **options):
        records = []

        Record.objects.all().delete()

        for i in range(1000000):
            if i % 2 == 0:
                active = True
            else:
                active = False
            records.append(Record(active=active, name='record %d' % i,
                                  description='description %d' % i))
        Record.objects.bulk_create(records)

        RecordPage.objects.all().delete()

        records = Record.objects.filter(active=True).order_by('name')
        paginator = Paginator(records, 48)

        records_pages = []
        for page in range(1, paginator.num_pages+1):
            for record in paginator.page(page).object_list:
                records_pages.append(RecordPage(record=record, page=page))

        RecordPage.objects.bulk_create(records_pages)
github mazefeng / ml / dt.py View on Github external
if y_pred == None:
                y_pred = node['LABEL']
            if y_pred == y:
                correct += 1

        return 1.0 * correct / len(Y)

if __name__ == '__main__':
   
    train_path = 'data/2_newsgroups.train'
    test_path = 'data/2_newsgroups.test'

    X_train, Y_train = read_sparse_data(open(train_path))
    X_test, Y_test = read_sparse_data(open(test_path))

    clf = ID3()
    clf.train(X_train, Y_train)
    acc_train = clf.test(X_train, Y_train)
    acc_test = clf.test(X_test, Y_test)

    print >> sys.stderr, 'Training accuracy for ID3 : %f%%' % (100 * acc_train)
    print >> sys.stderr, 'Test accuracy for ID3 : %f%%' % (100 * acc_test)
   
    clf.dump_model(open('data/dt.model', 'w'), open('data/dt.rule_set', 'w'))