Dataset.valid_set()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from abc import ABCMeta, abstractmethod
5
import collections
6
7
class Dataset(object):
8
    """
9
    Abstract dataset class.
10
    """
11
    __metaclass__ = ABCMeta
12
13
    @abstractmethod
14
    def train_set(self):
15
        """
16
        :rtype: list of tuple
17
        """
18
19
    def valid_set(self):
20
        """
21
        :rtype: list of tuple
22
        """
23
24
    def test_set(self):
25
        """
26
        :rtype: list of tuple
27
        """
28
29
    def train_size(self):
30
        """
31
        Return size of training data. (optional)
32
        :rtype: number
33
        """
34
        train_set = self.train_set()
35
        if isinstance(train_set, collections.Iterable):
36
            return len(list(train_set))
37
        else:
38
            return None