Skip to content

Commit c1e4162

Browse files
author
SamoraHunter
committed
implemented standard scaler into svc model to prevent ValueError: The dual coefficients or intercepts are not finite
1 parent fa48068 commit c1e4162

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

ml_grid/model_classes_ga/svc_model.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import numpy as np
77
from sklearn import metrics
88
from sklearn.metrics import matthews_corrcoef
9+
from sklearn.pipeline import make_pipeline
10+
from sklearn.preprocessing import StandardScaler
911
from sklearn.svm import SVC
1012

1113
from ml_grid.util.debug_methods_ga import debug_base_learner
@@ -18,7 +20,7 @@
1820

1921
def SVC_ModelGenerator(
2022
ml_grid_object: Any, local_param_dict: Dict
21-
) -> Tuple[float, SVC, List[str], int, float, np.ndarray]:
23+
) -> Tuple[float, Any, List[str], int, float, np.ndarray]:
2224
"""Generates, trains, and evaluates a Support Vector Classifier (SVC) model.
2325
2426
This function performs a single trial of training and evaluating an SVC
@@ -102,7 +104,7 @@ def SVC_ModelGenerator(
102104
sample_parameter_space[key] = random.choice(parameter_space.get(key))
103105

104106
# fit model with random sample of global parameter space
105-
model = SVC(**sample_parameter_space)
107+
model = make_pipeline(StandardScaler(), SVC(**sample_parameter_space))
106108

107109
try:
108110
# Train the model--------------------------------------------------------------------

0 commit comments

Comments
 (0)