feat: добавлены весовые коэффициенты (#126)

This commit is contained in:
Maxim Slipenko 2024-02-29 21:16:55 +03:00 committed by GitHub
parent babfd48ee1
commit 1900785502
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -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,

View File

@ -28,7 +28,7 @@ class RegressionResultModel(ROTableModel):
self._monomials = result.monomials
def getHorizontalHeader(self):
return ['Коэффициент регрессии', 'Коэффициент значимости']
return ['Коэффициент регрессии', 'Коэффициент значимости', 'Весовые коэффициенты']
def getVerticalHeader(self):
return self._monomials