Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用SAS代码运行多个SVM模型?_Sas - Fatal编程技术网

如何使用SAS代码运行多个SVM模型?

如何使用SAS代码运行多个SVM模型?,sas,Sas,我在EnterpriseMiner和saw工作,他在其中简要展示了一个SAS代码节点来运行一系列SVM模型 他并没有展示全部内容,但足以让我好奇如何做到这一点。以下是到目前为止我所能得到的: %macro hpsvm (run=1,runLabel=,penalty=10,method=activeSet,kernel=TBF); proc hpsvm data=&em_import_data maxiter=25 metho = &method. tolerance=

我在EnterpriseMiner和saw工作,他在其中简要展示了一个SAS代码节点来运行一系列SVM模型

他并没有展示全部内容,但足以让我好奇如何做到这一点。以下是到目前为止我所能得到的:

%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);
关于这一点,需要注意以下几点:

  • 我使用的是来自UCI的(但请让我知道如何将数据输出为良好的格式,我将在这里添加一些)
  • 这应该使用来自上一个节点(数据分区)的数据运行
  • 我能看出的唯一错误是没有在正确的位置使用引号或分号,但在我看来一切正常(几乎没有SAS编码经验)
  • 他没有显示代码的剩余1/5

我希望运行许多SVM模型,尝试不同的选项组合,以找到最佳模型。

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);

现在这个问题还不是很容易解决。它太大,细节太少;首先,您需要指定具体的错误。另一方面,这听起来像是你在尝试之前需要做更多的学习;这不是小事,如果你基本上没有SAS编码经验,我认为这更是你现在的问题。@Joe你似乎不知道你在说什么。尝试使用企业管理器几个星期,你也会遇到同样的问题。@TravisHeeter你是说企业矿工吗?还是模特经理?SAS EM很难使用,但我不确定这与Joe的陈述有什么关系。我也不知道你在问什么。上面的代码不起作用?在构建宏之前,应该先编写工作代码,然后逐步添加宏变量。您的代码中有几个错误,最明显的是最后缺少运行,但这也不一定是致命错误。你也没有发布错误日志……这里是一篇关于如何创建数据供其他人在任何论坛中使用的帖子。