From 1900785502d9066b31ed5311fab334f21eb9454e Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Thu, 29 Feb 2024 21:16:55 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=B2=D0=B5=D1=81=D0=BE=D0=B2=D1=8B=D0=B5?= =?UTF-8?q?=20=D0=BA=D0=BE=D1=8D=D1=84=D1=84=D0=B8=D1=86=D0=B8=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D1=8B=20(#126)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- statapp/calculations.py | 9 ++++++--- statapp/models/regression_result_model.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/statapp/calculations.py b/statapp/calculations.py index 8c1c759..4359ca4 100644 --- a/statapp/calculations.py +++ b/statapp/calculations.py @@ -132,8 +132,11 @@ def _calculateStatistics(y, x, xPoly, predictions, model, polyFeatures): ) # Заменяем пробелы на звездочки для представления умножения в названиях мономов monomials = [monomial.replace(' ', '*') for monomial in monomials] + weightsCoef = np.concatenate((np.array([0]), tStats[1:] / np.sum(tStats[1:]))) # Возвращаем рассчитанные статистики и названия мономов - return params, tStats, residualVariance, scaledResidualVariance, rSquared, fStatistic, monomials + return (params, tStats, weightsCoef, + residualVariance, scaledResidualVariance, + rSquared, fStatistic, monomials) @@ -142,7 +145,7 @@ def _regressionAnalysis(data, degree): data, degree ) model, predictions = _trainModelAndPredict(y, xPoly) - (params, tStats, residualVariance, + (params, tStats, weightsCoef, residualVariance, scaledResidualVariance, rSquared, fStatistic, monomials) = ( _calculateStatistics( y, @@ -154,7 +157,7 @@ def _regressionAnalysis(data, degree): )) return RegressionResult( - np.vstack((params, tStats)).T, + np.vstack((params, tStats, weightsCoef)).T, residualVariance, scaledResidualVariance, rSquared, diff --git a/statapp/models/regression_result_model.py b/statapp/models/regression_result_model.py index 059e6ea..17af473 100644 --- a/statapp/models/regression_result_model.py +++ b/statapp/models/regression_result_model.py @@ -28,7 +28,7 @@ class RegressionResultModel(ROTableModel): self._monomials = result.monomials def getHorizontalHeader(self): - return ['Коэффициент регрессии', 'Коэффициент значимости'] + return ['Коэффициент регрессии', 'Коэффициент значимости', 'Весовые коэффициенты'] def getVerticalHeader(self): return self._monomials