DWD Classifiers

class dwd.gen_dwd.GenDWD(lambd=1.0, q=1, implicit_P=True)

Generalized Distance Weighted Discrimination

Solves the gDWD problem using the MM algorithm derived in Wang and Zou, 2017.

Primary reference: Another look at distance-weighted discrimination by Boxiang Wang and Hui Zou, 2017

Note the tuning parameter lambd is on a different scale the parameter C which is used in the SOCP formulation.

Parameters
  • lambd (float) – Tuning parameter for DWD.

  • q (float) – Tuning parameter for generalized DWD (the exponent on the margin terms). When q = 1, gDWD is equivalent to DWD.

  • implicit_P (bool) – Whether to use the implicit P^{-1} gamma formulation (in the publication) or the explicit computation (in the arxiv version).

class dwd.gen_kern_dwd.KernGDWD(lambd=1.0, q=1.0, kernel='linear', kernel_kws={}, implicit_P=True)

Kernel Generalized Distance Weighted Discrimination

Solves the kernel gDWD problem using the MM algorithm derived in Wang and Zou, 2017.

Primary reference: Another look at distance-weighted discrimination by Boxiang Wang and Hui Zou, 2017

Note the tuning parameter lambd is on a different scale the parameter C which is used in the SOCP formulation.

Parameters
  • lambd (float) – Tuning parameter for DWD.

  • q (float) – Tuning parameter for generalized DWD (the exponent on the margin terms). When q = 1, gDWD is equivalent to DWD.

  • kernel (str, callable(X, Y, **kwargs)) – The kernel to use.

  • kernel_kws (dict) – Any key word arguments for the kernel.

  • implicit_P (bool) – Whether to use the implicit P^{-1} gamma formulation (in the publication) or the explicit computation (in the arxiv version).

Cross-validation

class dwd.gen_dwd.GenDWDCV(lambd_vals=array([0.01, 0.027825594, 0.0774263683, 0.215443469, 0.59948425, 1.66810054, 4.64158883, 12.9154967, 35.9381366, 100.0]), q_vals=array([0.01, 0.1, 1.0, 10.0, 100.0]), cv=5, scoring='accuracy')

Fits Genralized DWD with cross-validation. gDWD cross-validation can be significnatly faster if certain quantities are precomputed.

Parameters
  • lambd_vals (list of floats) – The lambda values to cross-validate over.

  • q_vals (list of floats) – The q-values to cross validate over.

  • cv – How to perform cross-valdiation. See documetnation in sklearn.model_selection.GridSearchCV.

  • scoring – What metric to use to score cross-validation. See documetnation in sklearn.model_selection.GridSearchCV.

class dwd.gen_kern_dwd.KernGDWDCV(lambd_vals=array([0.01, 0.027825594, 0.0774263683, 0.215443469, 0.59948425, 1.66810054, 4.64158883, 12.9154967, 35.9381366, 100.0]), q_vals=array([0.01, 0.1, 1.0, 10.0, 100.0]), kernel='linear', kernel_kws_vals={}, cv=5, scoring='accuracy')

Fits kernel gDWD with cross-validation. gDWD cross-validation can be significnatly faster if certain quantities are precomputed.

Parameters
  • lambd_vals (list of floats) – The lambda values to cross-validate over.

  • q_vals (list of floats) – The q-values to cross validate over.

  • kernel (str, callable) – The kernel to use.

  • kern_kws_vals (list of dicts) – The kernel parameters to validate over.

  • cv – How to perform cross-valdiation. See documetnation in sklearn.model_selection.GridSearchCV.

  • scoring – What metric to use to score cross-validation. See documetnation in sklearn.model_selection.GridSearchCV.