Skip to content

Instantly share code, notes, and snippets.

@ymattu
Created February 22, 2016 09:42
Show Gist options
  • Save ymattu/5f5dde1e4463aa193311 to your computer and use it in GitHub Desktop.
Save ymattu/5f5dde1e4463aa193311 to your computer and use it in GitHub Desktop.
****(1). Data exploration of iris flower data set****;
data iris;
set sashelp.iris;
run;
proc contents data=iris position;
run;
proc princomp data=iris out=iris_pca;
var Sepal: Petal:;
run;
proc sgplot data=iris_pca;
scatter x = prin1 y = prin2 / group = species;
run;
****(2). Cross validation error comparison of 4 kernels****;
proc dmdb batch data=iris dmdbcat=_cat out=_iris;
var Sepal: Petal:;
class species;
run;
%let knl = linear;
proc svm data=_iris dmdbcat=_cat kernel=&knl c=1 cv =loo;
title "The kernel is &knl";
ods output restab = &knl;
var Sepal: Petal:;
target species;
run;
%let knl = rbf;
proc svm data=_iris dmdbcat=_cat kernel=&knl c=1 K_PAR=1 cv=loo;
title "The kernel is &knl";
ods output restab = &knl;
var Sepal: Petal:;
target species;
run;
%let knl = polynom;
proc svm data=_iris dmdbcat=_cat kernel=&knl c=1 K_PAR =3 cv=loo;
title "The kernel is &knl";
ods output restab = &knl;
var Sepal: Petal:;
target species;
run;
%let knl = sigmoid;
proc svm data=_iris dmdbcat=_cat kernel=&knl c=1 K_PAR=1 K_PAR2=1 cv=loo;
title "The kernel is &knl";
ods output restab = &knl;
var Sepal: Petal:;
target species;
run;
data total;
set linear rbf polynom sigmoid;
where label1 in ('Kernel Function','Classification Error (Loo)');
cValue1 = lag(cValue1);
if missing(nValue1) = 0;
run;
proc sgplot data=total;
title " ";
vbar cValue1 / response = nValue1;
xaxis label = "Selection of kernel";
yaxis label = "Classification Error by Leave-one-out Cross Validation";
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment