advanced data mining with weka
play

Advanced Data Mining with Weka Class 3 Lesson 1 LibSVM and - PowerPoint PPT Presentation

Advanced Data Mining with Weka Class 3 Lesson 1 LibSVM and LibLINEAR Ian Witten Department of Computer Science University of Waikato New Zealand weka.waikato.ac.nz Lesson 3.1: LibSVM and LibLINEAR Class 1 Time series forecasting Lesson


  1. Advanced Data Mining with Weka Class 3 – Lesson 1 LibSVM and LibLINEAR Ian Witten Department of Computer Science University of Waikato New Zealand weka.waikato.ac.nz

  2. Lesson 3.1: LibSVM and LibLINEAR Class 1 Time series forecasting Lesson 3.1 LibSVM and LibLINEAR Class 2 Data stream mining in Weka and MOA Lesson 3.2 Setting up R with Weka Class 3 Interfacing to R and other data Lesson 3.3 Using R to plot data mining packages Lesson 3.4 Using R to run a classifier Class 4 Distributed processing with Apache Spark Lesson 3.5 Using R to preprocess data Class 5 Scripting Weka in Python Lesson 3.6 Application: Functional MRI Neuroimaging data

  3. LibSVM and LibLINEAR Install the packages LibSVM and LibLINEAR (also install gridSearch)  Written by the same people (National Taiwan University)  LibSVM and LibLINEAR widely used outside Weka  Weka’s most popular packages! Support Vector Machines  Both packages implement them – Weka already has SMO ( Data Mining with Weka Lesson 4.5) – ... but LibSVM is more flexible; LibLINEAR can be much faster  SVMs can be linear or non-linear: “kernel” functions  SVMs can do classification or regression – Weka already has SMOreg for regression  gridSearch will be used to optimize parameters for SVMs

  4. LibSVM and LibLINEAR SMO/SMOreg LibSVM LibLINEAR Linear SVM? yes yes yes Non-linear kernels? yes yes no 1-class classification? no yes no ... two-class classification when there are no negative examples Logistic regression? no no yes ... Logistic classifier ( Data Mining with Weka Lesson 4.4) Very fast? no no yes! L1 norm? no no yes ... minimize sum of absolute values, not sum of squares

  5. LibSVM and LibLINEAR LibLINEAR Speed test  Data generator: 10,000 instances of LED24 data, percentage split evaluation – LibLinear 2 secs to build model – LibSVM, default parameters (RBF kernel) 18 secs choose linear kernel 10 sec – SMO, default parameters (linear) 21 secs

  6. LibSVM and LibLINEAR Linear boundary  small margin  0 errors on training data

  7. LibSVM and LibLINEAR Linear boundary  small margin  0 errors on training data  4 errors on test data

  8. LibSVM and LibLINEAR Linear boundary  small margin  0 errors on training data  4 errors on test data

  9. LibSVM and LibLINEAR Linear boundary  small margin

  10. LibSVM and LibLINEAR Linear boundary  large margin  1 error on training data

  11. LibSVM and LibLINEAR Linear boundary  small margin  1 error on training data  0 errors on test data

  12. LibSVM and LibLINEAR Linear boundary  LibLINEAR  LibSVM with linear kernel (or SMO)  21 errors on the training set

  13. LibSVM and LibLINEAR Nonlinear boundary  LibSVM, RBF kernel default parameters cost=1, gamma=0  9 errors on training set Do it!  with BoundaryVisualizer  in Explorer

  14. LibSVM and LibLINEAR Nonlinear boundary  LibSVM: OK parameters cost=10, gamma=0  0 errors on training set  Poor generalization

  15. LibSVM and LibLINEAR Nonlinear boundary  LibSVM optimized parameters cost=1000, gamma=10  0 errors on training set  Good generalization

  16. LibSVM and LibLINEAR Optimizing LibSVM parameters with gridSearch

  17. LibSVM and LibLINEAR 10 i from 10 3 gridSearch defaults down to 10 –3 steps of 1 10 i C : 10 3 , 10 2 , 10, 1, 10 –1 , 10 –2 , 10 –3 from 10 3 kernel.gamma : 10 3 , 10 2 , 10, 1, 10 –1 , 10 –2 , 10 – 3 down to 10 –3 use SMOreg (regression) steps of 1 evaluate using correlation coefficient

  18. LibSVM and LibLINEAR 10 i from 10 3 Optimizing LibSVM parameters down to 10 –3 with gridSearch cost steps of 1 LibSVM: parameters cost, gamma 10 i cost : 10 3 , 10 2 , 10, 1, 10 –1 , 10 –2 , 10 –3 from 10 3 gamma : 10 3 , 10 2 , 10, 1, 10 –1 , 10 –2 , 10 –3 down to 10 –3 use LibSVM (classification) gamma steps of 1 evaluate using Accuracy LibSVM Accuracy  cost = 1000, gamma = 10

  19. LibSVM and LibLINEAR 10 i SMO from 10 3 Optimizing LibSVM parameters down to 10 –3 with gridSearch c steps of 1 (RBFKernel): c, kernel.gamma 10 i c : 10 3 , 10 2 , 10, 1, 10 –1 , 10 –2 , 10 –3 from 10 3 kernel.gamma : 10 3 , 10 2 , 10, 1, 10 –1 , 10 –2 , 10 – 3 down to 10 –3 kernel.gamma use SMO (classification) steps of 1 evaluate using Accuracy SMO Accuracy

  20. LibSVM and LibLINEAR  LibLINEAR: all things linear – linear SVMs – logistic regression – can use “L1 norm” minimize sum of absolute values, not sum of squares •  LibSVM: all things SVM  Practical advice for using SVMs: – first use a linear SVM – then select RBF kernel ... and optimize cost , gamma using gridSearch Reference: Hsu, Chang and Lin (2010) “A practical guide to support vector classification” http://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf

  21. Advanced Data Mining with Weka Class 3 – Lesson 2 Setting up R with Weka Eibe Frank Department of Computer Science University of Waikato New Zealand weka.waikato.ac.nz

  22. Lesson 3.2: Setting up R with Weka Class 1 Time series forecasting Lesson 3.1 LibSVM and LibLINEAR Class 2 Data stream mining in Weka and MOA Lesson 3.2 Setting up R with Weka Class 3 Interfacing to R and other data Lesson 3.3 Using R to plot data mining packages Lesson 3.4 Using R to run a classifier Class 4 Distributed processing with Apache Spark Lesson 3.5 Using R to preprocess data Class 5 Scripting Weka in Python Lesson 3.6 Application: Functional MRI Neuroimaging data

  23. Setting up R with Weka  The instructions are based on using 64-bit Windows, 64-bit Java, and 64-bit R, and assume admin rights – Mixing 32-bit versions with 64-bit ones will produce problems, e.g., the installation process for Weka’s RPlugin may halt for no apparent reason – If you have 32-bit Windows, use 32-bit Java and 32-bit R – Support for R in Weka can also be installed on OS X and Linux: refer to the installation instructions that come with Weka’s RPlugin  There are four main steps to the installation process: – Downloading and installing R – Installing the rJava package in R – Setting up some Windows environment variables – Downloading and installing the RPlugin package for Weka

  24. Downloading and installing R  Choose a download mirror from https://cran.r-project.org/mirrors.html  Choose to download the binary distribution for Windows  Choose the “base” version of the distribution  Once downloaded, execute the installer  Accept all default settings for install options, but untick 32-bit files when asked to choose R components to install – If you are using 32-bit Windows, untick 64-bit files instead

  25. Installing the rJava package in R  Start the R console, e.g., by double-clicking on the shortcut that the installer has put on your desktop  In the R console, type install.packages("rJava") and press the return key on your keyboard  Note that this will only work if you have direct web access, i.e., if your web access is not provided by a proxy computer (see the next slide on what to do if you are behind a proxy)  In the pop-up menu, choose a mirror to download from  Accept defaults when asked for install options  Close R once the package has been installed, by typing q(), without saving the workspace

  26. For users with web connections provided by a proxy  If your organization uses a proxy computer, you need to set up some Windows environment variables before starting R  Using the Windows search functionality, search for variables, and select Edit environment variables for your account  Use the New... button to add two new variables, with names HTTP_PROXY and HTTPS_PROXY  Set their value to the URL and port number of your organisation's proxy server, separated by a comma – For example, at Waikato, this would be http://proxy.waikato.ac.nz:8080  Then, when you install a package in R, you will be asked for your proxy user name and password

  27. Setting up the environment variables  We need to set up some environment variables so that Weka’s RPlugin knows where R and its libraries are located  Using the Windows search functionality, search for variables, and select Edit environment variables for your account  Use the New... button to add two new variables, with names R_HOME and R_LIBS_USER (see screenshot on next slide)  Set the value of R_HOME to the path of the folder containing the R software (it should end in something like R-X.X.X )  Set the value of R_LIBS_USER to the path of the folder containing the newly installed rJava package for R  Also, use the Edit... button to add the path of the folder containing the R executable to the PATH variable (after adding a semicolon) – If there is no PATH variable, make a new one

  28. Screenshot of environment variables Make sure you In this example, there was don’t use quotes no pre-existing PATH in the variable variable, so the location of values. the R executable is the only value of the PATH variable.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend