From 1177f4b29b616a59af39f4aef11b116f9660357d Mon Sep 17 00:00:00 2001 From: Danijel Anđelković Date: Sat, 23 Apr 2022 01:28:46 +0200 Subject: Reorganizovao stranice i komponente. --- .../_elements/metric-view/metric-view.component.ts | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 frontend/src/app/_elements/metric-view/metric-view.component.ts (limited to 'frontend/src/app/_elements/metric-view/metric-view.component.ts') diff --git a/frontend/src/app/_elements/metric-view/metric-view.component.ts b/frontend/src/app/_elements/metric-view/metric-view.component.ts new file mode 100644 index 00000000..3840692a --- /dev/null +++ b/frontend/src/app/_elements/metric-view/metric-view.component.ts @@ -0,0 +1,49 @@ +import { Component, Input, OnInit, ViewChild } from '@angular/core'; +import { LineChartComponent } from '../_charts/line-chart/line-chart.component'; + +@Component({ + selector: 'app-metric-view', + templateUrl: './metric-view.component.html', + styleUrls: ['./metric-view.component.css'] +}) +export class MetricViewComponent implements OnInit { + @ViewChild(LineChartComponent) linechartComponent!: LineChartComponent; + + constructor() { } + + ngOnInit(): void { + } + + history: any[] = []; + + update(history: any[]) { + const myAcc: number[] = []; + const myMae: number[] = []; + const myMse: number[] = []; + const myLoss: number[] = []; + + const myEpochs: number[] = []; + this.history = history; + this.history.forEach((metrics, epoch) => { + myEpochs.push(epoch + 1); + for (let key in metrics) { + let value = metrics[key]; + console.log(key, ':::', value, epoch); + if (key === 'accuracy') { + myAcc.push(parseFloat(value)); + } + else if (key === 'loss') { + myLoss.push(parseFloat(value)); + } + else if (key === 'mae') { + myMae.push(parseFloat(value)); + } + else if (key === 'mse') { + myMse.push(parseFloat(value)); + } + } + }); + + this.linechartComponent.update(myEpochs, myAcc, myLoss, myMae, myMse); + } +} \ No newline at end of file -- cgit v1.2.3