Giter Site home page Giter Site logo

amalgam's Introduction

Quick start

Welcome to the amalgam GitHub page!

It is difficult to visualize high-dimensional compositional data. One approach involves amalgamating the parts into a new set of composite features called "amalgams". This package uses genetic algorithms to find an optimal set of amalgams that satisfies an objective function. Although amalgams themselves are low-dimensional compositions, they are not sub-compositions. Rather, amalgamation acts like a kind of non-linear dimension reduction that can facilitate data understanding. Note that inferences made on amalgamations may not agree with inferences made on the full composition.

library(devtools)
devtools::install_github("tpq/amalgam")
library(amalgam)
?amalgam

Data-driven amalgamation

Before using amalgam, the analyst should decide what kind of amalgamation they want.

First, the analyst should decide how to amalgamate. The simplest amalgamation is "N-to-1" (handled by the weight.Nto1 function), where each component only contributes to one amalgam. A more complex amalgamation is "N-to-N" (handled by the weight.NtoN function), where each component may contribute to multiple amalgams. The former would produce amalgams that are easier to interpret, but the latter may fit the objective better.

Second, the analyst should decide on the objective. One objective function is to preserve the Aitchison distance between the sample amalgams (see objective.keepDist). This is an unsupervised dimension reduction method akin to a PCoA. Another objective function is to maximize the variance explained by a constraining matrix, z (see objective.maxRDA). This is a supervised dimension reduction method akin to a non-linear RDA.

Once this is decided, running the algorithm is easy! Use the n.amalgams argument to choose how many amalgams you want. Use the maxiter argument to choose how long the algorithm runs.

set.seed(3220)
sampleData <- randAcomp(10, 15)
out <- amalgam(sampleData, n.amalgams = 3, z = NULL,
               objective = objective.keepDist,
               weight = weight.Nto1)
print(out)
#> AMALGAM OBJECT
#> 
#> Dimension of original data:
#> [1] 10 15
#> 
#> Dimension of amalgamated data:
#> [1] 10  3
#> 
#> Size of amalgams:
#> [1] 3 4 3
#> 
#> Size of contributions:
#> 
#>  0  1 
#>  5 10 
#> 
#> Fitness:
#> [1] 0.8347408
#> 
#> Use plot() method!

Visualization

fakeClusters <- cutree(hclust(dist(sampleData)), 3)
plot(out, col = fakeClusters, center = TRUE, scale = TRUE)

This package only offers a few objectives right now, but we will add more later.

amalgam's People

Contributors

tpq avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.