Skip to content

Commit

Permalink
Merge 275d34a into 3c1e519
Browse files Browse the repository at this point in the history
  • Loading branch information
cyianor committed Oct 22, 2020
2 parents 3c1e519 + 275d34a commit 7de44dd
Show file tree
Hide file tree
Showing 5 changed files with 449 additions and 83 deletions.
9 changes: 5 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
StatsBase = ">=0.29"

[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

[compat]
StatsBase = ">=0.29"
test = ["Test", "Random"]
170 changes: 92 additions & 78 deletions src/MultivariateStats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,117 +2,130 @@ module MultivariateStats
using LinearAlgebra
using StatsBase: SimpleCovariance, CovarianceEstimator
import Statistics: mean, var, cov, covm
import Base: length, size, show, dump
import Base: length, size, show, dump, eltype
import StatsBase: fit, predict, ConvergenceException
import SparseArrays
import LinearAlgebra: eigvals

export

## common
evaluate, # evaluate discriminant function values (imported from Base)
predict, # use a model to predict responses (imported from StatsBase)
fit, # fit a model to data (imported from StatsBase)
centralize, # subtract a mean vector from each column
decentralize, # add a mean vector to each column
indim, # the input dimension of a model
outdim, # the output dimension of a model
projection, # the projection matrix
reconstruct, # reconstruct the input (approximately) given the output
transform, # apply a model to transform a vector or a matrix

# lreg
llsq, # Linear Least Square regression
ridge, # Ridge regression

# whiten
Whitening, # Type: Whitening transformation

invsqrtm, # Compute inverse of matrix square root, i.e. inv(sqrtm(A))
invsqrtm!, # Compute inverse of matrix square root inplace
cov_whitening, # Compute a whitening transform based on covariance
cov_whitening!, # Compute a whitening transform based on covariance (input will be overwritten)
invsqrtm, # Compute C^{-1/2}, i.e. inv(sqrtm(C))
evaluate, # evaluate discriminant function values (imported from Base)
predict, # use a model to predict responses (imported from StatsBase)
fit, # fit a model to data (imported from StatsBase)
centralize, # subtract a mean vector from each column
decentralize, # add a mean vector to each column
indim, # the input dimension of a model
outdim, # the output dimension of a model
projection, # the projection matrix
reconstruct, # reconstruct the input (approximately) given the output
transform, # apply a model to transform a vector or a matrix

## lreg
llsq, # Linear Least Square regression
ridge, # Ridge regression

## whiten
Whitening, # Type: Whitening transformation

invsqrtm, # Compute inverse of matrix square root, i.e. inv(sqrtm(A))
invsqrtm!, # Compute inverse of matrix square root inplace
cov_whitening, # Compute a whitening transform based on covariance
cov_whitening!, # Compute a whitening transform based on covariance (input will be overwritten)
invsqrtm, # Compute C^{-1/2}, i.e. inv(sqrtm(C))

## pca
PCA, # Type: Principal Component Analysis model
PCA, # Type: Principal Component Analysis model

pcacov, # PCA based on covariance
pcasvd, # PCA based on singular value decomposition of input data
principalratio, # the ratio of variances preserved in the principal subspace
principalvar, # the variance along a specific principal direction
principalvars, # the variances along all principal directions
pcacov, # PCA based on covariance
pcasvd, # PCA based on singular value decomposition of input data
principalratio, # the ratio of variances preserved in the principal subspace
principalvar, # the variance along a specific principal direction
principalvars, # the variances along all principal directions

tprincipalvar, # total principal variance, i.e. sum(principalvars(M))
tresidualvar, # total residual variance
tvar, # total variance
tprincipalvar, # total principal variance, i.e. sum(principalvars(M))
tresidualvar, # total residual variance
tvar, # total variance

## ppca
PPCA, # Type: the Probabilistic PCA model
PPCA, # Type: the Probabilistic PCA model

ppcaml, # Maximum likelihood probabilistic PCA
ppcaem, # EM algorithm for probabilistic PCA
bayespca, # Bayesian PCA
loadings, # factor loadings matrix
ppcaml, # Maximum likelihood probabilistic PCA
ppcaem, # EM algorithm for probabilistic PCA
bayespca, # Bayesian PCA
loadings, # factor loadings matrix

## kpca
KernelPCA, # Type: the Kernel PCA model
KernelPCA, # Type: the Kernel PCA model

## cca
CCA, # Type: Correlation Component Analysis model
CCA, # Type: Correlation Component Analysis model

ccacov, # CCA based on covariances
ccasvd, # CCA based on singular value decomposition of input data
ccacov, # CCA based on covariances
ccasvd, # CCA based on singular value decomposition of input data

xindim, # input dimension of X
yindim, # input dimension of Y
xmean, # sample mean of X
ymean, # sample mean of Y
xprojection, # projection matrix for X
yprojection, # projection matrix for Y
xtransform, # transform for X
ytransform, # transform for Y
correlations, # correlations of all projected directions
xindim, # input dimension of X
yindim, # input dimension of Y
xmean, # sample mean of X
ymean, # sample mean of Y
xprojection, # projection matrix for X
yprojection, # projection matrix for Y
xtransform, # transform for X
ytransform, # transform for Y
correlations, # correlations of all projected directions

## cmds
MDS,
classical_mds, # perform classical MDS over a given distance matrix
eigvals, # eignenvalues of the transformation
stress, # stress evaluation
classical_mds, # perform classical MDS over a given distance matrix
eigvals, # eignenvalues of the transformation
stress, # stress evaluation

gram2dmat, gram2dmat!, # Gram matrix => Distance matrix
dmat2gram, dmat2gram!, # Distance matrix => Gram matrix
gram2dmat, gram2dmat!, # Gram matrix => Distance matrix
dmat2gram, dmat2gram!, # Distance matrix => Gram matrix

## lda
Discriminant, # Abstract Type: for all discriminant functionals
LinearDiscriminant, # Type: Linear Discriminant functional
MulticlassLDAStats, # Type: Statistics required for training multi-class LDA
MulticlassLDA, # Type: Multi-class LDA model
SubspaceLDA, # Type: LDA model for high-dimensional spaces

ldacov, # Linear discriminant analysis based on covariances

classweights, # class-specific weights
classmeans, # class-specific means
withclass_scatter, # with-class scatter matrix
betweenclass_scatter, # between-class scatter matrix
multiclass_lda_stats, # compute statistics for multiclass LDA training
multiclass_lda, # train multi-class LDA based on statistics
mclda_solve, # solve multi-class LDA projection given scatter matrices
mclda_solve!, # solve multi-class LDA projection (inputs are overriden)
Discriminant, # Abstract Type: for all discriminant functionals
LinearDiscriminant, # Type: Linear Discriminant functional
MulticlassLDAStats, # Type: Statistics required for training multi-class LDA
MulticlassLDA, # Type: Multi-class LDA model
SubspaceLDA, # Type: LDA model for high-dimensional spaces

ldacov, # Linear discriminant analysis based on covariances

classweights, # class-specific weights
classmeans, # class-specific means
withclass_scatter, # with-class scatter matrix
betweenclass_scatter, # between-class scatter matrix
multiclass_lda_stats, # compute statistics for multiclass LDA training
multiclass_lda, # train multi-class LDA based on statistics
mclda_solve, # solve multi-class LDA projection given scatter matrices
mclda_solve!, # solve multi-class LDA projection (inputs are overriden)

## ica
ICA, # Type: the Fast ICA model
ICA, # Type: the Fast ICA model

icagfun, # a function to get a ICA approx neg-entropy functor
fastica!, # core algorithm function for the Fast ICA
icagfun, # a function to get a ICA approx neg-entropy functor
fastica!, # core algorithm function for the Fast ICA

## fa
FactorAnalysis, # Type: the Factor Analysis model
FactorAnalysis, # Type: the Factor Analysis model

faem, # Maximum likelihood probabilistic PCA
facm # EM algorithm for probabilistic PCA
faem, # Maximum likelihood probabilistic PCA
facm, # EM algorithm for probabilistic PCA

## facrot
FactorRotationAlgorithm, # Type: Factor rotation algorithm
Orthomax, # Type: Orthomax factor rotation algorithm
Varimax, # Convenience interfaces to Orthomax factor rotation algorithms
Quartimax,
Equamax,
Parsimax,

FactorRotation, # Type: Return type for factor rotations
loadings, # rotated loading matrix
rotation, # rotation matrix applied to loadings

rotatefactors # Alternative interface to factor rotations

## source files
include("common.jl")
Expand All @@ -126,5 +139,6 @@ module MultivariateStats
include("lda.jl")
include("ica.jl")
include("fa.jl")
include("facrot.jl")

end # module

0 comments on commit 7de44dd

Please sign in to comment.