Skip to content

Commit fa98503

Browse files
committed
Update API to conform to package
1 parent f5d16bc commit fa98503

File tree

3 files changed

+131
-148
lines changed

3 files changed

+131
-148
lines changed

src/MultivariateStats.jl

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
module MultivariateStats
22

3-
using LinearAlgebra
4-
using SparseArrays
5-
using Statistics: middle
6-
using StatsAPI: RegressionModel
7-
using StatsBase:
8-
SimpleCovariance,
9-
CovarianceEstimator,
10-
AbstractDataTransform,
11-
ConvergenceException,
12-
pairwise,
13-
pairwise!,
14-
CoefTable
15-
16-
import Statistics: mean, var, cov, covm, cor
17-
import Base: length, size, show
18-
import StatsAPI: fit, predict, coef, weights, dof, r2
19-
import LinearAlgebra: eigvals, eigvecs
20-
21-
export
3+
using DataFrames
4+
using LinearAlgebra
5+
using SparseArrays
6+
using Statistics: middle
7+
using StatsAPI: RegressionModel
8+
using StatsBase: SimpleCovariance, CovarianceEstimator, AbstractDataTransform,
9+
ConvergenceException, pairwise, pairwise!, CoefTable
10+
11+
import Statistics: mean, var, cov, covm, cor
12+
import Base: length, size, show
13+
import StatsAPI: fit, predict, coef, weights, dof, r2
14+
import LinearAlgebra: eigvals, eigvecs
15+
16+
export
2217

2318
## common
2419
evaluate, # evaluate discriminant function values
@@ -43,23 +38,27 @@ export
4338

4439
# whiten
4540
Whitening, # Type: Whitening transformation
41+
4642
invsqrtm, # Compute inverse of matrix square root, i.e. inv(sqrtm(A))
4743
cov_whitening, # Compute a whitening transform based on covariance
4844
cov_whitening!, # Compute a whitening transform based on covariance (input will be overwritten)
4945
invsqrtm, # Compute C^{-1/2}, i.e. inv(sqrtm(C))
5046

5147
## pca
5248
PCA, # Type: Principal Component Analysis model
49+
5350
pcacov, # PCA based on covariance
5451
pcasvd, # PCA based on singular value decomposition of input data
5552
principalratio, # the ratio of variances preserved in the principal subspace
5653
principalvar, # the variance along a specific principal direction
5754
principalvars, # the variances along all principal directions
55+
5856
tprincipalvar, # total principal variance, i.e. sum(principalvars(M))
5957
tresidualvar, # total residual variance
6058

6159
## ppca
6260
PPCA, # Type: the Probabilistic PCA model
61+
6362
ppcaml, # Maximum likelihood probabilistic PCA
6463
ppcaem, # EM algorithm for probabilistic PCA
6564
bayespca, # Bayesian PCA
@@ -79,17 +78,18 @@ export
7978
MetricMDS,
8079
classical_mds, # perform classical MDS over a given distance matrix
8180
stress, # stress evaluation
82-
gram2dmat,
83-
gram2dmat!, # Gram matrix => Distance matrix
84-
dmat2gram,
85-
dmat2gram!, # Distance matrix => Gram matrix
81+
82+
gram2dmat, gram2dmat!, # Gram matrix => Distance matrix
83+
dmat2gram, dmat2gram!, # Distance matrix => Gram matrix
8684

8785
## lda
8886
LinearDiscriminant, # Type: Linear Discriminant functional
8987
MulticlassLDAStats, # Type: Statistics required for training multi-class LDA
9088
MulticlassLDA, # Type: Multi-class LDA model
9189
SubspaceLDA, # Type: LDA model for high-dimensional spaces
90+
9291
ldacov, # Linear discriminant analysis based on covariances
92+
9393
classweights, # class-specific weights
9494
classmeans, # class-specific means
9595
withclass_scatter, # with-class scatter matrix
@@ -100,58 +100,59 @@ export
100100

101101
## ica
102102
ICA, # Type: the Fast ICA model
103+
103104
fastica!, # core algorithm function for the Fast ICA
104105

105106
## fa
106107
FactorAnalysis, # Type: the Factor Analysis model
108+
107109
faem, # EM algorithm for factor analysis
108110
facm, # CM algorithm for factor analysis
109111

