forked from JayYu0116/MLIP_Lab6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_utility.py
42 lines (37 loc) · 1.34 KB
/
test_utility.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
36
37
38
39
40
41
42
import pytest
import pandas as pd
import numpy as np
from prediction_demo import data_preparation,data_split,train_model,eval_model
@pytest.fixture
def housing_data_sample():
return pd.DataFrame(
data ={
'price':[13300000,12250000],
'area':[7420,8960],
'bedrooms':[4,4],
'bathrooms':[2,4],
'stories':[3,4],
'mainroad':["yes","yes"],
'guestroom':["no","no"],
'basement':["no","no"],
'hotwaterheating':["no","no"],
'airconditioning':["yes","yes"],
'parking':[2,3],
'prefarea':["yes","no"],
'furnishingstatus':["furnished","unfurnished"]}
)
def test_data_preparation(housing_data_sample):
feature_df, target_series = data_preparation(housing_data_sample)
# Target and datapoints has same length
assert feature_df.shape[0]==len(target_series)
#Feature only has numerical values
assert feature_df.shape[1] == feature_df.select_dtypes(include=(np.number,np.bool_)).shape[1]
@pytest.fixture
def feature_target_sample(housing_data_sample):
feature_df, target_series = data_preparation(housing_data_sample)
return (feature_df, target_series)
def test_data_split(feature_target_sample):
return_tuple = data_split(*feature_target_sample)
# TODO test if the length of return_tuple is 4
return len(return_tuple) == 4
raise NotImplemented