feat: добавлен график (#94)

Closes #86
This commit is contained in:
Maxim Slipenko 2024-01-08 16:09:12 +03:00 committed by GitHub
parent 7cbb93e37c
commit bb1b2f1ec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 114 additions and 37 deletions

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).
@ -17,7 +17,11 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import numpy as np
from PySide2.QtWidgets import QDialog, QHeaderView from PySide2.QtWidgets import QDialog, QHeaderView
import matplotlib
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
from matplotlib.figure import Figure
from statapp.calculations import prediction from statapp.calculations import prediction
from statapp.mathtex_header_view import MathTexHeaderView from statapp.mathtex_header_view import MathTexHeaderView
@ -27,6 +31,15 @@ from statapp.ui.ui_polynom_window import Ui_PolynomWindow
from statapp.utils import addIcon, FloatDelegate from statapp.utils import addIcon, FloatDelegate
matplotlib.use('Qt5Agg')
class MplCanvas(FigureCanvasQTAgg):
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot()
super().__init__(fig)
class PolynomWindow(QDialog): class PolynomWindow(QDialog):
def __init__(self, data, result, windowTitle): def __init__(self, data, result, windowTitle):
super().__init__() super().__init__()
@ -47,7 +60,30 @@ class PolynomWindow(QDialog):
self.ui.fStatisticValueLabel.setText(str(result.fStatistic)) self.ui.fStatisticValueLabel.setText(str(result.fStatistic))
self.ui.rSquaredValueLabel.setText(str(result.scaledResidualVariance)) self.ui.rSquaredValueLabel.setText(str(result.scaledResidualVariance))
self.predictionModel = PreditionTableModel(prediction(data, result)) predictionResult = prediction(data, result)
self.predictionModel = PreditionTableModel(predictionResult)
self.ui.predictionTableView.setModel(self.predictionModel) self.ui.predictionTableView.setModel(self.predictionModel)
header = self.ui.predictionTableView.horizontalHeader() header = self.ui.predictionTableView.horizontalHeader()
header.setSectionResizeMode(QHeaderView.ResizeMode.Stretch) header.setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
sc = MplCanvas(self, width=5, height=4, dpi=100)
xAxes = np.array(range(len(data[:, 0])))
realY = predictionResult[:, 0]
calculatedY = predictionResult[:, 1]
print(xAxes)
print(realY)
print(calculatedY)
sc.axes.scatter(xAxes, realY)
# xnew = np.linspace(xAxes.min(), xAxes.max(), 300)
# gfg = scipy.interpolate.make_interp_spline(xAxes, y, k=3)
# y_new = gfg(xnew)
sc.axes.plot(xAxes, calculatedY)
self.ui.plotContainer.addWidget(sc)

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).
@ -26,6 +26,7 @@ from statapp.combo_delegate import ComboDelegate
from statapp.mathtex_header_view import MathTexHeaderView from statapp.mathtex_header_view import MathTexHeaderView
from statapp.models.prediction_table_model import PreditionTableModel from statapp.models.prediction_table_model import PreditionTableModel
from statapp.models.transform_polynom_model import TransformPolynomModel, TRANSFORMS from statapp.models.transform_polynom_model import TransformPolynomModel, TRANSFORMS
from statapp.polynoms.polynom_window import MplCanvas
from statapp.ui.ui_polynom_window import Ui_PolynomWindow from statapp.ui.ui_polynom_window import Ui_PolynomWindow
from statapp.utils import addIcon from statapp.utils import addIcon
@ -41,11 +42,20 @@ class TransformPolynomWindow(QDialog):
self.data = data self.data = data
result = linearPolynom(data) result = linearPolynom(data)
self.predictionModel = PreditionTableModel(prediction(data, result)) predictionResult = prediction(data, result)
self.predictionModel = PreditionTableModel(predictionResult)
self.ui.predictionTableView.setModel(self.predictionModel) self.ui.predictionTableView.setModel(self.predictionModel)
header = self.ui.predictionTableView.horizontalHeader() header = self.ui.predictionTableView.horizontalHeader()
header.setSectionResizeMode(QHeaderView.ResizeMode.Stretch) header.setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
self.sc = MplCanvas(self, width=5, height=4, dpi=100)
xAxes = np.array(range(len(data[:, 0])))
realY = predictionResult[:, 0]
calculatedY = predictionResult[:, 1]
self.sc.axes.scatter(xAxes, realY)
self.sc.axes.plot(xAxes, calculatedY)
self.ui.plotContainer.addWidget(self.sc)
# Создание столбца из нулей # Создание столбца из нулей
zeroCol = np.zeros((result.paramsAndImportance.shape[0], 1)) zeroCol = np.zeros((result.paramsAndImportance.shape[0], 1))
# Добавление столбца к исходному массиву # Добавление столбца к исходному массиву
@ -84,7 +94,17 @@ class TransformPolynomWindow(QDialog):
def rebuildData(self, data): def rebuildData(self, data):
result = linearPolynom(data) result = linearPolynom(data)
self.predictionModel.updateAllData(prediction(data, result)) predictionResult = prediction(data, result)
self.predictionModel.updateAllData(predictionResult)
self.ui.plotContainer.removeWidget(self.sc)
self.sc = MplCanvas(self, width=5, height=4, dpi=100)
xAxes = np.array(range(len(data[:, 0])))
realY = predictionResult[:, 0]
calculatedY = predictionResult[:, 1]
self.sc.axes.scatter(xAxes, realY)
self.sc.axes.plot(xAxes, calculatedY)
self.ui.plotContainer.addWidget(self.sc)
zeroCol = np.zeros((result.paramsAndImportance.shape[0], 1)) zeroCol = np.zeros((result.paramsAndImportance.shape[0], 1))
result.paramsAndImportance = np.column_stack((zeroCol, result.paramsAndImportance)) result.paramsAndImportance = np.column_stack((zeroCol, result.paramsAndImportance))
self.model.updateAllData(result) self.model.updateAllData(result)

