From 39fc1f0cc9871b4436b839acb6ce4260e6c33931 Mon Sep 17 00:00:00 2001 From: TAMARA JERINIC Date: Wed, 30 Mar 2022 23:09:01 +0200 Subject: Omogućeno je sortiranje padajuće liste za izbor funkcije gubitka u zavisnosti od tipa problema. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/app/_data/Model.ts | 60 +++++++++++++++++++--- .../app/_pages/add-model/add-model.component.html | 56 ++++++++++++++++---- .../app/_pages/add-model/add-model.component.ts | 28 +++++++++- frontend/src/app/app.module.ts | 1 - 4 files changed, 127 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/_data/Model.ts b/frontend/src/app/_data/Model.ts index dd3cb760..ff9f8329 100644 --- a/frontend/src/app/_data/Model.ts +++ b/frontend/src/app/_data/Model.ts @@ -1,3 +1,5 @@ +import { NgIf } from "@angular/common"; + export default class Model { _id: string = ''; constructor( @@ -45,6 +47,7 @@ export enum ProblemType { export enum Encoding { Label = 'label', OneHot = 'one hot', + /* BackwardDifference = 'backward difference', BaseN = 'baseN', Binary = 'binary', @@ -62,34 +65,77 @@ export enum Encoding { Target = 'target', WOE = 'woe', Quantile = 'quantile' + */ } export enum ActivationFunction { // linear Binary_Step = 'binaryStep', - Linear = 'linear', // non-linear - Relu = 'relu', Leaky_Relu = 'leakyRelu', Parameterised_Relu = 'parameterisedRelu', Exponential_Linear_Unit = 'exponentialLinearUnit', Swish = 'swish', - Sigmoid = 'sigmoid', - Tanh = 'tanh', - Softmax = 'softmax' -} + //hiddenLayers + Relu='relu', + Sigmoid='sigmoid', + Tanh='tanh', + + //outputLayer + Linear = 'linear', + //Sigmoid='sigmoid', + Softmax='softmax', +} +/* +export enum ActivationFunctionHiddenLayer +{ + Relu='relu', + Sigmoid='sigmoid', + Tanh='tanh' +} +export enum ActivationFunctionOutputLayer +{ + Linear = 'linear', + Sigmoid='sigmoid', + Softmax='softmax' +} +*/ export enum LossFunction { // binary classification loss functions BinaryCrossEntropy = 'binary_crossentropy', + SquaredHingeLoss='squared_hinge_loss', HingeLoss = 'hinge_loss', // multi-class classiication loss functions CategoricalCrossEntropy = 'categorical_crossentropy', + SparseCategoricalCrossEntropy='sparse_categorical_crosentropy', KLDivergence = 'kullback_leibler_divergence', + // regression loss functions + + MeanAbsoluteError = 'mean_absolute_error', MeanSquaredError = 'mean_squared_error', + MeanSquaredLogarithmicError='mean_squared_logarithmic_error', + HuberLoss = 'Huber' + +} +export enum LossFunctionRegression +{ MeanAbsoluteError = 'mean_absolute_error', - HuberLoss = 'Huber', + MeanSquaredError = 'mean_squared_error', + MeanSquaredLogarithmicError='mean_squared_logarithmic_error', +} +export enum LossFunctionBinaryClassification +{ + BinaryCrossEntropy = 'binary_crossentropy', + SquaredHingeLoss='squared_hinge_loss', + HingeLoss = 'hinge_loss', +} +export enum LossFunctionMultiClassification +{ + CategoricalCrossEntropy = 'categorical_crossentropy', + SparseCategoricalCrossEntropy='sparse_categorical_crosentropy', + KLDivergence = 'kullback_leibler_divergence', } export enum Optimizer { diff --git a/frontend/src/app/_pages/add-model/add-model.component.html b/frontend/src/app/_pages/add-model/add-model.component.html index 3516805b..d1f15ffe 100644 --- a/frontend/src/app/_pages/add-model/add-model.component.html +++ b/frontend/src/app/_pages/add-model/add-model.component.html @@ -195,6 +195,7 @@

Parametri treniranja:

+
@@ -203,7 +204,9 @@
-
+
@@ -272,7 +276,7 @@
- +
@@ -283,7 +287,7 @@
-
+
@@ -341,12 +347,42 @@ [(ngModel)]="tempTestSetDistribution" [disabled]="!newModel.randomTestSet">
+
+ trening + + + test +
+ +

Aktivacione funkcije

+ +
+
+
+ +
+
+
+ +
+
+
+
-
+
-
@@ -361,13 +397,15 @@
-
+ + +
diff --git a/frontend/src/app/_pages/add-model/add-model.component.ts b/frontend/src/app/_pages/add-model/add-model.component.ts index b12ff825..ead9049b 100644 --- a/frontend/src/app/_pages/add-model/add-model.component.ts +++ b/frontend/src/app/_pages/add-model/add-model.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, ViewChild } from '@angular/core'; -import Model, { NullValReplacer, ReplaceWith } from 'src/app/_data/Model'; +import Model, { LossFunctionBinaryClassification, LossFunctionMultiClassification, LossFunctionRegression, NullValReplacer, ReplaceWith } from 'src/app/_data/Model'; import { ProblemType, Encoding, ActivationFunction, LossFunction, Optimizer, NullValueOptions } from 'src/app/_data/Model'; import { DatasetLoadComponent } from 'src/app/_elements/dataset-load/dataset-load.component'; import { ModelsService } from 'src/app/_services/models.service'; @@ -26,7 +26,9 @@ export class AddModelComponent implements OnInit { ProblemType = ProblemType; Encoding = Encoding; ActivationFunction = ActivationFunction; + activationFunction:any=ActivationFunction LossFunction = LossFunction; + lossFunction : any = LossFunction; Optimizer = Optimizer; NullValueOptions = NullValueOptions; ReplaceWith = ReplaceWith; @@ -50,6 +52,9 @@ export class AddModelComponent implements OnInit { //accepted: Boolean; term: string = ""; + selectedProblemType:string=''; + + constructor(private models: ModelsService, private datasets: DatasetsService, private csv: CsvParseService) { this.newModel = new Model(); @@ -62,6 +67,7 @@ export class AddModelComponent implements OnInit { (document.getElementById("btnMyDataset")).focus(); } + viewMyDatasetsForm() { this.showMyDatasets = true; this.resetSelectedDataset(); @@ -466,4 +472,24 @@ export class AddModelComponent implements OnInit { } arrayColumn = (arr: any[][], n: number) => [...new Set(arr.map(x => x[n]))]; + + problemtype:string=''; + + filterOptions(){ + switch(this.problemtype){ + case 'regresioni': + this.lossFunction=LossFunctionRegression; + break; + case 'binarni-klasifikacioni': + this.lossFunction=LossFunctionBinaryClassification; + break; + case 'multi-klasifikacioni': + this.lossFunction=LossFunctionMultiClassification; + break; + default: + break; + } + } + + } diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 4efab17e..d514d1f5 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -39,7 +39,6 @@ import { FilterDatasetsComponent } from './_pages/filter-datasets/filter-dataset import { ReactiveBackgroundComponent } from './_elements/reactive-background/reactive-background.component'; import { ItemModelComponent } from './_elements/item-model/item-model.component'; import { AnnvisualComponent } from './_elements/annvisual/annvisual.component'; - @NgModule({ declarations: [ AppComponent, -- cgit v1.2.3