-
Notifications
You must be signed in to change notification settings - Fork 93
/
data_test_multiple.py
35 lines (28 loc) · 1.31 KB
/
data_test_multiple.py
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
"""Create multiple dataset test"""
import uuid
import zipfile
from typing import Union, List
import datatable as dt
import numpy as np
import pandas as pd
from h2oaicore.data import CustomData
from h2oaicore.systemutils import user_dir
class TestDataMultiple(CustomData):
@staticmethod
def create_data(X: dt.Frame = None) -> Union[str, List[str],
dt.Frame, List[dt.Frame],
np.ndarray, List[np.ndarray],
pd.DataFrame, List[pd.DataFrame]]:
import os
from h2oaicore.systemutils_more import download
from h2oaicore.systemutils import config
temp_path = os.path.join(user_dir(), config.contrib_relative_directory, "testdata_%s" % str(uuid.uuid4()))
os.makedirs(temp_path, exist_ok=True)
url = "http://archive.ics.uci.edu/static/public/53/iris.zip"
dataset_name1 = "iris.data"
dataset_name2 = "bezdekIris.data"
zip_file = download(url, dest_path=temp_path)
with zipfile.ZipFile(zip_file, "r") as my_zip:
my_zip.extract(dataset_name1, temp_path)
my_zip.extract(dataset_name2, temp_path)
return [os.path.join(temp_path, dataset_name1), os.path.join(temp_path, dataset_name2)]