To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

split_dataset.py 543 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 19.01.2021

@author: Feliks Kiszkurno
"""

import slopestabilitytools
import random
import math


def split_dataset(test_names, random_seed):

    random.seed(random_seed)

    test_number = len(test_names)
    test_prediction = random.choices(list(test_names),
felikskiszkurno's avatar
felikskiszkurno committed
20
                                     k=math.ceil(test_number * 0.25))
21
22
23

    test_training = slopestabilitytools.set_diff(list(test_names), set(test_prediction))

24
    return sorted(test_training), sorted(test_prediction)