MultivariateStats.jl: predict for MulticlassLDA is throwing error

Hi

I am trying to fit MulticlassLDA on the iris dataset. The predict is throwing an error. I was wondering if you can help me to figure out what mistakes I am making.

using MultivariateStats, RDatasets;
iris = dataset("datasets", "iris");
X = Matrix(iris[1:1:end,1:4])
X_labels = Vector(iris[1:1:end,5])

X1 = Matrix(X')

y =X_labels
labels = repeat([3],length(y))
for (idx,X_labels) in enumerate(y)
    if X_labels =="virginica"
        labels[idx] = 1
    elseif X_labels == "setosa"
        labels[idx] = 2
    end
end
y = labels;
y = vec(y')

lda = fit(MulticlassLDA, 3, X1, y);

Up to fitting, everything is perfect. Now I am facing the problem.

predict(lda, X1)

MethodError: no method matching predict(::MulticlassLDA{Float64}, ::Matrix{Float64})
Closest candidates are:
  predict(::Discriminant, ::AbstractMatrix{T} where T) at /Users/sourishdas/.julia/packages/MultivariateStats/HTpHt/src/lda.jl:26

Thanks and regards,
Sourish

1 Like

Works for me here, with version v0.9.0:

(@v1.8) pkg> status --outdated MultivariateStats
Status `~/.julia/environments/v1.8/Project.toml`
⌅ [6f286f6a] MultivariateStats v0.9.0 (<v0.10.0): ManifoldLearning, StatsPlots

Hi Dan

Thank you for your prompt reply. Yes - I had an older version (0.8.0) and when I updated to 0.9.0 - it worked.

Thanks again.
Sourish