Commit cd30cd59 authored by thecml's avatar thecml
Browse files

fixed unit tests

parent 0aa9674e
Pipeline #96554 passed with stage
in 4 minutes and 27 seconds
......@@ -34,7 +34,7 @@ class BaseClassifer(ABC):
estimator object implementing 'fit'.
"""
def evaluate(self, metrics:List=None, k: int=0) -> Tuple[dict,np.ndarray]:
def evaluate(self, metrics:List, k:int) -> Tuple[dict,np.ndarray]:
"""
This method performs cross validation for k seeds
on a given dataset X and y and outputs the results
......
......@@ -90,8 +90,8 @@ def get_citizen_data(data: data_dto.Data, citizen_id: str) -> data_dto.Data:
training_done = data.td.loc[data.td['CitizenId'] == str(citizen_id)]
training_cancelled = data.tc.loc[data.tc['CitizenId'] == str(citizen_id)]
ats = data.ats.loc[data.ats['CitizenId'] == str(citizen_id)]
citizen_data = data.Data(screening_content, status_set,
training_done, training_cancelled, ats)
citizen_data = data_dto.Data(screening_content, status_set,
training_done, training_cancelled, ats)
return citizen_data
def get_screening_data(td: pd.DataFrame, tc: pd.DataFrame,
......
......@@ -43,6 +43,7 @@ class NeuralEmbedder:
def __init__(self,
df: pd.DataFrame,
target_name: str,
metrics: List[str],
train_ratio: float = 0.8,
network_layers: List[int] = (32, 32),
dropout_rate: float = 0,
......@@ -51,7 +52,6 @@ class NeuralEmbedder:
regularization_factor: float = 0,
loss_fn: str ='binary_crossentropy',
optimizer_fn: str = 'Adam',
metrics: List[str] = None,
epochs: int = 10,
batch_size: int = 32,
verbose: bool = False,
......
......@@ -8,7 +8,7 @@ def test_xgb_classifier():
random_state=0, n_clusters_per_class=1)
X = pd.DataFrame(X)
y = pd.Series(y)
result = XgbClassifier(X, y).evaluate()
result = XgbClassifier(X, y).evaluate(metrics=['accuracy'], k=0)
assert result is not None
def test_rf_classifier():
......@@ -16,7 +16,7 @@ def test_rf_classifier():
random_state=0, n_clusters_per_class=1)
X = pd.DataFrame(X)
y = pd.Series(y)
result = RfClassifier(X, y).evaluate()
result = RfClassifier(X, y).evaluate(metrics=['accuracy'], k=0)
assert result is not None
def test_knn_classifier():
......@@ -24,7 +24,7 @@ def test_knn_classifier():
random_state=0, n_clusters_per_class=1)
X = pd.DataFrame(X)
y = pd.Series(y)
result = KnnClassifier(X, y).evaluate()
result = KnnClassifier(X, y).evaluate(metrics=['accuracy'], k=0)
assert result is not None
def test_lr_classifier():
......@@ -32,13 +32,13 @@ def test_lr_classifier():
random_state=0, n_clusters_per_class=1)
X = pd.DataFrame(X)
y = pd.Series(y)
result = LrClassifier(X, y).evaluate()
result = LrClassifier(X, y).evaluate(metrics=['accuracy'], k=0)
assert result is not None
def test_mlp_classifier():
X, y = make_classification(n_features=2, n_redundant=0, n_informative=2,
random_state=0, n_clusters_per_class=1)
result = MlpClassifier(X, y).evaluate()
result = MlpClassifier(X, y).evaluate(metrics=['accuracy'], k=0)
assert result is not None
def test_svm_classifier():
......@@ -46,5 +46,5 @@ def test_svm_classifier():
random_state=0, n_clusters_per_class=1)
X = pd.DataFrame(X)
y = pd.Series(y)
result = SvmClassifier(X, y).evaluate()
result = SvmClassifier(X, y).evaluate(metrics=['accuracy'], k=0)
assert result is not None
......@@ -37,7 +37,7 @@ def test_predict_complete(get_data):
assert_split(X, y)
result = RfClassifier(X, y).evaluate()
result = RfClassifier(X, y).evaluate(metrics = ['accuracy'], k=0)
assert result is not None
def assert_split(X, y):
......
......@@ -30,6 +30,7 @@ def test_fit():
num_epochs = 10
network = neural_embedder.NeuralEmbedder(df=df_to_enc,
target_name=target_name,
metrics=['accuracy'],
epochs=num_epochs)
history = network.fit(X_train, y_train, X_val, y_val)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment