Skip to content

Commit e4a4743

Browse files
Merge pull request #84 from CTUAvastLab/master
removing labels from features
2 parents 6f4aa5a + e517f75 commit e4a4743

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/Mutagenesis/Mutagenesis.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ julia> test_x, test_y = Mutagenesis.testdata();
2222
julia> val_x, val_y = Mutagenesis.valdata();
2323
2424
julia> train_x[1]
25-
JSON3.Object{Base.CodeUnits{UInt8, String}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}} with 6 entries:
26-
:ind1 => 1
27-
:inda => 0
28-
:logp => 4.23
29-
:lumo => -1.246
30-
:mutagenic => 1
31-
:atoms => JSON3.Object[{…
25+
Dict{Symbol, Any} with 5 entries:
26+
:lumo => -1.246
27+
:inda => 0
28+
:logp => 4.23
29+
:ind1 => 1
30+
:atoms => Dict{Symbol, Any}[Dict(:element=>"c", :bonds=>Dict{Symbol, Any}[Dic…
3231
3332
julia> train_y[1]
3433
1
@@ -85,12 +84,13 @@ function load_data(dir)
8584
metadata = read_data(metadata_path)
8685
labelkey = metadata["label"]
8786
targets = map(i -> i[labelkey], samples)
87+
samples_without_label = map(x->delete!(copy(x), Symbol(labelkey)), samples)
8888
val_num = metadata["val_samples"]
8989
test_num = metadata["test_samples"]
9090
train_idxs = 1:length(samples)-val_num-test_num
9191
val_idxs = length(samples)-val_num-test_num+1:length(samples)-test_num
9292
test_idxs = length(samples)-test_num+1:length(samples)
93-
samples, targets, train_idxs, val_idxs, test_idxs
93+
samples_without_label, targets, train_idxs, val_idxs, test_idxs
9494
end
9595

9696
read_data(path) = open(JSON3.read, path)

test/tst_mutagenesis.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,12 @@ end
1010
@test length(train_x) == length(train_y) == 100
1111
@test length(test_x) == length(test_y) == 44
1212
@test length(val_x) == length(val_y) == 44
13+
# test that label is not contained in features
14+
@test !any(haskey.(train_x, :mutagenic))
15+
@test !any(haskey.(test_x, :mutagenic))
16+
@test !any(haskey.(val_x, :mutagenic))
17+
# test data is materialized
18+
@test train_x isa Vector{<:Dict}
19+
@test test_x isa Vector{<:Dict}
20+
@test val_x isa Vector{<:Dict}
1321
end

0 commit comments

Comments
 (0)