Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions statapp/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand All @@ -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,
Expand All @@ -154,7 +157,7 @@ def _regressionAnalysis(data, degree):
))

return RegressionResult(
np.vstack((params, tStats)).T,
np.vstack((params, tStats, weightsCoef)).T,
residualVariance,
scaledResidualVariance,
rSquared,
Expand Down
2 changes: 1 addition & 1 deletion statapp/models/regression_result_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, result: RegressionResult):
self._monomials = result.monomials

def getHorizontalHeader(self):
return ['Коэффициент регрессии', 'Коэффициент значимости']
return ['Коэффициент регрессии', 'Коэффициент значимости', 'Весовые коэффициенты']

def getVerticalHeader(self):
return self._monomials
Loading