This file is indexed.

/usr/share/octave/packages/statistics-1.3.0/@cvpartition/repartition.m is in octave-statistics 1.3.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
## Copyright (C) 2014 Nir Krakauer
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; If not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn{Function File}{@var{Cnew} =} repartition (@var{C})
## Return a new cvpartition object.
##
## @var{C} should be a cvpartition object. @var{Cnew} will use the same partition_type as @var{C} but redo any randomization performed (currently, only the HoldOut type uses randomization).
##
## @seealso{cvpartition}
## @end deftypefn

## Author: Nir Krakauer

function Cnew = repartition (C)

  if (nargin < 1 || nargin > 2)
    print_usage ();
  endif

  Cnew = C;

  switch C.Type
    case 'kfold'
    case 'given'
    case 'holdout' #currently, only the HoldOut method uses randomization
      n = C.NumObservations;
      k = C.TestSize;
      n_classes = C.n_classes;
      if k < 1
        f = k; #target fraction to sample
        k = round (k * n); #number of samples
      else
        f = k / n;
      endif
      inds = zeros (n, 1, "logical");
      if n_classes == 1
        inds(randsample(n, k)) = true; #indices for test set
      else #sample from each class
        j = C.classes; #integer class labels
        n_per_class = accumarray (j, 1);
        n_classes = numel (n_per_class);
        k_check = 0;
        for i = 1:n_classes
          ki = round(f*n_per_class(i));
          inds(find(j == i)(randsample(n_per_class(i), ki))) = true;
          k_check += ki;
        endfor
        if k_check < k #add random elements to test set to make it k
          inds(find(!inds)(randsample(n - k_check, k - k_check))) = true;
        elseif k_check > k #remove random elements from test set
          inds(find(inds)(randsample(k_check, k_check - k))) = false;
        endif
      endif
      Cnew.inds = inds;
    case 'leaveout'
    case 'resubstitution'
  endswitch