-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from JuliaAI/dev
For a 0.1.1 release
- Loading branch information
Showing
21 changed files
with
230 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "StatisticalMeasures" | ||
uuid = "a19d573c-0a75-4610-95b3-7071388c7541" | ||
authors = ["Anthony D. Blaom <[email protected]>"] | ||
version = "0.1.0" | ||
version = "0.1.1" | ||
|
||
[deps] | ||
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" | ||
|
@@ -13,16 +13,19 @@ LossFunctions = "30fc2ffe-d236-52d8-8643-a9d8f7c094a7" | |
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" | ||
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" | ||
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" | ||
ScientificTypes = "321657f4-b219-11e9-178b-2701a2544e81" | ||
ScientificTypesBase = "30f210dd-8aff-4c5f-94ba-8e64358c1161" | ||
StatisticalMeasuresBase = "c062fc1d-0d66-479b-b6ac-8b44719de4cc" | ||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" | ||
|
||
[weakdeps] | ||
LossFunctions = "30fc2ffe-d236-52d8-8643-a9d8f7c094a7" | ||
ScientificTypes = "321657f4-b219-11e9-178b-2701a2544e81" | ||
|
||
[extensions] | ||
LossFunctionsExt = "LossFunctions" | ||
ScientificTypesExt = "ScientificTypes" | ||
|
||
[compat] | ||
CategoricalArrays = "0.10" | ||
|
@@ -33,6 +36,7 @@ LossFunctions = "0.10" | |
MacroTools = "0.5" | ||
OrderedCollections = "1" | ||
PrecompileTools = "1.1" | ||
ScientificTypes = "3" | ||
ScientificTypesBase = "3" | ||
StatisticalMeasuresBase = "0.1" | ||
StatsBase = "0.33, 0.34" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module ScientificTypesExt | ||
using ScientificTypes | ||
import ScientificTypes.Tables | ||
using StatisticalMeasures | ||
import StatisticalMeasuresBase.MLUtils | ||
import Distributions | ||
import LearnAPI | ||
|
||
# # HELPERS | ||
|
||
guess_observation_scitype(y) = guess_observation_scitype(y, Val(Tables.istable(y))) | ||
guess_observation_scitype(y, ::Val{false}) = MLUtils.getobs(y, 1) |> scitype | ||
guess_observation_scitype(table, ::Val{true}) = | ||
MLUtils.getobs(table, 1) |> collect |> scitype | ||
|
||
|
||
# # MEASURE SEARCH BASED ON ARGUMENTS | ||
|
||
StatisticalMeasures.measures(y; kwargs...) = filter(measures(; kwargs...)) do (_, metadata) | ||
guess_observation_scitype(y) <: metadata.observation_scitype | ||
end | ||
|
||
function StatisticalMeasures.measures(yhat, y; trait_filters...) | ||
y_scitype = guess_observation_scitype(y) | ||
yhat_scitype = guess_observation_scitype(yhat) | ||
filter(measures(; trait_filters...)) do (_, metadata) | ||
requirement1 = y_scitype <: metadata.observation_scitype | ||
proxy = metadata.kind_of_proxy | ||
requirement2 = if proxy == LearnAPI.LiteralTarget() | ||
yhat_scitype <: metadata.observation_scitype | ||
elseif proxy == LearnAPI.Distribution() | ||
yhat_scitype <: Density{<:y_scitype} | ||
else | ||
false | ||
end | ||
requirement3 = !Tables.istable(y) || metadata.can_consume_tables | ||
requirement1 && requirement2 && requirement3 | ||
end | ||
end | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,4 @@ function API.check_pools( | |
end | ||
return nothing | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using ScientificTypes | ||
using ScientificTypes.Tables | ||
|
||
n = 10 | ||
p = 3 | ||
y = rand(p, n) | ||
yhat = rand(p, n) | ||
t = y' |> Tables.table |> Tables.columntable | ||
that = yhat' |> Tables.table |> Tables.columntable | ||
|
||
ms = measures(t) | ||
@test all(ms) do (_, metadata) | ||
AbstractVector{Continuous} <: metadata.observation_scitype | ||
end | ||
|
||
ms = measures(that, t) | ||
@test all(ms) do (_, metadata) | ||
AbstractVector{Continuous} <: metadata.observation_scitype | ||
end | ||
|
||
y = categorical(rand("ab", n)) | ||
yhat = UnivariateFinite(levels(y), rand(n), augment=true, pool=y) | ||
ms2 = measures((yhat, y)) | ||
@test all(ms2) do (_, metadata) | ||
Multiclass{2} <: metadata.observation_scitype && | ||
metadata.kind_of_proxy == LearnAPI.Distribution() | ||
end | ||
|
||
@test isempty(intersect(keys(ms), keys(ms2))) |
Oops, something went wrong.