mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-05 03:07:42 +00:00
update all (#530)
This commit is contained in:
@@ -8,6 +8,7 @@ Please make sure the stdout is rich enough to support informative feedback
|
||||
"""
|
||||
|
||||
import pickle
|
||||
from copy import deepcopy
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
@@ -19,17 +20,44 @@ print(f"X.shape: {X.shape}")
|
||||
print(f"y.shape: {y.shape}" if not isinstance(y, list) else f"y(list)'s length: {len(y)}")
|
||||
print(f"X_test.shape: {X_test.shape}")
|
||||
print(f"test_ids length: {len(test_ids)}")
|
||||
X_loaded = deepcopy(X)
|
||||
y_loaded = deepcopy(y)
|
||||
X_test_loaded = deepcopy(X_test)
|
||||
X, y, X_test = feat_eng(X, y, X_test)
|
||||
|
||||
|
||||
def get_length(data):
|
||||
return len(data) if isinstance(data, list) else data.shape[0]
|
||||
|
||||
assert get_length(X_test) == get_length(test_ids), (
|
||||
f"Mismatch in length of test images and test IDs: X_test ({get_length(X_test)}) and test_ids ({get_length(test_ids)})"
|
||||
)
|
||||
assert get_length(X) == get_length(y), (
|
||||
f"Mismatch in length of training images and labels: X ({get_length(X)}) and y ({get_length(y)})"
|
||||
)
|
||||
|
||||
print("Feature Engineering test passed successfully. Length of test images matches length of test IDs.")
|
||||
def get_width(data):
|
||||
return 1 if isinstance(data, list) else data.shape[1:]
|
||||
|
||||
|
||||
def get_column_list(data):
|
||||
return data.columns.tolist() if isinstance(data, pd.DataFrame) else None
|
||||
|
||||
|
||||
assert get_length(X_test) == get_length(
|
||||
test_ids
|
||||
), f"Mismatch in length of test images and test IDs: X_test ({get_length(X_test)}) and test_ids ({get_length(test_ids)})"
|
||||
assert get_length(X) == get_length(
|
||||
y
|
||||
), f"Mismatch in length of training images and labels: X ({get_length(X)}) and y ({get_length(y)})"
|
||||
|
||||
assert get_length(X) != 0, f"Training data is empty."
|
||||
assert get_length(y) != 0, f"Training labels are empty."
|
||||
assert get_length(X_test) != 0, f"Test data is empty."
|
||||
|
||||
assert get_width(X) == get_width(
|
||||
X_test
|
||||
), "Mismatch in width of training and test data. Width means the number of features."
|
||||
|
||||
if isinstance(X, pd.DataFrame) and isinstance(X_test, pd.DataFrame):
|
||||
assert get_column_list(X) == get_column_list(X_test), "Mismatch in column names of training and test data."
|
||||
|
||||
assert sorted(X.dtypes.unique().tolist()) == sorted(
|
||||
X_loaded.dtypes.unique().tolist()
|
||||
), f"feature engineering has produced new data types which is not allowed, data loader data types are {X_loaded.dtypes.unique().tolist()} and feature engineering data types are {X.dtypes.unique().tolist()}"
|
||||
|
||||
print("Feature Engineering test passed successfully. All checks including length, width, and data types have been validated.")
|
||||
|
||||
Reference in New Issue
Block a user