Skip to content

Commit

Permalink
Merge pull request #11 from alan-turing-institute/dev
Browse files Browse the repository at this point in the history
Update to MLJBase 0.11.1
  • Loading branch information
ablaom committed Feb 12, 2020
2 parents 869a38e + c053257 commit 7adad1a
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
11 changes: 6 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MLJTuning"
uuid = "03970b2e-30c4-11ea-3135-d1576263f10f"
authors = ["Anthony D. Blaom <[email protected]>"]
version = "0.1.2"
version = "0.1.3"

[deps]
ComputationalResources = "ed09eef8-17a6-5b46-8889-db040fac31e3"
Expand All @@ -11,17 +11,18 @@ 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"
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"
Expand All @@ -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"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +46,7 @@ MLJTuning is a component of the [MLJ
there.


## What's provided here?
## What is provided here?

This repository contains:

Expand Down
2 changes: 1 addition & 1 deletion src/strategies/explicit.jl
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 2 additions & 0 deletions test/models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion test/models/Constant.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export ConstantClassifier, ConstantRegressor,
ProbabilisticConstantClassifer

import MLJBase
import MLJBase: metadata_pkg, metadata_model
import Distributions

"""
Expand Down
3 changes: 0 additions & 3 deletions test/models/DecisionTree.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
export DecisionTreeClassifier, DecisionTreeRegressor

import MLJBase
import MLJBase: @mlj_model, metadata_pkg, metadata_model

using ScientificTypes

using CategoricalArrays
Expand Down
2 changes: 0 additions & 2 deletions test/models/MultivariateStats.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export RidgeRegressor, PCA

import MLJBase
import MLJBase: @mlj_model, metadata_model, metadata_pkg
# using Distances
using LinearAlgebra
using Tables, ScientificTypes
Expand Down
1 change: 0 additions & 1 deletion test/models/NearestNeighbors.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export KNNRegressor, KNNClassifier

import MLJBase: @mlj_model, metadata_model, metadata_pkg
using Distances

import NearestNeighbors
Expand Down
14 changes: 8 additions & 6 deletions test/models/Transformers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7adad1a

Please sign in to comment.