Scaling and hyperparameter effects
Quick answer
SVM hyperparameters interact with the geometry of the data. Use a preprocessing pipeline so every training fold learns its own scaling parameters, and tune C and kernel settings on development folds before evaluating a locked holdout. Static examples tested locally with Python 3.13.5, scikit-learn 1.8.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Apply frozen scaling
train=[2,4,6]; held=[10]mean=sum(train)/len(train)scale=(sum((x-mean)**2 for x in train)/len(train))**0.5print(round((held[0]-mean)/scale,4))Observed local output:
3.6742The held-out value is transformed using training statistics only.
How it works
Standardization computes a mean and scale from training observations and applies the same transformation to future inputs. In a two-feature dataset measuring load in kilograms and temperature in degrees, the raw numeric ranges may differ greatly; changing kilograms to grams changes distances unless scaling is adjusted. A pipeline with StandardScaler followed by SVC makes each cloned validation fit learn preprocessing only from its training rows. Tune linear and RBF configurations on identical folds, record the scoring rule and fix a deterministic tie policy. A small gamma can underfit complex patterns and a large gamma may overfit local ones; C controls margin violations, not the same notion as gamma. Inspect support-vector count, fit cost and latency, not only validation accuracy. Kernel training may become expensive as row count grows; try a linear estimator or kernel approximation if the workload requires it, and measure rather than promising a speedup. SVC in scikit-learn 1.8 does not provide probability estimates by default. Enabling probability=True before fit uses additional internal cross-validation and can produce probabilities inconsistent with predict. For a separately calibrated classifier, keep calibration data separate within development and evaluate calibration on held-out data. The internal probability fitting does not by itself establish leakage-safe preprocessing for a custom grouped or time-dependent calibration protocol; prefer explicitly designed folds. For this chapter, probability is disabled and the metric is accuracy. Binary decision boundaries in 2D can be drawn by evaluating the score on a bounded grid and contouring zero; contours are numerical approximations, not exact symbolic boundaries.
Inspect the fitted pipeline
from sklearn.pipeline import make_pipelinefrom sklearn.preprocessing import StandardScalerfrom sklearn.svm import SVCX=[[0,0],[0,100],[2,0],[2,100]]; y=[0,0,1,1]m=make_pipeline(StandardScaler(),SVC(kernel="linear",C=1)).fit(X,y)print(m[0].mean_.tolist())print(m.predict([[0,50],[2,50]]).tolist())print(hasattr(m,"predict_proba"))Observed local output:
[1.0, 50.0][0, 1]FalseThe pipeline stores training means, predicts labels and has no default probability interface.
Common mistakes
Do not scale the entire dataset before cross-validation, tune on the final holdout or use an RBF decision score as probability. Do not claim equal parameter grids imply equal compute. A pretty 2D plot cannot establish robustness outside the sampled area.
Practice and next steps
Run the chapter project and compare the selected linear and RBF configurations and support counts. Inspect the training-only decision-boundary plot. Explain how you would change the split if observations came from repeated machines or later time periods. Complete the knowledge check and staged exercise. Next: Clustering and unsupervised learning.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Scaling and hyperparameter effects — knowledge check
Apply scaling and hyperparameter effects to new scenarios.
Where should scaling be fitted during cross-validation?
Which score selects hyperparameters?
Does default SVC return probabilities?
What does a zero decision contour show in binary SVC?
What should be measured as kernel datasets grow?