我在Enterprise Miner工作,看到了this video from SAS,其中他简要地展示了一个运行一堆SVM模型的SAS代码节点。
他没有展示整件事,但足以让我对如何做到这一点感到好奇。这是我到目前为止所得到的:
%macro hpsvm (run=1,runLabel=,penalty=10,method=activeSet,kernel=TBF);
proc hpsvm data=&em_import_data maxiter=25 metho = &method. tolerance=0.000001 c = &penalty.;
input %em_internal_input / level = interval;
target %em_target / level = binary ;
lernel &kernel.;
partition fraction (validate=.3 seed=12345);
ods output fitStatistics=fitStats&run.;
run;
data firStats&run.;
length method $ 10;
length kernel $ 10;
length runLabel $ 64;
set fitStats&run.;
run = &run;
runLabel = "&runLabel";
method="&method.";
kernel="&kernel.";
penalty=&penalty.;
run;
proc print data=fitStats&run.;
run;
proc append base=fitStats data=firStats&run.;
%mend hpsvm;
%hpsvm(run=1,runLabel=RBF c=1, method=activeSet, kernel=RBF,penalty=1);
%hpsvm(run=2,runLabel=RBF c=5, method=activeSet, kernel=RBF,penalty=5);
%hpsvm(run=3,runLabel=RBF c=10, method=activeSet, kernel=RBF,penalty=10);
%hpsvm(run=4,runLabel=RBF c=15, method=activeSet, kernel=RBF,penalty=15);
%hpsvm(run=5,runLabel=RBF c=20, method=activeSet, kernel=RBF,penalty=20);
%hpsvm(run=6,runLabel=Linear c=1, method=ipoint, kernel=linear,penalty=1);
%hpsvm(run=7,runLabel=Linear c=5, method=ipoint, kernel=linear,penalty=5);
%hpsvm(run=8,runLabel=Linear c=10, method=ipoint, kernel=linear,penalty=10);
%hpsvm(run=9,runLabel=Linear c=15, method=ipoint, kernel=linear,penalty=15);
%hpsvm(run=10,runLabel=Linear c=20, method=ipoint, kernel=linear,penalty=20);
%hpsvm(run=11,runLabel=Polynomial c=1, method=ipoint, kernel=POLYNOM,penalty=1);
%hpsvm(run=12,runLabel=Polynomial c=5, method=ipoint, kernel=POLYNOM,penalty=5);
%hpsvm(run=13,runLabel=Polynomial c=10, method=ipoint, kernel=POLYNOM,penalty=10);
%hpsvm(run=14,runLabel=Polynomial c=15, method=ipoint, kernel=POLYNOM,penalty=15);
%hpsvm(run=15,runLabel=Polynomial c=20, method=ipoint, kernel=POLYNOM,penalty=20);
%hpsvm(run=16,runLabel=Sigmoid c=1, method=activeSet, kernel=SIGMOID,penalty=1);
%hpsvm(run=17,runLabel=Sigmoid c=5, method=activeSet, kernel=SIGMOID,penalty=5);
%hpsvm(run=18,runLabel=Sigmoid c=10, method=activeSet, kernel=SIGMOID,penalty=10);
%hpsvm(run=19,runLabel=Sigmoid c=15, method=activeSet, kernel=SIGMOID,penalty=15);
%hpsvm(run=20,runLabel=Sigmoid c=20, method=activeSet, kernel=SIGMOID,penalty=20);
data fitStats;
retain run runLabel method kernal penalty;
set fitStats;
run;
%em_register(type=Data,key=fitStats);
data &em_user_fitStats;
retain Penalty;
set fitStats;
run;
%em_report(viewType=data,key=fitStats,autodisplay=y,description=Fit Statistics by Run);
%em_register(type=Data,key=Error);
有几点需要注意:
我希望运行许多SVM模型来尝试不同的选项组合以找到最佳模型。
答案 0 :(得分:0)
SAS实际上通过电子邮件向我发送了密码!
%macro hpsvm (run=1,runLabel=,penalty=10,method=activeSet,kernel=RBF);
proc hpsvm data=&em_import_data maxiter=25 method = &method. tolerance=0.000001 c = &Penalty.;
input %em_interval_input / level = interval;
target %em_target / level = binary ;
kernel &kernel.;
partition fraction (validate=.3 seed=12345);
ods output fitStatistics=fitStats&run.;
run;
data fitStats&run.;
length method $ 10;
length kernel $ 10;
length runLabel $ 64;
set fitStats&run.;
run = &run;
runLabel = "&runLabel";
method="&method.";
kernel="&kernel.";
penalty=&penalty.;
run;
proc print data=fitStats&run.;
run;
proc append base=fitStats data=fitStats&run.;
run;
%mend hpsvm;
%hpsvm(run=1,runLabel=RBF c=1,method=activeSet,kernel=RBF,penalty=1);
%hpsvm(run=2,runLabel=RBF c=5,method=activeSet,kernel=RBF,penalty=5);
%hpsvm(run=3,runLabel=RBF c=10,method=activeSet,kernel=RBF,penalty=10);
%hpsvm(run=4,runLabel=RBF c=15,method=activeSet,kernel=RBF,penalty=15);
%hpsvm(run=5,runLabel=RBF c=20,method=activeSet,kernel=RBF,penalty=20);
%hpsvm(run=6,runLabel=Linear c=1,method=ipoint,kernel=linear,penalty=1);
%hpsvm(run=7,runLabel=Linear c=5,method=ipoint,kernel=linear,penalty=5);
%hpsvm(run=8,runLabel=Linear c=10,method=ipoint,kernel=linear,penalty=10);
%hpsvm(run=9,runLabel=Linear c=15,method=ipoint,kernel=linear,penalty=15);
%hpsvm(run=10,runLabel=Linear c=20,method=ipoint,kernel=linear,penalty=20);
%hpsvm(run=11,runLabel=RBF c=1,method=ipoint,kernel=POLYNOM,penalty=1);
%hpsvm(run=12,runLabel=RBF c=5,method=ipoint,kernel=POLYNOM,penalty=5);
%hpsvm(run=13,runLabel=RBF c=10,method=ipoint,kernel=POLYNOM,penalty=10);
%hpsvm(run=14,runLabel=RBF c=15,method=ipoint,kernel=POLYNOM,penalty=15);
%hpsvm(run=15,runLabel=RBF c=20,method=ipoint,kernel=POLYNOM,penalty=20);
%hpsvm(run=16,runLabel=Linear c=1,method=activeSet,kernel=SIGMOID,penalty=1);
%hpsvm(run=17,runLabel=Linear c=5,method=activeSet,kernel=SIGMOID,penalty=5);
%hpsvm(run=18,runLabel=Linear c=10,method=activeSet,kernel=SIGMOID,penalty=10);
%hpsvm(run=19,runLabel=Linear c=15,method=activeSet,kernel=SIGMOID,penalty=15);
%hpsvm(run=20,runLabel=Linear c=20,method=activeSet,kernel=SIGMOID,penalty=20);
data fitStats;
retain run runLabel method kernel penalty;
set fitStats;
run;
proc print data=fitStats;
run;
%em_register(type=Data,key=fitStats);
data &em_user_fitStats;
retain Penalty;
set fitStats;
run;
%em_report(viewType=data,key=fitStats,autodisplay=y,description=Fit Statistics by Run);
%em_register(type=Data,key=Error);
data &em_user_Error;
set fitStats;
if statistic = 'Error';
run;
%em_report(viewType=lineplot,key=Error,x=penalty,y=validation,group=kernel,description=Classification Error by penalty,autodisplay=y);
%em_register(type=Data,key=Sensitivity);
data &em_user_Sensitivity;
set fitStats;
if statistic = 'Sensitivity';
run;
%em_report(viewType=lineplot,key=Sensitivity,x=penalty,y=validation,group=kernel,description=Sensitivity by penalty,autodisplay=y);
%em_register(type=Data,key=Specificity);
data &em_user_Specificity;
set fitStats;
if statistic = 'Specificity';
run;
%em_report(viewType=lineplot,key=Specificity,x=penalty,y=validation,group=kernel,description=Specificity by penalty,autodisplay=y);