{{modelItem.name}}
- {{modelItem.label}}
{{modelItem.url}}
- {{spectrumNames[i]}}: {{prediction}} {{activeGroup.models[activeModelIndex].label}}
- #
+ {{spectrumNames[i]}}: {{prediction}}#
- Average result: {{result.meanPrediction}} {{activeGroup.models[activeModelIndex].label}}
- # ,
- standard deviation: {{result.std}}#
+ Average result: {{result.mean}}#
Details
- {{spectrumNames[i]}}: {{prediction}} {{activeGroup.models[activeModelIndex].label}}
- #
+ {{spectrumNames[i]}}: {{prediction}}#
diff --git a/src/app/prediction/prediction.component.ts b/src/app/prediction/prediction.component.ts
index 075c150..d6cb0c2 100644
--- a/src/app/prediction/prediction.component.ts
+++ b/src/app/prediction/prediction.component.ts
@@ -3,15 +3,10 @@ import {ChartOptions} from 'chart.js';
import {ApiService} from '../services/api.service';
import {animate, style, transition, trigger} from '@angular/animations';
import cloneDeep from 'lodash/cloneDeep';
+import omit from 'lodash/omit';
import {DataService} from '../services/data.service';
import {ModelItemModel} from '../models/model-item.model';
-import {HttpClient} from '@angular/common/http';
-interface PredictionResult {
- meanPrediction: string;
- std: string;
- predictions: string[];
-}
@Component({
selector: 'app-prediction',
@@ -34,7 +29,7 @@ interface PredictionResult {
})
export class PredictionComponent implements OnInit {
- result: PredictionResult;
+ result: {predictions: string[], mean: string};
loading = false;
activeGroup: ModelItemModel = new ModelItemModel();
activeModelIndex = 0;
@@ -104,9 +99,16 @@ export class PredictionComponent implements OnInit {
loadPrediction() {
this.loading = true;
- console.log(this.activeModelIndex);
- this.api.post(this.activeGroup.models[this.activeModelIndex].url, this.flattenedSpectra, data => {
- this.result = data;
+ this.api.post(this.activeGroup.models[this.activeModelIndex].url, this.flattenedSpectra, data => {
+ this.result = {
+ 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(', ')
+ };
+ console.log(this.result);
this.loading = false;
});
}
@@ -115,4 +117,8 @@ export class PredictionComponent implements OnInit {
this.activeGroup = this.d.arr.modelGroups[index];
this.result = undefined;
}
+
+ clip(str) { // clip spaces at start and end
+ return str.replace(/^\s*(.*?)\s*$/, '$1');
+ }
}
diff --git a/src/app/sample/sample.component.html b/src/app/sample/sample.component.html
index 3448b5b..98a6b8d 100644
--- a/src/app/sample/sample.component.html
+++ b/src/app/sample/sample.component.html
@@ -238,7 +238,7 @@
[(ngModel)]="measurement.measurement_template"
(ngModelChange)="clearMeasurement(gIndex, mIndex)">
- {{d.id.measurementTemplates[measurement.measurement_template].name}} - current
+ {{d.id.measurementTemplates[measurement.measurement_template].name}} - old
{{m.name}}
@@ -330,7 +330,7 @@
1 ? 's' : '')"
cancelBtnLabel="Cancel">
- Do you really want to delete {{samples.length > 1 ? 'these samples' : 'this sample'}}?
+ Do you really want to delete {{(samples.length > 1 ? 'samples ' : 'sample ') + sampleNames()}}?
diff --git a/src/app/sample/sample.component.ts b/src/app/sample/sample.component.ts
index 9fa4ba0..554620f 100644
--- a/src/app/sample/sample.component.ts
+++ b/src/app/sample/sample.component.ts
@@ -613,6 +613,10 @@ export class SampleComponent implements OnInit, AfterContentChecked {
return this.sampleReferenceList.bind(this);
}
+ sampleNames() {
+ return this.samples.map(e => e.number).join(', ');
+ }
+
uniqueCfValues(index) { // returns all names until index for unique check
return this.customFields ? this.customFields.slice(0, index).map(e => e[0]) : [];
}