/
Dataset.jl
38 lines (32 loc) · 983 Bytes
/
Dataset.jl
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
38
module DatasetModule
import ..ProgramConstantsModule: BATCH_DIM, FEATURE_DIM
struct Dataset{T<:Real}
X::AbstractMatrix{T}
y::AbstractVector{T}
n::Int
nfeatures::Int
weighted::Bool
weights::Union{AbstractVector{T},Nothing}
varMap::Array{String,1}
end
"""
Dataset(X::AbstractMatrix{T}, y::AbstractVector{T};
weights::Union{AbstractVector{T}, Nothing}=nothing,
varMap::Union{Array{String, 1}, Nothing}=nothing)
Construct a dataset to pass between internal functions.
"""
function Dataset(
X::AbstractMatrix{T},
y::AbstractVector{T};
weights::Union{AbstractVector{T},Nothing}=nothing,
varMap::Union{Array{String,1},Nothing}=nothing,
) where {T<:Real}
n = size(X, BATCH_DIM)
nfeatures = size(X, FEATURE_DIM)
weighted = weights !== nothing
if varMap === nothing
varMap = ["x$(i)" for i in 1:nfeatures]
end
return Dataset{T}(X, y, n, nfeatures, weighted, weights, varMap)
end
end