Skip to content

Commit f45ef65

Browse files
authored
Titanic docs added (#92)
1 parent c1a3739 commit f45ef65

File tree

4 files changed

+36
-22
lines changed

4 files changed

+36
-22
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Find below a list of available datasets and links to their documentation.
3131
- [BostonHousing](https://juliaml.github.io/MLDatasets.jl/dev/datasets/BostonHousing/)
3232
- [Iris](https://juliaml.github.io/MLDatasets.jl/dev/datasets/Iris/)
3333
- [Mutagenesis](https://relational.fit.cvut.cz/dataset/Mutagenesis)
34+
- [Titanic](https://juliaml.github.io/MLDatasets.jl/dev/datasets/Titanic/)
3435

3536
#### Text
3637
- [PTBLM](https://juliaml.github.io/MLDatasets.jl/dev/datasets/PTBLM/)

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ makedocs(
3535
"Iris" => "datasets/Iris.md",
3636
"Boston Housing" => "datasets/BostonHousing.md",
3737
"Mutagenesis" => "datasets/Mutagenesis.md",
38+
"Titanic" => "datasets/Titanic.md",
3839
],
3940

4041
"Text" => Any[

docs/src/datasets/Titanic.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Titanic
2+
3+
```@docs
4+
Titanic
5+
```
6+
7+
## API reference
8+
9+
```@docs
10+
Titanic.feature_names
11+
Titanic.features
12+
Titanic.targets
13+
```

src/Titanic/Titanic.jl

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export Titanic
2+
23
"""
3-
Titanic Dataset
4+
Titanic Dataset.
45
56
The titanic and titanic2 data frames describe the survival status of individual passengers on the Titanic.
67
@@ -24,12 +25,6 @@ using the Encyclopedia Titanica and created a new dataset called titanic3.
2425
These datasets reflects the state of data available as of 2 August 1999.
2526
Some duplicate passengers have been dropped, many errors corrected, many missing ages filled in, and new variables created.
2627
27-
# Interface
28-
29-
- [`Titanic.features`](@ref)
30-
- [`Titanic.targets`](@ref)
31-
- [`Titanic.feature_names`](@ref)
32-
3328
DATASET specs
3429
3530
NAME: titanic3
@@ -63,8 +58,6 @@ body Body Identification Number
6358
home.dest Home/Destination
6459
6560
66-
67-
6861
SPECIAL NOTES
6962
7063
Pclass is a proxy for socio-economic status (SES) 1st ~ Upper; 2nd ~ Middle; 3rd ~ Lower
@@ -94,6 +87,12 @@ attach (titanic3)
9487
plsmo (age, survived, group=sex, datadensity=T)
9588
# or group=pclass plot (naclus (titanic3)) # study patterns of missing values summary (survived ~ age + sex + pclass + sibsp + parch, data=titanic3)
9689
90+
91+
# Interface
92+
93+
- [`Titanic.features`](@ref)
94+
- [`Titanic.targets`](@ref)
95+
- [`Titanic.feature_names`](@ref)
9796
"""
9897
module Titanic
9998

@@ -116,45 +115,45 @@ julia> using MLDatasets: Titanic
116115
julia> target = Titanic.targets();
117116
118117
julia> summary(target)
119-
"1×891 Matrix{Float64}"
120-
121-
"""
118+
"1×891 Matrix{Any}"
122119
120+
julia> target[1]
121+
0
122+
```
123+
"""
123124
function targets(; dir = nothing)
124125
titanic_data = readdlm(DATA, ',')
125-
reshape(Vector(titanic_data[2:end,2]), (1, 891))
126+
reshape(Vector(titanic_data[2:end, 2]), (1, 891))
126127
end
127128

128129
"""
129130
feature_names()
130131
131132
Return the the names of the features provided in the dataset.
132133
"""
133-
134134
function feature_names()
135135
["PassengerId", "Pclass", "Name", "Sex", "Age", "SibSp", "Parch", "Ticket", "Fare", "Cabin", "Embarked"]
136136
end
137137

138138
"""
139139
features()
140140
141-
Return the features of the Boston Housing dataset. This is a 13x506 Matrix of Float64 datatypes.
142-
The values are in the order ["crim","zn","indus","chas","nox","rm","age","dis","rad","tax","ptratio","b","lstat"].
143-
It has 506 examples.
141+
Return the features of the Titanic dataset. This is a 11x891 Matrix of containing both String and Float datatypes.
142+
The values are in the order ["PassengerId", "Pclass", "Name", "Sex", "Age", "SibSp", "Parch", "Ticket", "Fare", "Cabin", "Embarked"].
143+
It has 891 examples.
144144
145145
```jldoctest
146-
julia> using MLDatasets: BostonHousing
146+
julia> using MLDatasets: Titanic
147147
148-
julia> features = BostonHousing.features();
148+
julia> features = Titanic.features();
149149
150150
julia> summary(features)
151-
"13×506 Matrix{Float64}"
151+
"11×891 Matrix{Any}"
152152
```
153153
"""
154-
155154
function features()
156155
titanic_data = readdlm(DATA, ',')
157-
reshape(Matrix(hcat(titanic_data[2:end, 1], titanic_data[2:end, 3:12])),(11,891))
156+
reshape(Matrix(hcat(titanic_data[2:end, 1], titanic_data[2:end, 3:12])), (11, 891))
158157
end
159158

160159
end # module

0 commit comments

Comments
 (0)