Skip to content

Commit 148baf7

Browse files
authored
Fixed matrix order in Titanic features (#109)
1 parent 752af69 commit 148baf7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Titanic/Titanic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ julia> summary(features)
153153
"""
154154
function features()
155155
titanic_data = readdlm(DATA, ',')
156-
reshape(Matrix(hcat(titanic_data[2:end, 1], titanic_data[2:end, 3:12])), (11, 891))
156+
permutedims(Matrix(hcat(titanic_data[2:end, 1], titanic_data[2:end, 3:12])), (2, 1))
157157
end
158158

159159
end # module

test/tst_titanic.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ using MLDatasets
88
X = Titanic.features()
99
Y = Titanic.targets()
1010
names = Titanic.feature_names()
11+
12+
first_row_expected = [
13+
1, 3, "Braund, Mr. Owen Harris", "male", 22, 1, 0, "A/5 21171", 7.25, "", "S"
14+
]
15+
1116
@test X isa Matrix{}
1217
@test Y isa Matrix{}
1318
@test names == ["PassengerId","Pclass", "Name", "Sex", "Age", "SibSp", "Parch", "Ticket", "Fare", "Cabin", "Embarked"]
1419
@test size(X) == (11, 891)
1520
@test size(Y) == (1, 891)
21+
@test X[:, 1] == first_row_expected
1622
end
1723

1824
end #module

0 commit comments

Comments
 (0)