Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
move targets, gettargets, and gettarget here from MLDataUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
Evizero committed Mar 31, 2017
1 parent 2be62bf commit 9e8ea40
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/LearnBase.jl
Expand Up @@ -155,6 +155,40 @@ function getobs! end

# --------------------------------------------------------------------

# gettarget([f], observation)
#
# Use `f` (if provided) to extract the target from the single
# `observation` and return it. It is used internally by
# `targets` (only if `f` is provided) and by
# `eachtarget` (always) on each individual observation.
#
# Even though this function is not exported, it is intended to be
# extended by users to support their custom data storage types.
#
# This function is implemented in MLDataPattern
function gettarget end # not exported

# gettargets(data, [idx], [obsdim])
#
# Return the targets corresponding to the observation-index `idx`.
# Note that `idx` can be of type `Int` or `AbstractVector`.
#
# Implementing this function for a custom type of `data` is
# optional. It is particularly useful if the targets in `data` can
# be provided without invoking `getobs`. For example if you have a
# remote data-source where the labels are part of some metadata
# that is locally available.
#
# This function is implemented in MLDataPattern
function gettargets end # not exported

# targets([f], data, [obsdim])
#
# This function is implemented in MLDataPattern
function targets end

# --------------------------------------------------------------------

"""
datasubset(data, [indices], [obsdim])
Expand Down Expand Up @@ -422,6 +456,8 @@ export
datasubset,
ObsDim,

targets,

# StatsBase
fit,
fit!,
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Expand Up @@ -67,6 +67,10 @@ using Base.Test
@test typeof(getobs!) <: Function
@test typeof(datasubset) <: Function

@test typeof(targets) <: Function
@test typeof(LearnBase.gettarget) <: Function
@test typeof(LearnBase.gettargets) <: Function

@test typeof(fit) <: Function
@test typeof(fit!) <: Function
@test typeof(nobs) <: Function
Expand Down

0 comments on commit 9e8ea40

Please sign in to comment.