KennethLange / AlgorithmsFromTheBook.jl

Julia code in Kenneth Lange's Algorithms from THE BOOK
29 stars 7 forks source link

mcda_test.jl: analyze_iris_data gives same results irregardless of the missing rate #3

Open DanielEWeeks opened 1 year ago

DanielEWeeks commented 1 year ago

If I copy the mcda_test.jl code into the Julia terminal, it always gives the same results, no matter if I change missing_rate. For example, here I put it to 80% but it still returns one classification error across all ranks (and made epsilon smaller):

       (classes, epsilon, missing_rate) = (3, 1e-19, 0.80);
       analyze_iris_data(epsilon, missing_rate, classes) 
       end

       end
WARNING: replacing module McdaTest.
rank = 1 classification_errors = 1
rank = 2 classification_errors = 1
rank = 3 classification_errors = 1
rank = 4 classification_errors = 1
rank = 5 classification_errors = 1
rank = 6 classification_errors = 1
Test Summary: |Time
MCDA          | None  0.1s
Main.McdaTest

Also, as I am a Julia newbie, could you tell me how to run analyze_iris_data without copying/pasting code? Looks like it is within a module and is not exported.

julia>  versioninfo()
Julia Version 1.8.5
Commit 17cfb8e65ea (2023-01-08 06:45 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.5.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 8 virtual cores
DanielEWeeks commented 1 year ago

Looks like, for Julia Version 1.8.5, this line here in test/mcda_test.jl:

errors = count(class - imputedclass != 0);

should instead now be:

errors = count(class - imputedclass .!= 0);

with the dot operator.

Simple example:

julia> a
3-element Vector{Int64}:
 1
 1
 1

julia> b
3-element Vector{Int64}:
 1
 0
 0

julia> d = a-b
3-element Vector{Int64}:
 0
 1
 1

julia> count(a-b != 0)
1

julia> count(a-b .!= 0)
2