Data%20Mining%20Packages%20in%20R:%20logistic%20regression%20and%20SVM - PowerPoint PPT Presentation

About This Presentation
Title:

Data%20Mining%20Packages%20in%20R:%20logistic%20regression%20and%20SVM

Description:

Data Mining Packages in R: logistic regression and SVM – PowerPoint PPT presentation

Number of Views:237
Avg rating:3.0/5.0
Slides: 10
Provided by: jdu
Learn more at: https://zoo.cs.yale.edu
Category:

less

Transcript and Presenter's Notes

Title: Data%20Mining%20Packages%20in%20R:%20logistic%20regression%20and%20SVM


1
Data Mining Packages in R logistic regression
and SVM
  • Jiang Du
  • March 2008

2
Logistic Regression
  • lrm in package Design
  • http//biostat.mc.vanderbilt.edu/s/Design/html/lrm
    .html
  • glm in package stats
  • http//finzi.psych.upenn.edu/R/library/stats/html/
    glm.html

3
Logistic Regression lrm
  • Usage
  • lrm(formula, data, subset, na.actionna.delete,
    method"lrm.fit", modelFALSE, xFALSE, yFALSE,
    linear.predictorsTRUE, se.fitFALSE, penalty0,
    penalty.matrix, tol1e-7, strata.penalty0,
    var.penaltyc('simple','sandwich'), weights,
    normwt, ...)
  • Arguments
  • Formula
  • a formula object. An offset term can be included.
    The offset causes fitting of a model such as
    logit(Y1) Xß W, where W is the offset
    variable having no estimated coefficient. The
    response variable can be any data type lrm
    converts it in alphabetic or numeric order to an
    S factor variable and recodes it 0,1,2,...
    internally.
  • Data
  • data frame to use. Default is the current frame.
  • Usage
  • S3 method for class 'lrm'
  • predict(object, ..., typec("lp", "fitted",
    "fitted.ind", "mean", "x", "data.frame", "terms",
    "adjto","adjto.data.frame", "model.frame"),
    se.fitFALSE, codesFALSE)
  • Arguments
  • Object
  • a object created by lrm
  • ...
  • arguments passed to predict.Design, such as kint
    and newdata (which is used if you are predicting
    out of data). See predict.Design to see how NAs
    are handled.
  • Type

4
Logistic Regression lrm
  • Fitting training data
  • model lrm(Class X Y Z, datatrain)
  • Prediction on new data
  • To get logit(Y1)
  • predict(model, newdata test, type lp)
  • To get Pr(Y1)
  • predict(model, newdata test, type
    fitted.ind)

5
?formula
  • The models fit by, e.g., the lm and glm functions
    are specified in a compact symbolic form. The
    operator is basic in the formation of such
    models. An expression of the form y model is
    interpreted as a specification that the response
    y is modelled by a linear predictor specified
    symbolically by model. Such a model consists of a
    series of terms separated by operators. The
    terms themselves consist of variable and factor
    names separated by operators. Such a term is
    interpreted as the interaction of all the
    variables and factors appearing in the term.
  • In addition to and , a number of other
    operators are useful in model formulae. The
    operator denotes factor crossing ab interpreted
    as abab. The operator indicates crossing to
    the specified degree. For example (abc)2 is
    identical to (abc)(abc) which in turn
    expands to a formula containing the main effects
    for a, b and c together with their second-order
    interactions. The in operator indicates that
    the terms on its left are nested within those on
    the right. For example a b in a expands to
    the formula a ab. The - operator removes the
    specified terms, so that (abc)2 - ab is
    identical to a b c bc ac. It can also
    used to remove the intercept term y x - 1 is a
    line through the origin. A model with no
    intercept can be also specified as y x 0 or y
    0 x.

6
Logistic Regression glm
  • Fitting training data
  • model glm(Class X Y Z, datatrain,
    familybinomial(logit))
  • Prediction on new data
  • To get logit(Y1)
  • predict(model, newdata test)
  • To get Pr(Y1)
  • predict(model, newdata test, type response)

7
SVM
  • svm in e1071
  • http//www.potschi.de/svmtut/svmtut.html
  • ksvm in kernlab
  • http//rss.acs.unt.edu/Rdoc/library/kernlab/html/k
    svm.html

8
SVM svm
  • Kernel
  • the kernel used in training and predicting. You
    might consider changing some of the following
    parameters, depending on the kernel type.
  • linear
  • u'v
  • polynomial
  • (gammau'v coef0)degree
  • radial basis
  • exp(-gammau-v2)
  • sigmoid
  • Tanh(gammau'v coef0)

9
SVM svm
  • Training
  • model svm(Class X Y Z, datatrain, type
    "C, kernel linear)
  • Prediction
  • predict(model, newdata test)
Write a Comment
User Comments (0)
About PowerShow.com