File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,18 @@ import GLM
2222import DecisionTree as DT
2323import NearestNeighbors as NN
2424
25+ include (" labeledtable.jl" )
2526include (" interface.jl" )
2627include (" models/nn.jl" )
2728include (" models/glm.jl" )
2829include (" models/tree.jl" )
2930include (" learn.jl" )
3031
3132export
33+ # labeled table
34+ LabeledTable,
35+ label,
36+
3237 # NearestNeighbors.jl
3338 KNNClassifier,
3439 KNNRegressor,
Original file line number Diff line number Diff line change 1+ # ------------------------------------------------------------------
2+ # Licensed under the MIT License. See LICENSE in the project root.
3+ # ------------------------------------------------------------------
4+
5+ """
6+ LabeledTable(table, names)
7+
8+ Stores a Tables.jl `table` along with column `names` that
9+ identify which columns are labels for supervised learning.
10+ """
11+ struct LabeledTable{T}
12+ table:: T
13+ labels:: Vector{Symbol}
14+ end
15+
16+ function LabeledTable (table, names)
17+ Tables. istable (table) || throw (ArgumentError (" please provide a valid Tables.jl table" ))
18+ cols = Tables. columns (table)
19+ vars = Tables. columnnames (cols)
20+ labs = selector (names)(vars)
21+ labs ⊆ vars || throw (ArgumentError (" all labels must be column names in the table" ))
22+ vars ⊆ labs && throw (ArgumentError (" there must be at least one feature column in the table" ))
23+ LabeledTable {typeof(table)} (table, labs)
24+ end
25+
26+ """
27+ label(table, names)
28+
29+ Creates a `LabeledTable` from `table` using `names` as label columns.
30+ """
31+ label (table, names) = LabeledTable (table, names)
You can’t perform that action at this time.
0 commit comments