From 093c0d2eeefa6e1a55524727d301753412486284 Mon Sep 17 00:00:00 2001 From: Danijel Andjelkovic Date: Wed, 6 Apr 2022 21:06:06 +0200 Subject: Add model stranica zamenjena sa eksperiment stranicom. --- .../src/app/experiment/experiment.component.ts | 105 ++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) (limited to 'frontend/src/app/experiment/experiment.component.ts') diff --git a/frontend/src/app/experiment/experiment.component.ts b/frontend/src/app/experiment/experiment.component.ts index 16de7351..2309dcd7 100644 --- a/frontend/src/app/experiment/experiment.component.ts +++ b/frontend/src/app/experiment/experiment.component.ts @@ -1,4 +1,9 @@ import { Component, OnInit } from '@angular/core'; +import Experiment, { NullValReplacer, NullValueOptions, ReplaceWith } from '../_data/Experiment'; +import Model from '../_data/Model'; +import Dataset from '../_data/Dataset'; +import { ModelsService } from '../_services/models.service'; +import Shared from '../Shared'; @Component({ selector: 'app-experiment', @@ -7,9 +12,107 @@ import { Component, OnInit } from '@angular/core'; }) export class ExperimentComponent implements OnInit { - constructor() { } + experiment: Experiment = new Experiment(); + selectedModel?: Model; + selectedDataset?: Dataset; + trainingResult: any; // any za sad, promeni kasnije + + NullValueOptions = NullValueOptions; + ReplaceWith = ReplaceWith; + Object = Object; + + selectedOutputColumnVal: string = ''; + + constructor(private models: ModelsService) { } ngOnInit(): void { } + getInputById(id: string): HTMLInputElement { + return document.getElementById(id) as HTMLInputElement; + } + + arrayColumn = (arr: any[][], n: number) => [...this.dropEmptyString(new Set(arr.map(x => x[n])))]; + + dropEmptyString(set: Set): Set { + if (set.has("")) + set.delete(""); + if (set.has(null)) + set.delete(null); + if (set.has(undefined)) + set.delete(undefined); + return set; + } + + emptyFillTextInput(colName: string) { + (document.getElementById("fillText_" + colName)).value = ""; + } + + checkFillColRadio(colName: string) { + (document.getElementById("fillCol_" + colName)).checked = true; + } + + replace(event: Event) { + let option = (event.target).value; + // TODO + } + + getNullValuesReplacersArray()/*: NullValReplacer[]*/ { + let array: NullValReplacer[] = []; + + // TODO ispravi + /*if (this.datasetFile) { + + if (this.newModel.nullValues == NullValueOptions.Replace) { + + for (let i = 0; i < this.datasetFile[0].length; i++) { + let column = this.datasetFile[0][i]; + + if (this.calculateSumOfNullValuesInCol(column) > 0) { //ako kolona nema null vrednosti, ne dodajemo je u niz + if ((document.getElementById("delCol_" + column)).checked) { + array.push({ + column: column, + option: NullValueOptions.DeleteColumns, + value: "" + }); + } + else if ((document.getElementById("delRows_" + column)).checked) { + array.push({ + column: column, + option: NullValueOptions.DeleteRows, + value: "" + }); + } + else if (((document.getElementById("fillCol_" + column)).checked)) { + array.push({ + column: column, + option: NullValueOptions.Replace, + value: (document.getElementById("fillText_" + column)).value + }); + } + } + } + } + } + //console.log(array); + return array;*/ + } + + trainModel() { + this.trainingResult = undefined; + console.log('Training model...', this.selectedModel); + if (!this.selectedDataset) { + Shared.openDialog('Greška', 'Izvor podataka nije izabran!'); + return; + } + // TODO proveri nullValues + if (!this.selectedModel) { + Shared.openDialog('Greška', 'Model nije izabran!'); + return; + } + this.models.trainModel(this.selectedModel).subscribe((response: any) => { + console.log('Train model complete!', response); + this.trainingResult = response; + }); + } } -- cgit v1.2.3