dml

dml: Distance Metric Learning in R - Published in JOSS (2018)

https://github.com/terrytangyuan/dml

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

dimensionality-reduction distance-metric-learning machine-learning metric-learning r statistics
Last synced: 6 months ago · JSON representation

Repository

R package for Distance Metric Learning

Basic Info
  • Host: GitHub
  • Owner: terrytangyuan
  • License: mit
  • Language: R
  • Default Branch: master
  • Size: 254 KB
Statistics
  • Stars: 58
  • Watchers: 16
  • Forks: 30
  • Open Issues: 10
  • Releases: 2
Topics
dimensionality-reduction distance-metric-learning machine-learning metric-learning r statistics
Created over 10 years ago · Last pushed over 2 years ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.md

Note: This package has been maintained by @terrytangyuan since 2015. Please consider sponsoring!

JOSS DOI CRAN Status Coverage Status Downloads from the RStudio CRAN mirror License Zenodo DOI

dml (Distance Metric Learning in R)

R package for a collection of Distance Metric Learning algorithms, including global and local methods such as Relevant Component Analysis, Discriminative Component Analysis, Local Fisher Discriminant Analysis, etc. These distance metric learning methods are widely applied in feature extraction, dimensionality reduction, clustering, classification, information retrieval, and computer vision problems.

Installation

Install the current release from CRAN:

r install.packages("dml")

Or, try the latest development version from GitHub:

r devtools::install_github("terrytangyuan/dml")

Examples

Relevant Component Analysis

```r library("MASS")

generate synthetic multivariate normal data

set.seed(42)

k <- 100L # sample size of each class n <- 3L # specify how many classes N <- k * n # total sample size

x1 <- mvrnorm(k, mu = c(-16, 8), matrix(c(15, 1, 2, 10), ncol = 2)) x2 <- mvrnorm(k, mu = c(0, 0), matrix(c(15, 1, 2, 10), ncol = 2)) x3 <- mvrnorm(k, mu = c(16, -8), matrix(c(15, 1, 2, 10), ncol = 2)) x <- as.data.frame(rbind(x1, x2, x3)) # predictors y <- gl(n, k) # response

fully labeled data set with 3 classes

need to use a line in 2D to classify

plot(x[, 1L], x[, 2L], bg = c("#E41A1C", "#377EB8", "#4DAF4A")[y], pch = rep(c(22, 21, 25), each = k) ) abline(a = -10, b = 1, lty = 2) abline(a = 12, b = 1, lty = 2) ```

```r

generate synthetic chunklets

chunks <- vector("list", 300) for (i in 1:100) chunks[[i]] <- sample(1L:100L, 10L) for (i in 101:200) chunks[[i]] <- sample(101L:200L, 10L) for (i in 201:300) chunks[[i]] <- sample(201L:300L, 10L)

chks <- x[unlist(chunks), ]

make "chunklet" vector to feed the chunks argument

chunksvec <- rep(-1L, nrow(x)) for (i in 1L:length(chunks)) { for (j in 1L:length(chunks[[i]])) { chunksvec[chunks[[i]][j]] <- i } }

relevant component analysis

rcs <- rca(x, chunksvec)

learned transformation of the data

rcs$A

> [,1] [,2]

> [1,] -3.181484 -0.8812647

> [2,] -1.196200 2.3438640

learned Mahalanobis distance metric

rcs$B

> [,1] [,2]

> [1,] 10.898467 1.740125

> [2,] 1.740125 6.924592

whitening transformation applied to the chunklets

chkTransformed <- as.matrix(chks) %*% rcs$A

original data after applying RCA transformation

easier to classify - using only horizontal lines

xnew <- rcs$newX plot(xnew[, 1L], xnew[, 2L], bg = c("#E41A1C", "#377EB8", "#4DAF4A")[gl(n, k)], pch = c(rep(22, k), rep(21, k), rep(25, k)) ) abline(a = -15, b = 0, lty = 2) abline(a = 16, b = 0, lty = 2) ```

Other Examples

For examples of Local Fisher Discriminant Analysis, please take a look at the separate package here. For examples of all other implemented algorithms, please take a look at the dml package reference manual.

Brief Introduction

