Skip to content

Commit

Permalink
rename n_iter to max_iter to avoid breaking change with v1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerjthomas9 committed Jan 20, 2024
1 parent 7aa9594 commit bd5086b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/models/linear-regressors.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const ARDRegressor_ = sklm(:ARDRegression)
@sk_reg mutable struct ARDRegressor <: MMI.Deterministic
# TODO: rename `n_iter` to `max_iter` in v1.5
n_iter::Int = 300::(_ > 0)
max_iter::Int = 300::(_ > 0)
tol::Float64 = 1e-3::(_ > 0)
alpha_1::Float64 = 1e-6::(_ > 0)
alpha_2::Float64 = 1e-6::(_ > 0)
Expand All @@ -19,16 +18,16 @@ MMI.fitted_params(model::ARDRegressor, (fitresult, _, _)) = (
alpha = fitresult.alpha_,
lambda = fitresult.lambda_,
sigma = fitresult.sigma_,
scores = fitresult.scores_
scores = fitresult.scores_,
n_iter = fitresult.n_iter_,
)
add_human_name_trait(ARDRegressor, "Bayesian ARD regressor")
@sk_feature_importances ARDRegressor

# =============================================================================
const BayesianRidgeRegressor_ = sklm(:BayesianRidge)
@sk_reg mutable struct BayesianRidgeRegressor <: MMI.Deterministic
# TODO: rename `n_iter` to `max_iter` in v1.5
n_iter::Int = 300::(_ ≥ 1)
max_iter::Int = 300::(_ ≥ 1)
tol::Float64 = 1e-3::(_ > 0)
alpha_1::Float64 = 1e-6::(_ > 0)
alpha_2::Float64 = 1e-6::(_ > 0)
Expand All @@ -45,7 +44,8 @@ MMI.fitted_params(model::BayesianRidgeRegressor, (fitresult, _, _)) = (
alpha = fitresult.alpha_,
lambda = fitresult.lambda_,
sigma = fitresult.sigma_,
scores = fitresult.scores_
scores = fitresult.scores_,
n_iter = fitresult.n_iter_,
)
add_human_name_trait(BayesianRidgeRegressor, "Bayesian ridge regressor")
@sk_feature_importances BayesianRidgeRegressor
Expand Down
8 changes: 4 additions & 4 deletions test/macros.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@testset "reg-mdl" begin
m = ARDRegressor()
@test m isa MB.Deterministic
@test m.n_iter > 0
@test m.max_iter > 0
# set
m = ARDRegressor(n_iter=100)
@test m.n_iter == 100
m = ARDRegressor(max_iter=100)
@test m.max_iter == 100
# clean method
@test @test_logs (:warn, r"Constraint") ARDRegressor(n_iter=-5).n_iter > 0
@test @test_logs (:warn, r"Constraint") ARDRegressor(max_iter=-5).max_iter > 0

# traits
@test MB.load_path(m) == "MLJScikitLearnInterface.ARDRegressor"
Expand Down
4 changes: 2 additions & 2 deletions test/models/linear-regressors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ models = (
)

fparams = (
ARDRegressor=(:coef, :intercept, :alpha, :lambda, :sigma, :scores),
BayesianRidgeRegressor=(:coef, :intercept, :alpha, :lambda, :sigma, :scores),
ARDRegressor=(:coef, :intercept, :alpha, :lambda, :sigma, :scores, :n_iter),
BayesianRidgeRegressor=(:coef, :intercept, :alpha, :lambda, :sigma, :scores, :n_iter),
ElasticNetRegressor=(:coef, :intercept),
ElasticNetCVRegressor=(:coef, :intercept, :l1_ratio, :mse_path, :alphas),
HuberRegressor=(:coef, :intercept, :scale, :outliers),
Expand Down

0 comments on commit bd5086b

Please sign in to comment.