View File

@ -120,6 +120,16 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>График</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QGridLayout" name="plotContainer"/>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).
@ -117,6 +117,16 @@ class Ui_PolynomWindow(object):
self.gridLayout_4.addWidget(self.predictionTableView, 0, 0, 1, 1) self.gridLayout_4.addWidget(self.predictionTableView, 0, 0, 1, 1)
self.tabWidget.addTab(self.prediction, "") self.tabWidget.addTab(self.prediction, "")
self.tab = QWidget()
self.tab.setObjectName(u"tab")
self.gridLayout_5 = QGridLayout(self.tab)
self.gridLayout_5.setObjectName(u"gridLayout_5")
self.plotContainer = QGridLayout()
self.plotContainer.setObjectName(u"plotContainer")
self.gridLayout_5.addLayout(self.plotContainer, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab, "")
self.gridLayout_2.addWidget(self.tabWidget, 0, 6, 1, 1) self.gridLayout_2.addWidget(self.tabWidget, 0, 6, 1, 1)
@ -141,4 +151,5 @@ class Ui_PolynomWindow(object):
self.rSquaredValueLabel.setText(QCoreApplication.translate("PolynomWindow", u"undefined", None)) self.rSquaredValueLabel.setText(QCoreApplication.translate("PolynomWindow", u"undefined", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.model), QCoreApplication.translate("PolynomWindow", u"\u041c\u043e\u0434\u0435\u043b\u044c", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.model), QCoreApplication.translate("PolynomWindow", u"\u041c\u043e\u0434\u0435\u043b\u044c", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.prediction), QCoreApplication.translate("PolynomWindow", u"\u041f\u0440\u043e\u0433\u043d\u043e\u0437", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.prediction), QCoreApplication.translate("PolynomWindow", u"\u041f\u0440\u043e\u0433\u043d\u043e\u0437", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QCoreApplication.translate("PolynomWindow", u"\u0413\u0440\u0430\u0444\u0438\u043a", None))
# retranslateUi # retranslateUi

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko. # Copyright (c) 2024 Maxim Slipenko, Eugene Lazurenko.
# #
# This file is part of Statapp # This file is part of Statapp
# (see https://github.com/shizand/statapp). # (see https://github.com/shizand/statapp).