diff --git a/Project.toml b/Project.toml index 3b2170b..8edef99 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MLJTuning" uuid = "03970b2e-30c4-11ea-3135-d1576263f10f" authors = ["Anthony D. Blaom "] -version = "0.1.2" +version = "0.1.3" [deps] ComputationalResources = "ed09eef8-17a6-5b46-8889-db040fac31e3" @@ -11,10 +11,10 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" [compat] -julia = "^1" -MLJBase = "^0.10.1" ComputationalResources = "^0.3" -RecipesBase = "^0.7" +MLJBase = "^0.11.1" +RecipesBase = "^0.8" +julia = "^1" [extras] CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" @@ -22,6 +22,7 @@ DecisionTree = "7806a523-6efd-50cb-b5f6-3fa6f1930dbb" Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea" MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411" NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce" ScientificTypes = "321657f4-b219-11e9-178b-2701a2544e81" @@ -31,4 +32,4 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["CategoricalArrays", "DecisionTree", "Distances", "Distributions", "LinearAlgebra", "MultivariateStats", "NearestNeighbors", "ScientificTypes", "Statistics", "StatsBase", "Tables", "Test"] +test = ["CategoricalArrays", "DecisionTree", "Distances", "Distributions", "LinearAlgebra", "MLJModelInterface", "MultivariateStats", "NearestNeighbors", "ScientificTypes", "Statistics", "StatsBase", "Tables", "Test"] diff --git a/README.md b/README.md index 0559660..0f77285 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ learning models. ### Contents - [Who is this repo for?](#who-is-this-repo-for) - - [What's provided here?](#what's-provided-here) + - [What's provided here?](#what-is-provided-here) - [How do I implement a new tuning strategy?](#How-do-I-implement-a-new-tuning-strategy) *Note:* This component of the [MLJ @@ -46,7 +46,7 @@ MLJTuning is a component of the [MLJ there. -## What's provided here? +## What is provided here? This repository contains: diff --git a/src/strategies/explicit.jl b/src/strategies/explicit.jl index 29f9cd4..5075fba 100644 --- a/src/strategies/explicit.jl +++ b/src/strategies/explicit.jl @@ -1,4 +1,4 @@ -mutable struct Explicit <: TuningStrategy end +mutable struct Explicit <: TuningStrategy end # models! returns all available models in the range at once: MLJTuning.models!(tuning::Explicit, model, history::Nothing, diff --git a/test/models.jl b/test/models.jl index 9bb16ea..e73014c 100644 --- a/test/models.jl +++ b/test/models.jl @@ -7,6 +7,8 @@ module Models using MLJBase +import MLJModelInterface: @mlj_model, metadata_model, metadata_pkg +import MLJModelInterface include("models/Constant.jl") include("models/DecisionTree.jl") diff --git a/test/models/Constant.jl b/test/models/Constant.jl index 2438dc0..55e611e 100644 --- a/test/models/Constant.jl +++ b/test/models/Constant.jl @@ -5,7 +5,6 @@ export ConstantClassifier, ConstantRegressor, ProbabilisticConstantClassifer import MLJBase -import MLJBase: metadata_pkg, metadata_model import Distributions """ diff --git a/test/models/DecisionTree.jl b/test/models/DecisionTree.jl index 7ab9d9b..ce71e24 100755 --- a/test/models/DecisionTree.jl +++ b/test/models/DecisionTree.jl @@ -1,8 +1,5 @@ export DecisionTreeClassifier, DecisionTreeRegressor -import MLJBase -import MLJBase: @mlj_model, metadata_pkg, metadata_model - using ScientificTypes using CategoricalArrays diff --git a/test/models/MultivariateStats.jl b/test/models/MultivariateStats.jl index 83fe4bc..dcd9313 100644 --- a/test/models/MultivariateStats.jl +++ b/test/models/MultivariateStats.jl @@ -1,7 +1,5 @@ export RidgeRegressor, PCA -import MLJBase -import MLJBase: @mlj_model, metadata_model, metadata_pkg # using Distances using LinearAlgebra using Tables, ScientificTypes diff --git a/test/models/NearestNeighbors.jl b/test/models/NearestNeighbors.jl index 7cfcb51..277a564 100644 --- a/test/models/NearestNeighbors.jl +++ b/test/models/NearestNeighbors.jl @@ -1,6 +1,5 @@ export KNNRegressor, KNNClassifier -import MLJBase: @mlj_model, metadata_model, metadata_pkg using Distances import NearestNeighbors diff --git a/test/models/Transformers.jl b/test/models/Transformers.jl index 7306e64..bbd6356 100644 --- a/test/models/Transformers.jl +++ b/test/models/Transformers.jl @@ -5,6 +5,8 @@ export FeatureSelector, UnivariateBoxCoxTransformer, OneHotEncoder, UnivariateDiscretizer +import MLJModelInterface: @mlj_model, metadata_model, metadata_pkg + using Statistics const N_VALUES_THRESH = 16 # for BoxCoxTransformation @@ -158,15 +160,15 @@ function MLJBase.fit(transformer::UnivariateDiscretizer, verbosity::Int,X) return res, cache, report end + # acts on scalars: function transform_to_int( - result::UnivariateDiscretizerResult{<:CategoricalElement{R}}, - r::Real) where R - - k = R(1) - for q in result.odd_quantiles + result::UnivariateDiscretizerResult{<:CategoricalValue{R}}, + r::Real) where R + k = oneR = R(1) + @inbounds for q in result.odd_quantiles if r > q - k += R(1) + k += oneR end end return k