From aaa236b14ce3ac29e8beea450636fc49277ddc94 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 28 Apr 2023 18:48:47 +0200 Subject: [PATCH] Cleaned up MLPPUniLinReg. --- mlpp/uni_lin_reg/uni_lin_reg.cpp | 33 ++++++++++++++++++++------------ mlpp/uni_lin_reg/uni_lin_reg.h | 13 ++++++++----- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/mlpp/uni_lin_reg/uni_lin_reg.cpp b/mlpp/uni_lin_reg/uni_lin_reg.cpp index d5abe6c..38f82cb 100644 --- a/mlpp/uni_lin_reg/uni_lin_reg.cpp +++ b/mlpp/uni_lin_reg/uni_lin_reg.cpp @@ -15,28 +15,35 @@ // Univariate Linear Regression Model // ลท = b0 + b1x1 -Ref MLPPUniLinReg::get_input_set() { +Ref MLPPUniLinReg::get_input_set() const { return _input_set; } void MLPPUniLinReg::set_input_set(const Ref &val) { _input_set = val; } -Ref MLPPUniLinReg::get_output_set() { +Ref MLPPUniLinReg::get_output_set() const { return _output_set; } void MLPPUniLinReg::set_output_set(const Ref &val) { _output_set = val; } -real_t MLPPUniLinReg::get_b0() { +real_t MLPPUniLinReg::get_b0() const { return _b0; } -real_t MLPPUniLinReg::get_b1() { - return _b1; +void MLPPUniLinReg::set_b0(const real_t val) { + _b0 = val; } -void MLPPUniLinReg::initialize() { +real_t MLPPUniLinReg::get_b1() const { + return _b1; +} +void MLPPUniLinReg::set_b1(const real_t val) { + _b1 = val; +} + +void MLPPUniLinReg::fit() { ERR_FAIL_COND(!_input_set.is_valid() || !_output_set.is_valid()); MLPPStat estimator; @@ -59,10 +66,7 @@ MLPPUniLinReg::MLPPUniLinReg(const Ref &p_input_set, const Ref get_input_set(); + Ref get_input_set() const; void set_input_set(const Ref &val); - Ref get_output_set(); + Ref get_output_set() const; void set_output_set(const Ref &val); - real_t get_b0(); - real_t get_b1(); + real_t get_b0() const; + void set_b0(const real_t val); - void initialize(); + real_t get_b1() const; + void set_b1(const real_t val); + + void fit(); Ref model_set_test(const Ref &x); real_t model_test(real_t x);