Spaces:
Sleeping
Sleeping
File size: 1,056 Bytes
a9184d1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# Sum of square error between two arrays
function SSE(x::Array{Float32}, y::Array{Float32})::Float32
diff = (x - y)
return sum(diff .* diff)
end
function SSE(x::Nothing, y::Array{Float32})::Float32
return 1f9
end
# Sum of square error between two arrays, with weights
function SSE(x::Array{Float32}, y::Array{Float32}, w::Array{Float32})::Float32
diff = (x - y)
return sum(diff .* diff .* w)
end
function SSE(x::Nothing, y::Array{Float32}, w::Array{Float32})::Float32
return Nothing
end
# Mean of square error between two arrays
function MSE(x::Nothing, y::Array{Float32})::Float32
return 1f9
end
# Mean of square error between two arrays
function MSE(x::Array{Float32}, y::Array{Float32})::Float32
return SSE(x, y)/size(x)[1]
end
# Mean of square error between two arrays
function MSE(x::Nothing, y::Array{Float32}, w::Array{Float32})::Float32
return 1f9
end
# Mean of square error between two arrays
function MSE(x::Array{Float32}, y::Array{Float32}, w::Array{Float32})::Float32
return SSE(x, y, w)/sum(w)
end |