Skip to content

Commit

Permalink
remove "NA" #204
Browse files Browse the repository at this point in the history
  • Loading branch information
szcf-weiya committed Aug 18, 2019
1 parent 4bedd76 commit e96849f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions code/LDA/diagonalLDA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
using DelimitedFiles
using Statistics
using StatsBase
# read data
path = "data\\SRBCT\\" # windows style
xtrain = readdlm(path*"khan.xtrain.txt")
ytrain = readdlm(path*"khan.ytrain.txt", Int)
xtest = readdlm(path*"khan.xtest.txt")
ytest = readdlm(path*"khan.ytest.txt")
using FreqTables


function DiagLDA(X::Array{Float64, 2}, y::Array{Int})
# number of genes & number of observations
Expand Down Expand Up @@ -90,33 +86,37 @@ function classify(x::Array{Float64, 2}, δ::Array{Function, 1})
return res
end


# read data
path = "data\\SRBCT\\" # windows style
xtrain = readdlm(path*"khan.xtrain.txt")
ytrain = readdlm(path*"khan.ytrain.txt", Int)
xtest = readdlm(path*"khan.xtest.txt")
ytest = readdlm(path*"khan.ytest.txt")

# remove NA obs
idx_nonNA = ytest .!= "NA"
ytest = ytest[idx_nonNA]
xtest = xtest[:, vec(idx_nonNA)]

# run
δ = DiagLDA(xtrain, ytrain)
cl = classify(xtrain, δ)
cltest = classify(xtest, δ)


using FreqTables
# train results
freqtable(cl, ytrain[1, :])






# test results
freqtable(cltest, ytest[1,:])






# RegDiagLDA
δ2 = RegDiagLDA(xtrain, ytrain[:], 2.0)
cl2 = classify(xtrain, δ2)
cltest2 = classify(xtest, δ2)
# RegDiagLDA
freqtable(cl2, ytrain[:])


Expand Down

0 comments on commit e96849f

Please sign in to comment.