precomputed kernel matrix, LibSVM

Nicklas03
Nicklas03 New Altair Community Member
edited November 5 in Community Q&A
Hi,

I would like to use precomputed kernel matrix in my experiment, because I need use chi square kernel. My questions:

1.) When I pick precomputed kernel in LibSVM, I don't know, how I insert precomputed kernel matrix into SVM.
2.) Format of file with precomputed kernel.

This is my experiment:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.0">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.0.10" expanded="true" name="Process">
    <process expanded="true" height="400" width="681">
      <operator activated="true" class="read_sparse" compatibility="5.0.10" expanded="true" height="60" name="Read Sparse" width="90" x="45" y="75">
        <parameter key="format" value="yx"/>
        <parameter key="data_file" value="D:\Praca\DataSet\trainDataSet.txt"/>
        <parameter key="dimension" value="16"/>
        <parameter key="use_quotes" value="false"/>
        <list key="prefix_map"/>
      </operator>
      <operator activated="true" class="optimize_parameters_grid" compatibility="5.0.10" expanded="true" height="112" name="Optimize Parameters (Grid)" width="90" x="179" y="75">
        <list key="parameters">
          <parameter key="SVM.C" value="[0.1;5000;3;logarithmic]"/>
          <parameter key="SVM.gamma" value="[0.00001;100;3;logarithmic]"/>
        </list>
        <process expanded="true" height="400" width="677">
          <operator activated="true" class="x_validation" compatibility="5.0.10" expanded="true" height="112" name="Validation" width="90" x="179" y="30">
            <parameter key="number_of_validations" value="6"/>
            <process expanded="true" height="400" width="313">
              <operator activated="true" class="support_vector_machine_libsvm" compatibility="5.0.10" expanded="true" height="76" name="SVM" width="90" x="112" y="30">
                <parameter key="kernel_type" value="precomputed"/>
                <parameter key="gamma" value="100.00000000000001"/>
                <parameter key="C" value="5000.0"/>
                <parameter key="cache_size" value="800"/>
                <list key="class_weights">
                  <parameter key="0" value="0.6088239"/>
                  <parameter key="1" value="0.3911761"/>
                </list>
              </operator>
              <connect from_port="training" to_op="SVM" to_port="training set"/>
              <connect from_op="SVM" from_port="model" to_port="model"/>
              <portSpacing port="source_training" spacing="0"/>
              <portSpacing port="sink_model" spacing="0"/>
              <portSpacing port="sink_through 1" spacing="0"/>
            </process>
            <process expanded="true" height="400" width="313">
              <operator activated="true" class="apply_model" compatibility="5.0.10" expanded="true" height="76" name="Apply Model" width="90" x="45" y="30">
                <list key="application_parameters"/>
              </operator>
              <operator activated="true" class="performance" compatibility="5.0.10" expanded="true" height="76" name="Performance" width="90" x="179" y="30"/>
              <connect from_port="model" to_op="Apply Model" to_port="model"/>
              <connect from_port="test set" to_op="Apply Model" to_port="unlabelled data"/>
              <connect from_op="Apply Model" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
              <connect from_op="Performance" from_port="performance" to_port="averagable 1"/>
              <portSpacing port="source_model" spacing="0"/>
              <portSpacing port="source_test set" spacing="0"/>
              <portSpacing port="source_through 1" spacing="0"/>
              <portSpacing port="sink_averagable 1" spacing="0"/>
              <portSpacing port="sink_averagable 2" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="log" compatibility="5.0.10" expanded="true" height="76" name="Log" width="90" x="380" y="165">
            <list key="log"/>
          </operator>
          <connect from_port="input 1" to_op="Validation" to_port="training"/>
          <connect from_op="Validation" from_port="model" to_port="result 1"/>
          <connect from_op="Validation" from_port="averagable 1" to_op="Log" to_port="through 1"/>
          <connect from_op="Log" from_port="through 1" to_port="performance"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="source_input 2" spacing="0"/>
          <portSpacing port="sink_performance" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
      <operator activated="true" class="read_sparse" compatibility="5.0.10" expanded="true" height="60" name="Read Sparse (2)" width="90" x="45" y="255">
        <parameter key="format" value="yx"/>
        <parameter key="data_file" value="D:\Praca\DataSet\testDataSet.txt"/>
        <parameter key="dimension" value="16"/>
        <parameter key="use_quotes" value="false"/>
        <list key="prefix_map"/>
      </operator>
      <operator activated="true" class="apply_model" compatibility="5.0.10" expanded="true" height="76" name="Apply Model (2)" width="90" x="380" y="210">
        <list key="application_parameters"/>
      </operator>
      <operator activated="true" class="performance" compatibility="5.0.10" expanded="true" height="76" name="Performance (2)" width="90" x="514" y="165"/>
      <connect from_op="Read Sparse" from_port="output" to_op="Optimize Parameters (Grid)" to_port="input 1"/>
      <connect from_op="Optimize Parameters (Grid)" from_port="performance" to_port="result 1"/>
      <connect from_op="Optimize Parameters (Grid)" from_port="parameter" to_port="result 2"/>
      <connect from_op="Optimize Parameters (Grid)" from_port="result 1" to_op="Apply Model (2)" to_port="model"/>
      <connect from_op="Read Sparse (2)" from_port="output" to_op="Apply Model (2)" to_port="unlabelled data"/>
      <connect from_op="Apply Model (2)" from_port="labelled data" to_op="Performance (2)" to_port="labelled data"/>
      <connect from_op="Performance (2)" from_port="performance" to_port="result 3"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
      <portSpacing port="sink_result 3" spacing="0"/>
      <portSpacing port="sink_result 4" spacing="0"/>
    </process>
  </operator>
</process>
Thank you.
Tagged:

Answers

  • MariusHelf
    MariusHelf New Altair Community Member
    Hi,

    as far as I know we don't yet support precomputed kernels (even if the GUI offers the option). What happens if you execute the process?
    Probably it would be a good idea to post a bug at bugs.rapid-i.com.

    Best, Marius