Giter Site home page Giter Site logo

marchinilab / sda4d Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 220 KB

R package SDA4D for performing 4-dimensional sparse Bayesian tensor decomposition

License: Other

R 100.00%
parafac tensor-decomposition bayesian-methods variational-bayes sparse

sda4d's Introduction

SDA4D

An R package providing an implementation of a variational Bayes algorithm for four dimensional Parallel Factor Analysis.

Installation

You can install the released version of SDA4D from the marchinilab github with

install.packages('devtools')
devtools::install_github("marchinilab/SDA4D")

Example

Generating a data tensor

We provide a function to generate a data tensor similar to those we used in simulations, named generate_example_data which also returns a list of the matrices used to generate it.

library(SDA4D)

set.seed(42)
generatedData <- generate_example_data()
 
lapply(generatedData,dim)
#> $dataTensor
#> [1] 200 500  16   3
#> 
#> $A
#> [1] 200   8
#> 
#> $B
#> [1] 3 8
#> 
#> $D
#> [1] 16  8
#> 
#> $X
#> [1]   8 500

Performing a short run of the tensor decomposition

Now, setting stopping=FALSE to ignore the stopping criterion we run the tensor decomposition with the function RunSDA4D for 100 iterations as follows:

 res<-RunSDA4D(data_tensor = generatedData$dataTensor,
               dimn_vector = c(200,500,16,3),
               max_iters = 100,
               num_components = 8,
               stopping=FALSE)

Note that we have suppressed the console output from this run in the file here.

In the output we have the evidence lower bound (ELBO, also sometimes referred to as the negative free energy), recorded at each iteration, the maximum number of iterations, and a number of other parameters. Note that in the code we have omitted constant terms from the ELBO.

The output

The output of the main function is a list of a number of components:

The main RunSDA4D provides an interface to an implementation of a Bayesian sparse parallel factor analysis model for four-dimensional tensor decomposition. The output therefore consists of a list of the approximate posterior distributions of the main parameters, in the form of their parameters, or point estimates where these were calculated instead.

names(res)
#>  [1] "ELBO"             "A"                "B"               
#>  [4] "D"                "Lam"              "Beta"            
#>  [7] "Ph"               "Ps"               "Rho"             
#> [10] "WS"               "maximumiteration"
res$maximumiteration
#> [1] 100
length(res$ELBO)
#> [1] 101

See the vignette in the doc directory for a description of the output.

sda4d's People

Contributors

ccgill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kai0511

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.