The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

applying optimal parameters to SVM model

m_r_nourm_r_nour Member Posts: 35 Maven
edited October 2019 in Help
Hi

I wrote the following to code to get optimal parameters for a libsvm model then applying them to  the model.

The codes is successful to do frist step (find the opimumum  C, gamma) however I can't apply them in my model :
<operator name="Root" class="Process" expanded="yes">
    <operator name="ExampleSetGenerator" class="ExampleSetGenerator">
        <parameter key="target_function" value="polynomial classification"/>
    </operator>
    <operator name="IOStorer" class="IOStorer">
        <parameter key="name" value="datacopy"/>
        <parameter key="io_object" value="ExampleSet"/>
        <parameter key="remove_from_process" value="false"/>
    </operator>
    <operator name="GridParameterOptimization" class="GridParameterOptimization" expanded="yes">
        <list key="parameters">
          <parameter key="LibSVMLearner.C" value="[1.0;200.0;1;linear]"/>
          <parameter key="LibSVMLearner.gamma" value="[0.0;1.0;1;linear]"/>
        </list>
        <operator name="XValidation (2)" class="XValidation" expanded="yes">
            <operator name="LibSVMLearner" class="LibSVMLearner">
                <parameter key="C" value="200.0"/>
                <list key="class_weights">
                </list>
            </operator>
            <operator name="OperatorChain" class="OperatorChain" expanded="yes">
                <operator name="ModelApplier" class="ModelApplier">
                    <list key="application_parameters">
                    </list>
                </operator>
                <operator name="BinominalClassificationPerformance" class="BinominalClassificationPerformance">
                    <parameter key="main_criterion" value="specificity"/>
                    <parameter key="precision" value="true"/>
                    <parameter key="recall" value="true"/>
                    <parameter key="f_measure" value="true"/>
                    <parameter key="false_positive" value="true"/>
                    <parameter key="false_negative" value="true"/>
                    <parameter key="true_positive" value="true"/>
                    <parameter key="true_negative" value="true"/>
                    <parameter key="sensitivity" value="true"/>
                    <parameter key="specificity" value="true"/>
                </operator>
            </operator>
        </operator>
        <operator name="ProcessLog (2)" class="ProcessLog">
            <parameter key="filename" value="output_%{a}.log"/>
            <list key="log">
              <parameter key="File" value="operator.CSVExampleSource.parameter.filename"/>
              <parameter key="Iteration" value="operator.GridParameterOptimization.value.applycount"/>
              <parameter key="gamma" value="operator.LibSVMLearner.parameter.gamma"/>
              <parameter key="C" value="operator.LibSVMLearner.parameter.C"/>
              <parameter key="Performance_main criterion" value="operator.XValidation (2).value.performance"/>
              <parameter key="Deviation" value="operator.XValidation (2).value.deviation"/>
              <parameter key="sdfg" value="operator.GridParameterOptimization.value.performance"/>
            </list>
            <parameter key="sorting_dimension" value="3"/>
        </operator>
    </operator>
    <operator name="IORetriever" class="IORetriever">
        <parameter key="name" value="datacopy"/>
        <parameter key="io_object" value="ExampleSet"/>
    </operator>
    <operator name="ParameterSetter" class="ParameterSetter">
        <list key="name_map">
          <parameter key="Opt_svm" value="Opt_svm"/>
        </list>
    </operator>
    <operator name="OPT_XValidation" class="XValidation" expanded="yes">
        <parameter key="sampling_type" value="shuffled sampling"/>
        <operator name="Opt_svm" class="LibSVMLearner">
            <parameter key="gamma" value="0.5"/>
            <parameter key="C" value="100.0"/>
            <list key="class_weights">
            </list>
        </operator>
        <operator name="Opt_ApplierChain" class="OperatorChain" expanded="yes">
            <operator name="Opt_Applier" class="ModelApplier">
                <list key="application_parameters">
                </list>
            </operator>
            <operator name="Opt_Performance" class="BinominalClassificationPerformance">
                <parameter key="main_criterion" value="specificity"/>
                <parameter key="precision" value="true"/>
                <parameter key="recall" value="true"/>
                <parameter key="f_measure" value="true"/>
                <parameter key="false_positive" value="true"/>
                <parameter key="false_negative" value="true"/>
                <parameter key="true_positive" value="true"/>
                <parameter key="true_negative" value="true"/>
                <parameter key="sensitivity" value="true"/>
                <parameter key="specificity" value="true"/>
            </operator>
        </operator>
    </operator>
    <operator name="saving output" class="OperatorChain" expanded="no">
        <operator name="PerformanceWriter" class="PerformanceWriter">
            <parameter key="performance_file" value="wrapper_per"/>
        </operator>
        <operator name="ResultWriter (2)" class="ResultWriter">
            <parameter key="result_file" value="wrapper_results"/>
        </operator>
        <operator name="ProcessLog (3)" class="ProcessLog">
            <parameter key="filename" value="output_%{a}.log"/>
            <list key="log">
              <parameter key="File" value="operator.CSVExampleSource.parameter.filename"/>
              <parameter key="Iteration" value="operator.ParameterIteration.value.iteration"/>
              <parameter key="gamma" value="operator.Opt_svm.parameter.gamma"/>
              <parameter key="C" value="operator.Opt_svm.parameter.C"/>
              <parameter key="Performance_main criterion" value="operator.OPT_XValidation.value.performance"/>
              <parameter key="Deviation" value="operator.OPT_XValidation.value.deviation"/>
            </list>
            <parameter key="sorting_dimension" value="3"/>
        </operator>
    </operator>
</operator>

I'd appreciate if you help me


Regards

Tagged:

