File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -244,7 +244,12 @@ sc = StandardScaler()
244244X_train_std = sc.fit_transform(X_train)
245245X_test_std = sc.transform(X_test)
246246
247- data = [X_train_std, X_test_std, y_train, y_test]
247+ data = {
248+ " X_train" : X_train_std,
249+ " X_test" : X_test_std,
250+ " y_train" : y_train,
251+ " y_test" : y_test
252+ }
248253
249254
250255class SvmOptimizedProblem (Problem ):
@@ -260,11 +265,11 @@ class SvmOptimizedProblem(Problem):
260265 svc = SVC(C = C_paras, kernel = kernel_paras, degree = degree,
261266 gamma = gamma, probability = probability, random_state = 1 )
262267 # Fit the model
263- svc.fit(X_train_std, y_train)
268+ svc.fit(self .data[ " X_train " ], self .data[ " y_train" ] )
264269 # Make the predictions
265- y_predict = svc.predict(X_test_std )
270+ y_predict = svc.predict(self .data[ " X_test " ] )
266271 # Measure the performance
267- return metrics.accuracy_score(y_test, y_predict)
272+ return metrics.accuracy_score(self .data[ " y_test" ] , y_predict)
268273
269274my_bounds = [
270275 FloatVar(lb = 0.01 , ub = 1000 ., name = " C_paras" ),
You can’t perform that action at this time.
0 commit comments