blob: 3840692a995f21bdd2fc4a46b4ba566f1c7410aa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
}
}
|