2.1.1 Kernels: 1. Find the code that defines the abstract kernel definition and report what types of kernels are available in WEKA/LibSVM respectively (as well as where/how they are implemented). weka/src/main/java/weka/classifiers/functions/supportVector/Kernel.java <- defines the abstract kernel class. Following Kernels are supported by default: All Kernels are implemented in its own class. Polykernel -> weka/src/main/java/weka/classifiers/functions/supportVector/PolyKernel.java NormalizedPoykernel -> weka/src/main/java/weka/classifiers/functions/supportVector/NormalizedPolyKernel.java PrecomputedKernelMatrixKernel -> weka/src/main/java/weka/classifiers/functions/supportVector/PrecomputedKernelMatrixKernel.java Puk -> weka/src/main/java/weka/classifiers/functions/supportVector/Puk.java RBFKernel -> weka/src/main/java/weka/classifiers/functions/supportVector/RBFKernel.java StringKernel -> weka/src/main/java/weka/classifiers/functions/supportVector/StringKernel.java 2. How would you go about implementing an additional kernel? Extends from class kernel to implement an own implementation. 3. Describe the process involved in computing the dot product (svm.cpp:294ff., operation Kernel::dot; weka.classifiers.functions.supportVector.CachedKernel#dotProd, lines 292ff.) including what are the arguments to the respective functions. protected final double dotProd(Instance inst1, Instance inst2) throws Exception { double result = 0; // we can do a fast dot product int n1 = inst1.numValues(); // length of array 1 int n2 = inst2.numValues(); // length of array 2 int classIndex = m_data.classIndex(); for (int p1 = 0, p2 = 0; p1 < n1 && p2 < n2;) { int ind1 = inst1.index(p1); int ind2 = inst2.index(p2); // returns the index on given position. if (ind1 == ind2) { if (ind1 != classIndex) { result += inst1.valueSparse(p1) * inst2.valueSparse(p2); // add the multiplication of (value at postition p1 of inst1, value at postition p2 of inst2 ) to final result. } p1++; p2++; } else if (ind1 > ind2) { p2++; } else { p1++; } } return (result); } 4. Describe the caching that is going on in both libraries (LRU refers to least-recentlyused cache). What is being cached and why is this relevant? CacheKernel class: implements a simple LRU (least-recently-used) cache if the cache size is set to a value > 0, otherwise it uses a full cache. LRU: m_storage, m_keys Full cache: m_kernelMatrix --> dot product is being cached, for performance reason 2.1.2 Sequential Minimal Optimization: 1. As described in the lectures, SMO alternates between finding two parameters α to optimize, and optimizing their values. Find this loop in both implementations and name the methods used for performing the two steps. It is defined in the method "buildClassifier" weka/src/main/java/weka/classifiers/functions/SMO.java (from line 588) 2. Identify the code that performs the ‘clipping’ of lagrange multipliers as described in the lecture notes on page 25. Can you find the optimization computations involved in finding the new value for αi and αj? it is implemented in takeStep (L925) weka/src/main/java/weka/classifiers/functions/SMO.java. The method its self gets called by examineExample which is called from buildClassifyer. 3. Describe where in the code the mapping function Φ is being computed.