Answers

  • haddockhaddock Member Posts: 849 Maven
    Greetings,

    Just a small slip in the parameter setter I think, as this seems to work...
    <operator name="Root" class="Process" expanded="yes">
        <operator name="ExampleSetGenerator" class="ExampleSetGenerator">
            <parameter key="target_function" value="polynomial classification"/>
        </operator>
        <operator name="IOStorer" class="IOStorer">
            <parameter key="name" value="datacopy"/>
            <parameter key="io_object" value="ExampleSet"/>
            <parameter key="remove_from_process" value="false"/>
        </operator>
        <operator name="GridParameterOptimization" class="GridParameterOptimization" expanded="yes">
            <list key="parameters">
              <parameter key="LibSVMLearner.C" value="[1.0;200.0;1;linear]"/>
              <parameter key="LibSVMLearner.gamma" value="[0.0;1.0;1;linear]"/>
            </list>
            <operator name="XValidation (2)" class="XValidation" expanded="yes">
                <operator name="LibSVMLearner" class="LibSVMLearner">
                    <parameter key="gamma" value="1.0"/>
                    <parameter key="C" value="200.0"/>
                    <list key="class_weights">
                    </list>
                </operator>
                <operator name="OperatorChain" class="OperatorChain" expanded="yes">
                    <operator name="ModelApplier" class="ModelApplier">
                        <list key="application_parameters">
                        </list>
                    </operator>
                    <operator name="BinominalClassificationPerformance" class="BinominalClassificationPerformance">
                        <parameter key="main_criterion" value="specificity"/>
                        <parameter key="precision" value="true"/>
                        <parameter key="recall" value="true"/>
                        <parameter key="f_measure" value="true"/>
                        <parameter key="false_positive" value="true"/>
                        <parameter key="false_negative" value="true"/>
                        <parameter key="true_positive" value="true"/>
                        <parameter key="true_negative" value="true"/>
                        <parameter key="sensitivity" value="true"/>
                        <parameter key="specificity" value="true"/>
                    </operator>
                </operator>
            </operator>
            <operator name="ProcessLog (2)" class="ProcessLog">
                <parameter key="filename" value="output_%{a}.log"/>
                <list key="log">
                  <parameter key="File" value="operator.CSVExampleSource.parameter.filename"/>
                  <parameter key="Iteration" value="operator.GridParameterOptimization.value.applycount"/>
                  <parameter key="gamma" value="operator.LibSVMLearner.parameter.gamma"/>
                  <parameter key="C" value="operator.LibSVMLearner.parameter.C"/>
                  <parameter key="Performance_main criterion" value="operator.XValidation (2).value.performance"/>
                  <parameter key="Deviation" value="operator.XValidation (2).value.deviation"/>
                  <parameter key="sdfg" value="operator.GridParameterOptimization.value.performance"/>
                </list>
                <parameter key="sorting_dimension" value="3"/>
            </operator>
        </operator>
        <operator name="IORetriever" class="IORetriever">
            <parameter key="name" value="datacopy"/>
            <parameter key="io_object" value="ExampleSet"/>
        </operator>
        <operator name="ParameterSetter" class="ParameterSetter">
            <list key="name_map">
              <parameter key="LibSVMLearner" value="Opt_svm"/>
            </list>
        </operator>
        <operator name="OPT_XValidation" class="XValidation" expanded="no">
            <parameter key="sampling_type" value="shuffled sampling"/>
            <operator name="Opt_svm" class="LibSVMLearner">
                <parameter key="C" value="200.0"/>
                <list key="class_weights">
                </list>
            </operator>
            <operator name="Opt_ApplierChain" class="OperatorChain" expanded="yes">
                <operator name="Opt_Applier" class="ModelApplier">
                    <list key="application_parameters">
                    </list>
                </operator>
                <operator name="Opt_Performance" class="BinominalClassificationPerformance">
                    <parameter key="main_criterion" value="specificity"/>
                    <parameter key="precision" value="true"/>
                    <parameter key="recall" value="true"/>
                    <parameter key="f_measure" value="true"/>
                    <parameter key="false_positive" value="true"/>
                    <parameter key="false_negative" value="true"/>
                    <parameter key="true_positive" value="true"/>
                    <parameter key="true_negative" value="true"/>
                    <parameter key="sensitivity" value="true"/>
                    <parameter key="specificity" value="true"/>
                </operator>
            </operator>
        </operator>
        <operator name="saving output" class="OperatorChain" expanded="no">
            <operator name="PerformanceWriter" class="PerformanceWriter">
                <parameter key="performance_file" value="wrapper_per"/>
            </operator>
            <operator name="ResultWriter (2)" class="ResultWriter">
                <parameter key="result_file" value="wrapper_results"/>
            </operator>
            <operator name="ProcessLog (3)" class="ProcessLog">
                <parameter key="filename" value="output_%{a}.log"/>
                <list key="log">
                  <parameter key="File" value="operator.CSVExampleSource.parameter.filename"/>
                  <parameter key="Iteration" value="operator.ParameterIteration.value.iteration"/>
                  <parameter key="gamma" value="operator.Opt_svm.parameter.gamma"/>
                  <parameter key="C" value="operator.Opt_svm.parameter.C"/>
                  <parameter key="Performance_main criterion" value="operator.OPT_XValidation.value.performance"/>
                  <parameter key="Deviation" value="operator.OPT_XValidation.value.deviation"/>
                </list>
                <parameter key="sorting_dimension" value="3"/>
            </operator>
        </operator>
    </operator>
  • m_r_nourm_r_nour Member Posts: 35 Maven
    thanks haddock

    it works well :D

    Regards
    REZA
Sign In or Register to comment.