Distance metric is widely used in the machine learning literature. We used to choose a distance metric according to a priori (Euclidean Distance , L1 Distance, etc.) or according to the result of cross validation within small class of functions (e.g. choosing order of polynomial for a kernel). Actually, with priori knowledge of the data, we could learn a more suitable distance metric with (semi-)supervised distance metric learning techniques. dml is such an R package aims to implement a collection of algorithms for (semi-)supervised distance metric learning. These distance metric learning methods are widely applied in feature extraction, dimensionality reduction, clustering, classification, information retrieval, and computer vision problems.

Algorithms

Algorithms planned in the first development stage:

  • Supervised Global Distance Metric Learning:

    • Relevant Component Analysis (RCA) - implemented
    • Kernel Relevant Component Analysis (KRCA)
    • Discriminative Component Analysis (DCA) - implemented
    • Kernel Discriminative Component Analysis (KDCA)
    • Global Distance Metric Learning by Convex Programming - implemented
  • Supervised Local Distance Metric Learning:

    • Local Fisher Discriminant Analysis - implemented
    • Kernel Local Fisher Discriminant Analysis - implemented
    • Information-Theoretic Metric Learning (ITML)
    • Large Margin Nearest Neighbor Classifier (LMNN)
    • Neighbourhood Components Analysis (NCA)
    • Localized Distance Metric Learning (LDM)

The algorithms and routines might be adjusted during developing.

Contribute & Code of Conduct

To contribute to this project, please take a look at the Contributing Guidelines first. Please note that this project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Contact

Contact the maintainer of this package: Yuan Tang terrytangyuan@gmail.com

Owner

  • Name: Yuan Tang
  • Login: terrytangyuan
  • Kind: user
  • Location: USA
  • Company: Red Hat

Principal Engineer at Red Hat | Project Lead @argoproj @kubeflow | Maintainer @tensorflow XGBoost | ML/AI Infrastructure | Author | Speaker | Technical Advisor

JOSS Publication

dml: Distance Metric Learning in R
Published
October 23, 2018
Volume 3, Issue 30, Page 1036
Authors
Yuan Tang ORCID
Ant Financial Services Group, San Mateo, CA 94402, USA
Tao Gao
Minghong Investment Management, Shanghai 200122, China
Nan Xiao ORCID
Seven Bridges Genomics, Inc., Cambridge, MA 02142, USA
Editor
Arfon Smith ORCID
Tags
distance metric learning statistics clustering machine learning dimensionality reduction

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 92
  • Total Committers: 11
  • Avg Commits per committer: 8.364
  • Development Distribution Score (DDS): 0.587
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
terrytangyuan t****n@g****m 38
Nan Xiao r****t@g****m 37
gsganden g****g@g****g 4
James Lamb j****0@g****m 4
Michael Horrell h****7@g****m 2
Kyle Szela k****a@c****m 2
torpeterson t****n@u****m 1
mtc2013 m****e@g****m 1
michaelfrasco m****o@u****m 1
Chronocook c****k@g****m 1
Andrzej Janusz a****z@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 24
  • Total pull requests: 13
  • Average time to close issues: 7 months
  • Average time to close pull requests: 3 months
  • Total issue authors: 8
  • Total pull request authors: 10
  • Average comments per issue: 0.54
  • Average comments per pull request: 1.15
  • Merged pull requests: 10
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • jayqi (10)
  • joethorley (8)
  • dosen4552 (1)
  • nbnbhwyy (1)
  • BinDuan (1)
  • ghost (1)
  • mtc2013 (1)
  • terrytangyuan (1)
Pull Request Authors
  • jameslamb (3)
  • kszela24 (2)
  • torpeterson (1)
  • janusza (1)
  • mthorrell (1)
  • mtc2013 (1)
  • yl3296 (1)
  • michaelfrasco (1)
  • jayqi (1)
  • Chronocook (1)
Top Labels
Issue Labels
enhancement (1) help wanted (1)
Pull Request Labels
community (9)

Packages

  • Total packages: 2
  • Total downloads:
    • cran 249 last-month
  • Total docker downloads: 48
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 2
  • Total maintainers: 1
cran.r-project.org: dml

Distance Metric Learning in R

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 249 Last month
  • Docker Downloads: 48
Rankings
Forks count: 2.4%
Stargazers count: 6.1%
Average: 26.6%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Downloads: 59.0%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: r-dml
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Forks count: 27.4%
Dependent repos count: 34.0%
Stargazers count: 35.0%
Average: 36.9%
Dependent packages count: 51.2%
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • lfda * imports
  • MASS * suggests
  • lintr * suggests
  • scatterplot3d * suggests
  • testthat * suggests