aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_elements/metric-view/metric-view.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app/_elements/metric-view/metric-view.component.ts')
-rw-r--r--frontend/src/app/_elements/metric-view/metric-view.component.ts55
1 files changed, 36 insertions, 19 deletions
diff --git a/frontend/src/app/_elements/metric-view/metric-view.component.ts b/frontend/src/app/_elements/metric-view/metric-view.component.ts
index 18b0d1ad..9193a0e5 100644
--- a/frontend/src/app/_elements/metric-view/metric-view.component.ts
+++ b/frontend/src/app/_elements/metric-view/metric-view.component.ts
@@ -1,32 +1,49 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { SignalRService } from 'src/app/_services/signal-r.service';
+import { LineChartComponent } from '../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 {
- myAcc:[]=[];
- myMae:[]=[];
- myMse:[]=[];
- myEpochs:[]=[];
+ @ViewChild(LineChartComponent) linechartComponent!: LineChartComponent;
+
+ @Input() history!: any[];
+
constructor(private signalRService: SignalRService) { }
ngOnInit(): void {
- if(this.signalRService.hubConnection)
- {
- this.signalRService.hubConnection.on("NotifyEpoch", (mName: string, mId: string, stat: string, totalEpochs: number, currentEpoch: number) => {
- //console.log(stat)
- //console.log(totalEpochs)
- const data=JSON.parse(stat)
- for (let key in data)
- {
- let value = data[key];
- //console.log(value)
+ }
+
+ 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