aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_pages/experiment/experiment.component.ts
diff options
context:
space:
mode:
authorDanijel Anđelković <adanijel99@gmail.com>2022-06-04 01:17:55 +0200
committerDanijel Anđelković <adanijel99@gmail.com>2022-06-04 01:17:55 +0200
commit60782001174dc7f6f8f5670bff5aaca54667b734 (patch)
tree3839d149476115cbf7b954867a7c3bf2006c23f7 /frontend/src/app/_pages/experiment/experiment.component.ts
parent854e21f08d1c876cf62c7a360bd5bd142675d705 (diff)
Dodao poredjenje modela/prediktora nad eksperimentom. Popravio bug sa dodavanjem novog prediktora.
Diffstat (limited to 'frontend/src/app/_pages/experiment/experiment.component.ts')
-rw-r--r--frontend/src/app/_pages/experiment/experiment.component.ts71
1 files changed, 67 insertions, 4 deletions
diff --git a/frontend/src/app/_pages/experiment/experiment.component.ts b/frontend/src/app/_pages/experiment/experiment.component.ts
index 4ceb9a03..5822eedf 100644
--- a/frontend/src/app/_pages/experiment/experiment.component.ts
+++ b/frontend/src/app/_pages/experiment/experiment.component.ts
@@ -37,13 +37,27 @@ export class ExperimentComponent implements AfterViewInit {
@ViewChild("folderDataset") folderDataset!: FolderComponent;
@ViewChild(ColumnTableComponent) columnTable!: ColumnTableComponent;
@ViewChild("folderModel") folderModel!: FolderComponent;
- @ViewChild(LineChartComponent) linechartComponent!: LineChartComponent;
+ @ViewChild("folderModelCompare") folderModelCmp!: FolderComponent;
+ @ViewChild("linechart") linechartComponent!: LineChartComponent;
+ @ViewChild("linechartCompare") linechartComponentCmp!: LineChartComponent;
step1: boolean = false;
step2: boolean = false;
step3: boolean = false;
step4: boolean = false;
+ comparing: boolean = false;
+
+ toggleCompare() {
+ this.comparing = !this.comparing;
+ setTimeout(() => {
+ if (this.folderModel.formModel)
+ this.folderModel.formModel.graph.resize();
+ if (this.folderModel.formNewModel)
+ this.folderModel.formNewModel.graph.resize();
+ });
+ }
+
constructor(private experimentsService: ExperimentsService, private modelsService: ModelsService, private datasetsService: DatasetsService, private predictorsService: PredictorsService, private signalRService: SignalRService, private route: ActivatedRoute) {
this.experiment = new Experiment("exp1");
}
@@ -65,6 +79,15 @@ export class ExperimentComponent implements AfterViewInit {
}
}
+ trainModelCmp() {
+ if (!this.modelToTrainCmp) {
+ Shared.openDialog('Greška', 'Morate odabrati konfiguraciju neuronske mreže');
+ } else {
+ this.modelsService.trainModel(this.modelToTrainCmp._id, this.experiment._id).subscribe(() => { console.log("pocelo treniranje") });
+ this.step4 = true;
+ }
+ }
+
stepHeight = this.calcStepHeight();
calcStepHeight() {
@@ -87,16 +110,48 @@ export class ExperimentComponent implements AfterViewInit {
if (this.signalRService.hubConnection) {
this.signalRService.hubConnection.on("NotifyEpoch", (mName: string, mId: string, stat: string, totalEpochs: number, currentEpoch: number) => {
- if (currentEpoch == 0) {
- this.history = [];
- }
+
if (this.modelToTrain?._id == mId) {
+ if (currentEpoch == 0) {
+ this.linechartComponent.setName(mName);
+ this.history = [];
+ }
+
stat = stat.replace(/'/g, '"');
this.history.push(JSON.parse(stat));
+
this.linechartComponent.updateAll(this.history, this.modelToTrain.epochs);
}
+
+ if (this.modelToTrainCmp?._id == mId) {
+ if (currentEpoch == 0) {
+ this.linechartComponentCmp.setName(mName);
+ this.historyCmp = [];
+ }
+
+ stat = stat.replace(/'/g, '"');
+
+ this.historyCmp.push(JSON.parse(stat));
+ this.linechartComponentCmp.updateAll(this.historyCmp, this.modelToTrainCmp.epochs);
+ }
});
+ this.signalRService.hubConnection.on("NotifyPredictor", (pId: string, mId: string) => {
+ console.log("Predictor trained: ", pId, "for model:", mId);
+
+ if (this.modelToTrain && mId == this.modelToTrain._id) {
+ this.predictorsService.getPredictor(pId).subscribe((predictor) => {
+ this.linechartComponent.predictor = predictor;
+ });
+ }
+
+ if (this.modelToTrainCmp && mId == this.modelToTrainCmp._id) {
+ this.predictorsService.getPredictor(pId).subscribe((predictor) => {
+ this.linechartComponentCmp.predictor = predictor;
+ });
+ }
+ })
+
}
this.route.queryParams.subscribe(params => {
@@ -142,6 +197,7 @@ export class ExperimentComponent implements AfterViewInit {
}
history: any[] = [];
+ historyCmp: any[] = [];
updatePageIfScrolled() {
if (this.scrolling) return;
@@ -227,10 +283,17 @@ export class ExperimentComponent implements AfterViewInit {
}
modelToTrain?: Model;
+ modelToTrainCmp?: Model;
setModel(model: FolderFile) {
const m = <Model>model;
this.modelToTrain = m;
this.step3 = true;
}
+
+ setModelCmp(model: FolderFile) {
+ const m = <Model>model;
+ this.modelToTrainCmp = m;
+ this.step3 = true;
+ }
}