Skip to content

Commit

Permalink
Add test for training house rentals
Browse files Browse the repository at this point in the history
  • Loading branch information
alperkesen committed Aug 21, 2019
1 parent 215db8c commit 96c3a83
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include("config.jl")
include("layers.jl")
include("train.jl")
29 changes: 29 additions & 0 deletions test/train.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Knet: relu, gpu

@testset "houserentals" begin
hr = AutoML.house_rentals()
trn, tst = AutoML.splitdata(hr; trainprop=0.8)
epochs = 100

hrtrn = AutoML.csv2data(trn)
hrtst = AutoML.csv2data(tst)

hrinputs = [("neighborhood", "String"),
("number_of_bathrooms", "Int"),
("location", "String"),
("days_on_market", "Int"),
("initial_price", "Float"),
("number_of_rooms", "Int"),
("sqft", "Float")]
hroutputs = [("rental_price", "Float")]

model = AutoML.Model(hrinputs, hroutputs; name="houserentals")
model, dtrn = AutoML.train(model, hrtrn; epochs=epochs)
dtst = AutoML.getbatches(model, hrtst)

trnerr = model.model(dtrn.x, dtrn.y)
tsterr = model.model(dtst.x, dtst.y)
threshold = 1000

@test abs(trnerr - tsterr) < threshold
end

0 comments on commit 96c3a83

Please sign in to comment.