110-
## CA, MCA
112+
## ca, mca
111113
CA, # Type: correspondence analysis
114+
112115
MCA, # Type: multiple correspondence analysis
113116
ca, # fit and return a correspondence analysis
114117
mca, # fit and return a multiple correspondence analysis
115118
objectscores, # return the object scores or coordinates from CA or MCA
116119
variablescores, # return the variable/category scores or coordinates from CA or MCA
117120
inertia # return the inertia (derived from eigenvalues) for CA
118121

119-
## source files
120-
include("types.jl")
121-
include("common.jl")
122-
include("lreg.jl")
123-
include("whiten.jl")
124-
include("pca.jl")
125-
include("ppca.jl")
126-
include("kpca.jl")
127-
include("cca.jl")
128-
include("cmds.jl")
129-
include("mmds.jl")
130-
include("lda.jl")
131-
include("ica.jl")
132-
include("fa.jl")
133-
include("mca.jl")
134-
135-
## deprecations
136-
@deprecate indim(f) size(f, 1)
137-
@deprecate outdim(f) size(f, 2)
138-
@deprecate transform(f, x) predict(f, x)
139-
@deprecate indim(f::Whitening) length(f::Whitening)
140-
@deprecate outdim(f::Whitening) length(f::Whitening)
141-
@deprecate tvar(f::PCA) var(f::PCA)
142-
@deprecate classical_mds(D::AbstractMatrix, p::Int) predict(
143-
fit(MDS, D, maxoutdim = p, distances = true),
144-
)
145-
@deprecate transform(f::MDS) predict(f::MDS)
146-
@deprecate xindim(M::CCA) size(M, 1)
147-
@deprecate yindim(M::CCA) size(M, 2)
148-
@deprecate outdim(M::CCA) size(M, 3)
149-
@deprecate correlations(M::CCA) cor(M)
150-
@deprecate xmean(M::CCA) mean(M, :x)
151-
@deprecate ymean(M::CCA) mean(M, :y)
152-
@deprecate xprojection(M::CCA) projection(M, :x)
153-
@deprecate yprojection(M::CCA) projection(M, :y)
154-
@deprecate xtransform(M::CCA, x) predict(M, x, :x)
155-
@deprecate ytransform(M::CCA, y) predict(M, y, :y)
122+
## source files
123+
include("types.jl")
124+
include("common.jl")
125+
include("lreg.jl")
126+
include("whiten.jl")
127+
include("pca.jl")
128+
include("ppca.jl")
129+
include("kpca.jl")
130+
include("cca.jl")
131+
include("cmds.jl")
132+
include("mmds.jl")
133+
include("lda.jl")
134+
include("ica.jl")
135+
include("fa.jl")
136+
include("mca.jl")
137+
138+
## deprecations
139+
@deprecate indim(f) size(f,1)
140+
@deprecate outdim(f) size(f,2)
141+
@deprecate transform(f, x) predict(f, x)
142+
@deprecate indim(f::Whitening) length(f::Whitening)
143+
@deprecate outdim(f::Whitening) length(f::Whitening)
144+
@deprecate tvar(f::PCA) var(f::PCA)
145+
@deprecate classical_mds(D::AbstractMatrix, p::Int) predict(fit(MDS, D, maxoutdim=p, distances=true))
146+
@deprecate transform(f::MDS) predict(f::MDS)
147+
@deprecate xindim(M::CCA) size(M,1)
148+
@deprecate yindim(M::CCA) size(M,2)
149+
@deprecate outdim(M::CCA) size(M,3)
150+
@deprecate correlations(M::CCA) cor(M)
151+
@deprecate xmean(M::CCA) mean(M, :x)
152+
@deprecate ymean(M::CCA) mean(M, :y)
153+
@deprecate xprojection(M::CCA) projection(M, :x)
154+
@deprecate yprojection(M::CCA) projection(M, :y)
155+
@deprecate xtransform(M::CCA, x) predict(M, x, :x)
156+
@deprecate ytransform(M::CCA, y) predict(M, y, :y)
156157

157158
end # module

0 commit comments

Comments
 (0)