Hyperparameter tuning of Support Vector Machine in MATLAB
Let's create a code for hyper parameter optimization of SVM classifier using Harris hawks optimization algorithm. What is Hyperparameter Optimization? As the name indicates, hyperparameter optimization means, optimal selection of SVM parameters. Harris Hawks algorithm is adapted to optimally choose the SVM parameters like kernel functions and box constraints. Fitness function The fitness function is the minimization of classification error. Our objective is to find the best parameter setting with minimum classification error. function [ err , svmModel ] = fitness_fun ( p ) global traindata trainlabel valdata vallabela kernel = { ' gaussian ' , ' polynomial ' , ' linear ' }; op1 = kernel{ round ( p ( 1 ))}; kernelScale = round ( p ( 2 )); boxx = round ( p ( 3 )); svmModel = fitcsvm ( traindata , trainlabel , ... ' BoxConstraint ' , boxx , ... ' KernelFun...