1+ import pytest
2+ import numpy as np
3+ import pandas as pd
4+ from lazypredict .Supervised import LazyClassifier , LazyRegressor
5+ from sklearn .datasets import load_breast_cancer , load_boston
6+ from sklearn .model_selection import train_test_split
7+ from sklearn .utils import shuffle
8+
9+ def test_lazy_classifier_fit ():
10+ data = load_breast_cancer ()
11+ X = data .data
12+ y = data .target
13+ X_train , X_test , y_train , y_test = train_test_split (X , y , test_size = 0.5 , random_state = 123 )
14+ clf = LazyClassifier (verbose = 0 , ignore_warnings = True , custom_metric = None )
15+ models , predictions = clf .fit (X_train , X_test , y_train , y_test )
16+ assert isinstance (models , pd .DataFrame )
17+ assert isinstance (predictions , pd .DataFrame )
18+
19+ def test_lazy_classifier_provide_models ():
20+ data = load_breast_cancer ()
21+ X = data .data
22+ y = data .target
23+ X_train , X_test , y_train , y_test = train_test_split (X , y , test_size = 0.5 , random_state = 123 )
24+ clf = LazyClassifier (verbose = 0 , ignore_warnings = True , custom_metric = None )
25+ clf .fit (X_train , X_test , y_train , y_test )
26+ models = clf .provide_models (X_train , X_test , y_train , y_test )
27+ assert isinstance (models , dict )
28+
29+ def test_lazy_regressor_fit ():
30+ boston = load_boston ()
31+ X , y = shuffle (boston .data , boston .target , random_state = 13 )
32+ X = X .astype (np .float32 )
33+ offset = int (X .shape [0 ] * 0.9 )
34+ X_train , y_train = X [:offset ], y [:offset ]
35+ X_test , y_test = X [offset :], y [offset :]
36+ reg = LazyRegressor (verbose = 0 , ignore_warnings = False , custom_metric = None )
37+ models , predictions = reg .fit (X_train , X_test , y_train , y_test )
38+ assert isinstance (models , pd .DataFrame )
39+ assert isinstance (predictions , pd .DataFrame )
40+
41+ def test_lazy_regressor_provide_models ():
42+ boston = load_boston ()
43+ X , y = shuffle (boston .data , boston .target , random_state = 13 )
44+ X = X .astype (np .float32 )
45+ offset = int (X .shape [0 ] * 0.9 )
46+ X_train , y_train = X [:offset ], y [:offset ]
47+ X_test , y_test = X [offset :], y [offset :]
48+ reg = LazyRegressor (verbose = 0 , ignore_warnings = False , custom_metric = None )
49+ reg .fit (X_train , X_test , y_train , y_test )
50+ models = reg .provide_models (X_train , X_test , y_train , y_test )
51+ assert isinstance (models , dict )
0 commit comments