• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

autonomio / talos / 8782146110

22 Apr 2024 10:00AM UTC coverage: 86.975%. First build
8782146110

Pull #600

github

mikkokotila
change the mentioned stats in readme
Pull Request #600: few small changes to README.md

1429 of 1643 relevant lines covered (86.98%)

5.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/talos/utils/validation_split.py
1
def validation_split(self):
6✔
2

3
    '''Defines the attributes `x_train`, `y_train`, `x_val` and `y_val`.
4
    The validation sets are determined by the attribute val_split,
5
    which is a number in (0, 1) which determines the proportion of
6
    the input data to be allocated for cross-validation.'''
7

8
    # data input is list but multi_input is not set to True
9
    if isinstance(self.x, list) and self.multi_input is False:
6✔
10

11
        raise TypeError("For multi-input x, set multi_input to True")
×
12

13
    # If split is done in `Scan()` do nothing
14
    if self.custom_val_split:
6✔
15

16
        self.x_train = self.x
6✔
17
        self.y_train = self.y
6✔
18

19
        return self
6✔
20

21
    # Otherwise start by shuffling
22
    import wrangle
6✔
23
    self.x, self.y = wrangle.array_random_shuffle(x=self.x,
6✔
24
                                                  y=self.y,
25
                                                  multi_input=self.multi_input)
26

27
    # deduce the midway point for input data
28
    limit = int(len(self.y) * (1 - self.val_split))
6✔
29

30
    # handle the case where x is multi-input
31
    if self.multi_input:
6✔
32

33
        self.x_train = []
×
34
        self.x_val = []
×
35

36
        for ar in self.x:
×
37
            self.x_train.append(ar[:limit])
×
38
            self.x_val.append(ar[limit:])
×
39

40
    # handle the case where x is not multi-input
41
    else:
42

43
        self.x_train = self.x[:limit]
6✔
44
        self.x_val = self.x[limit:]
6✔
45

46
    # handle y data same for both cases
47
    self.y_train = self.y[:limit]
6✔
48
    self.y_val = self.y[limit:]
6✔
49

50
    return self
6✔
51

52

53
def kfold(x, y, folds=10, shuffled=True, multi_input=False):
6✔
54

55
    import wrangle
6✔
56

57
    # data input is list but multi_input is not set to True
58
    if isinstance(x, list) and multi_input is False:
6✔
59
        raise TypeError("For multi-input x, set multi_input to True")
×
60

61
    if shuffled is True:
6✔
62
        x, y = wrangle.array_random_shuffle(x, y, multi_input)
6✔
63

64
    out_x = []
6✔
65
    out_y = []
6✔
66

67
    # establish the fold size
68
    y_len = len(y)
6✔
69
    step = int(y_len / folds)
6✔
70

71
    lo = 0
6✔
72
    hi = step
6✔
73

74
    # create folds one by one
75
    for _i in range(folds):
6✔
76

77
        # handle the case for multi-input model
78
        if multi_input:
6✔
79
            fold_x = []
×
80
            for ar in x:
×
81
                fold_x.append(ar[lo:hi])
×
82
            out_x.append(fold_x)
×
83

84
        # handle the case where model is not multi-input
85
        else:
86
            out_x.append(x[lo:hi])
6✔
87

88
        out_y.append(y[lo:hi])
6✔
89

90
        lo += step
6✔
91
        hi += step
6✔
92

93
    return out_x, out_y
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc