Changes: Colors for Prediction added
This commit is contained in:
parent
1bafb21f5c
commit
ff9d56c005
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "definma",
|
||||
"version": "0.5.5",
|
||||
"version": "0.9.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<rb-full-header id="top">
|
||||
<nav *rbMainNavItems>
|
||||
<a routerLink="/home" routerLinkActive="active" rbLoadingLink>Home</a>
|
||||
<a routerLink="/prediction" routerLinkActive="active" rbLoadingLink *ngIf="login.isLevel.dev">Prediction</a>
|
||||
<a routerLink="/prediction" routerLinkActive="active" rbLoadingLink *ngIf="login.hasPrediction">Prediction</a>
|
||||
<a routerLink="/models" routerLinkActive="active" rbLoadingLink *ngIf="login.isLevel.dev">Models</a>
|
||||
<a routerLink="/samples" routerLinkActive="active" rbLoadingLink *ngIf="login.isLevel.read">Samples</a>
|
||||
<a routerLink="/materials" routerLinkActive="active" rbLoadingLink *ngIf="login.isLevel.dev">Materials</a>
|
||||
|
@ -11,17 +11,29 @@
|
||||
<div *ngIf="result" class="result" [@inOut]>
|
||||
<ng-container *ngIf="multipleSamples; else singleSampleResult">
|
||||
<h4 *ngFor="let prediction of result.predictions; index as i">
|
||||
{{spectrumNames[i]}}: {{prediction}}<a [routerLink]='"."' fragment="disclaimer"><sup>#</sup></a>
|
||||
{{spectrumNames[i]}}:
|
||||
<span *ngFor="let predictionEntry of prediction">
|
||||
{{predictionEntry.category}} <span [ngStyle]="{color: predictionEntry.color}">{{predictionEntry.value}}</span> {{predictionEntry.label}}
|
||||
</span>
|
||||
<a [routerLink]='"."' fragment="disclaimer"><sup>#</sup></a>
|
||||
</h4>
|
||||
</ng-container>
|
||||
<ng-template #singleSampleResult>
|
||||
<h4>
|
||||
Average result: {{result.mean}}<a [routerLink]='"."' fragment="disclaimer"><sup>#</sup></a>
|
||||
Average result:
|
||||
<span *ngFor="let predictionEntry of result.mean">
|
||||
{{predictionEntry.category}} <span [ngStyle]="{color: predictionEntry.color}">{{predictionEntry.value}}</span> {{predictionEntry.label}} {{( predictionEntry.std !== '' ? ' (standard deviation: '+ predictionEntry.std+')' : '') }}
|
||||
</span>
|
||||
<a [routerLink]='"."' fragment="disclaimer"><sup>#</sup></a>
|
||||
</h4>
|
||||
<a class="rb-details-toggle" rbDetailsToggle #triggerDetails="rbDetailsToggle">Details</a>
|
||||
<div *ngIf="triggerDetails.open" class="space-below">
|
||||
<p *ngFor="let prediction of result.predictions; index as i">
|
||||
{{spectrumNames[i]}}: {{prediction}}<a [routerLink]='"."' fragment="disclaimer"><sup>#</sup></a>
|
||||
{{spectrumNames[i]}}:
|
||||
<span *ngFor="let predictionEntry of prediction">
|
||||
{{predictionEntry.category}} <span [ngStyle]="{color: predictionEntry.color}">{{predictionEntry.value}}</span> {{predictionEntry.label}}
|
||||
</span>
|
||||
<a [routerLink]='"."' fragment="disclaimer"><sup>#</sup></a>
|
||||
</p>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
@ -29,7 +29,7 @@ import {ModelItemModel} from '../models/model-item.model';
|
||||
})
|
||||
export class PredictionComponent implements OnInit {
|
||||
|
||||
result: {predictions: string[], mean: string}; // prediction result from python container
|
||||
result: {predictions: any[], mean: any[]}; // prediction result from python container
|
||||
loading = false;
|
||||
activeGroup: ModelItemModel = new ModelItemModel();
|
||||
activeModelIndex = 0;
|
||||
@ -104,14 +104,12 @@ export class PredictionComponent implements OnInit {
|
||||
loadPrediction() {
|
||||
this.loading = true;
|
||||
this.api.post<any>(this.activeGroup.models[this.activeModelIndex].url, this.flattenedSpectra, data => {
|
||||
this.result = { // parse result into prediction and mean string
|
||||
predictions: Object.entries(omit(data, ['mean', 'std', 'label']))
|
||||
.map((p: any) => p[1].map(e => `${p[0]}: ${e} ${data.label[p[0]]}`))
|
||||
.reduce((s, e) => s.map((el, i) => this.clip(el) + ', ' + e[i])),
|
||||
mean: Object.keys(data.mean).map(e =>
|
||||
this.clip(`${e}: ${data.mean[e]} ${data.label[e]}`) +
|
||||
(data.std[e] !== '' ? ` (standard deviation: ${data.std[e]})` : '')
|
||||
).join(', ')
|
||||
let tmp = Object.entries(omit(data, ['mean', 'std', 'label'])) // form: [[label, [{value, color}]]]
|
||||
.map((entry: any) => entry[1].map(e => ({category: entry[0], label: data.label[entry[0]], value: e.value, color: e.color}))); // form: [[{category, label, value, color}]]
|
||||
this.result = {
|
||||
predictions: tmp[0].map((ignore, columnIndex) => tmp.map(row => row[columnIndex])), // transpose tmp
|
||||
mean: Object.entries(data.mean)
|
||||
.map((entry:any) => ({category: entry[0], label: data.label[entry[0]], value: entry[1].value, color: entry[1].color, std: data.std[entry[0]]})) // form: [{category, label, value, color}]
|
||||
};
|
||||
this.loading = false;
|
||||
});
|
||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 148 KiB |
Loading…
Reference in New Issue
Block a user