From 0010400ed39a13dcdad3890a0b71841fe1408964 Mon Sep 17 00:00:00 2001 From: Ognjen Cirkovic Date: Wed, 30 Mar 2022 16:51:15 +0200 Subject: JwtToken servis pretvoren u dependency injection. U svim klasama dodato da se koristi jwtToken interface. Dodato da se u jwt tokena sada nalazi i id korisnika --- backend/api/api/Controllers/DatasetController.cs | 6 +++--- backend/api/api/Controllers/FileController.cs | 6 +++--- backend/api/api/Controllers/ModelController.cs | 6 +++--- backend/api/api/Controllers/PredictorController.cs | 6 +++--- backend/api/api/Controllers/UserController.cs | 6 +++--- backend/api/api/Models/IJwtToken.cs | 12 ++++++++++++ backend/api/api/Models/JwtToken.cs | 19 +++++++++++++------ backend/api/api/Program.cs | 2 ++ backend/api/api/Services/AuthService.cs | 6 +++--- backend/api/api/Services/IUserService.cs | 2 ++ backend/api/api/Services/UserService.cs | 8 ++++++++ 11 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 backend/api/api/Models/IJwtToken.cs diff --git a/backend/api/api/Controllers/DatasetController.cs b/backend/api/api/Controllers/DatasetController.cs index d9803744..8a622138 100644 --- a/backend/api/api/Controllers/DatasetController.cs +++ b/backend/api/api/Controllers/DatasetController.cs @@ -14,12 +14,12 @@ namespace api.Controllers public class DatasetController : ControllerBase { private readonly IDatasetService _datasetService; - private JwtToken jwtToken; + private IJwtToken jwtToken; - public DatasetController(IDatasetService datasetService, IConfiguration configuration) + public DatasetController(IDatasetService datasetService, IConfiguration configuration,IJwtToken Token) { _datasetService = datasetService; - jwtToken = new JwtToken(configuration); + jwtToken = Token; } // GET: api//mydatasets diff --git a/backend/api/api/Controllers/FileController.cs b/backend/api/api/Controllers/FileController.cs index a6bab373..89b4e473 100644 --- a/backend/api/api/Controllers/FileController.cs +++ b/backend/api/api/Controllers/FileController.cs @@ -12,12 +12,12 @@ namespace api.Controllers { private string[] permittedExtensions = { ".csv" }; private readonly IConfiguration _configuration; - private JwtToken _token; + private IJwtToken _token; private IFileService _fileservice; - public FileController(IConfiguration configuration,IFileService fileService) + public FileController(IConfiguration configuration,IFileService fileService,IJwtToken token) { _configuration = configuration; - _token = new JwtToken(configuration); + _token = token; _fileservice = fileService; } diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs index 355eb9f4..0be7894e 100644 --- a/backend/api/api/Controllers/ModelController.cs +++ b/backend/api/api/Controllers/ModelController.cs @@ -17,16 +17,16 @@ namespace api.Controllers private readonly IDatasetService _datasetService; private readonly IFileService _fileService; private readonly IModelService _modelService; - private JwtToken jwtToken; + private IJwtToken jwtToken; - public ModelController(IMlConnectionService mlService, IModelService modelService, IDatasetService datasetService, IFileService fileService, IConfiguration configuration) + public ModelController(IMlConnectionService mlService, IModelService modelService, IDatasetService datasetService, IFileService fileService, IConfiguration configuration,IJwtToken token) { _mlService = mlService; _modelService = modelService; _datasetService = datasetService; _fileService = fileService; - jwtToken = new JwtToken(configuration); + jwtToken = token; } [HttpPost("sendModel")] diff --git a/backend/api/api/Controllers/PredictorController.cs b/backend/api/api/Controllers/PredictorController.cs index 63c5d2bf..8f2167c4 100644 --- a/backend/api/api/Controllers/PredictorController.cs +++ b/backend/api/api/Controllers/PredictorController.cs @@ -13,12 +13,12 @@ namespace api.Controllers public class PredictorController : Controller { private readonly IPredictorService _predictorService; - private JwtToken jwtToken; + private IJwtToken jwtToken; - public PredictorController(IPredictorService predictorService, IConfiguration configuration) + public PredictorController(IPredictorService predictorService, IConfiguration configuration, IJwtToken Token) { _predictorService = predictorService; - jwtToken = new JwtToken(configuration); + jwtToken = Token; } // GET: api//mypredictors diff --git a/backend/api/api/Controllers/UserController.cs b/backend/api/api/Controllers/UserController.cs index 741382b8..782a02cf 100644 --- a/backend/api/api/Controllers/UserController.cs +++ b/backend/api/api/Controllers/UserController.cs @@ -15,12 +15,12 @@ namespace api.Controllers public class UserController : ControllerBase { private readonly IUserService userService; - private JwtToken jwtToken; + private IJwtToken jwtToken; - public UserController(IUserService userService, IConfiguration configuration) + public UserController(IUserService userService, IConfiguration configuration,IJwtToken token) { this.userService = userService; - jwtToken = new JwtToken(configuration); + jwtToken = token; } // GET: api/ diff --git a/backend/api/api/Models/IJwtToken.cs b/backend/api/api/Models/IJwtToken.cs new file mode 100644 index 00000000..da71f7ec --- /dev/null +++ b/backend/api/api/Models/IJwtToken.cs @@ -0,0 +1,12 @@ +using api.Models.Users; + +namespace api.Models +{ + public interface IJwtToken + { + string GenGuestToken(); + string GenToken(AuthRequest user); + string RenewToken(string existingToken); + string TokenToUsername(string token); + } +} \ No newline at end of file diff --git a/backend/api/api/Models/JwtToken.cs b/backend/api/api/Models/JwtToken.cs index f262fd23..29f4bafc 100644 --- a/backend/api/api/Models/JwtToken.cs +++ b/backend/api/api/Models/JwtToken.cs @@ -2,27 +2,33 @@ using System.Security.Claims; using System.Text; using api.Models.Users; +using api.Services; using Microsoft.IdentityModel.Tokens; namespace api.Models { - public class JwtToken + public class JwtToken : IJwtToken { private readonly IConfiguration _configuration; + private readonly IUserService _userService; - public JwtToken(IConfiguration configuration) + public JwtToken(IConfiguration configuration, IUserService userService) { _configuration = configuration; + _userService = userService; + } - + public string GenToken(AuthRequest user) { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_configuration.GetSection("AppSettings:JwtToken").Value); + var fullUser = _userService.GetUserByUsername(user.UserName); var tokenDescriptor = new SecurityTokenDescriptor { - Subject = new ClaimsIdentity(new[] { new Claim("name", user.UserName), - new Claim("role", "User")}), + Subject = new ClaimsIdentity(new[] { new Claim("name", fullUser.Username), + new Claim("role", "User"), + new Claim("id",fullUser._id)}), Expires = DateTime.UtcNow.AddMinutes(20), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; @@ -76,7 +82,8 @@ namespace api.Models var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new[] { new Claim("name",""), - new Claim("role", "Guest")}), + new Claim("role", "Guest"), + new Claim("id","")}), Expires = DateTime.UtcNow.AddMinutes(20), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; diff --git a/backend/api/api/Program.cs b/backend/api/api/Program.cs index 5913c2d3..2bb97e45 100644 --- a/backend/api/api/Program.cs +++ b/backend/api/api/Program.cs @@ -1,6 +1,7 @@ using System.Text; using api.Data; using api.Interfaces; +using api.Models; using api.Services; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.Options; @@ -32,6 +33,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); var mlwss = new MLWebSocketService(); diff --git a/backend/api/api/Services/AuthService.cs b/backend/api/api/Services/AuthService.cs index a646cc9d..c7161dee 100644 --- a/backend/api/api/Services/AuthService.cs +++ b/backend/api/api/Services/AuthService.cs @@ -8,13 +8,13 @@ namespace api.Services { public class AuthService : IAuthService { - private JwtToken _jwt; + private IJwtToken _jwt; private readonly IConfiguration _configuration; private readonly IMongoCollection _users; - public AuthService(IConfiguration configuration, IUserStoreDatabaseSettings settings, IMongoClient mongoClient) + public AuthService(IConfiguration configuration, IUserStoreDatabaseSettings settings, IMongoClient mongoClient,IJwtToken jwt) { _configuration = configuration; - _jwt = new JwtToken(_configuration); + _jwt = jwt; var database = mongoClient.GetDatabase(settings.DatabaseName); _users = database.GetCollection(settings.CollectionName); } diff --git a/backend/api/api/Services/IUserService.cs b/backend/api/api/Services/IUserService.cs index e4a23213..d34d410a 100644 --- a/backend/api/api/Services/IUserService.cs +++ b/backend/api/api/Services/IUserService.cs @@ -10,5 +10,7 @@ namespace api.Services User Create(User user); // kreira korisnika bool Update(string username, User user); //apdejtuje korisnika po idu void Delete(string username);//brise korisnika + public User GetUserByUsername(string username);//Uzima jednog korisnika po username-u + public User GetUserById(string id);//Uzima jednog korisnika po id-u } } diff --git a/backend/api/api/Services/UserService.cs b/backend/api/api/Services/UserService.cs index 607bb04b..39b3a8d3 100644 --- a/backend/api/api/Services/UserService.cs +++ b/backend/api/api/Services/UserService.cs @@ -33,6 +33,14 @@ namespace api.Services { return _users.Find(user => true).ToList(); } + public User GetUserByUsername(string username) + { + return _users.Find(user=>user.Username == username).FirstOrDefault(); + } + public User GetUserById(string id) + { + return _users.Find(user => user._id == id).FirstOrDefault(); + } public User GetUserUsername(string username) { return _users.Find(user => user.Username == username).FirstOrDefault(); -- cgit v1.2.3 From 686c049223a62f0a6926e08d8743ef9661200874 Mon Sep 17 00:00:00 2001 From: "DESKTOP-S0O2C44\\ROG" Date: Wed, 30 Mar 2022 17:49:50 +0200 Subject: Sitne izmene oko predict stranice.(Nije zavrsneno) #53 #66 --- backend/api/api/Controllers/ModelController.cs | 12 +++-- backend/api/api/Controllers/PredictorController.cs | 3 +- backend/api/api/Services/IModelService.cs | 1 + backend/api/api/Services/ModelService.cs | 5 ++ .../item-predictor/item-predictor.component.html | 4 +- .../item-predictor/item-predictor.component.ts | 4 ++ .../src/app/_pages/predict/predict.component.html | 61 +++++++++++++++++++++- .../src/app/_pages/predict/predict.component.ts | 6 ++- 8 files changed, 88 insertions(+), 8 deletions(-) diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs index 0be7894e..d8bc1515 100644 --- a/backend/api/api/Controllers/ModelController.cs +++ b/backend/api/api/Controllers/ModelController.cs @@ -129,8 +129,9 @@ namespace api.Controllers // POST api//add [HttpPost("add")] [Authorize(Roles = "User,Guest")] - public ActionResult Post([FromBody] Model model) + public ActionResult Post([FromBody] Model model)//, bool overwrite) { + bool overwrite = false; //username="" ako je GUEST model.inputNeurons = model.inputColumns.Length; if (_modelService.CheckHyperparameters(model.inputNeurons, model.hiddenLayerNeurons, model.hiddenLayers, model.outputNeurons) == false) @@ -138,11 +139,16 @@ namespace api.Controllers var existingModel = _modelService.GetOneModel(model.username, model.name); - if (existingModel != null) + if (existingModel != null && !overwrite) return NotFound($"Model with name = {model.name} exisits"); else { - _modelService.Create(model); + if (existingModel == null) + _modelService.Create(model); + else + { + _modelService.Replace(model); + } return CreatedAtAction(nameof(Get), new { id = model._id }, model); } diff --git a/backend/api/api/Controllers/PredictorController.cs b/backend/api/api/Controllers/PredictorController.cs index 8f2167c4..98e2695e 100644 --- a/backend/api/api/Controllers/PredictorController.cs +++ b/backend/api/api/Controllers/PredictorController.cs @@ -74,8 +74,7 @@ namespace api.Controllers return _predictorService.SearchPredictors(name, username); } - //SEARCH za predictore (public ili private sa ovim imenom ) - // GET api//search/{name} + // GET api//{name} [HttpGet("{id}")] [Authorize(Roles = "User")] public ActionResult GetPredictor(string id) diff --git a/backend/api/api/Services/IModelService.cs b/backend/api/api/Services/IModelService.cs index 637d09a3..3e70a1c3 100644 --- a/backend/api/api/Services/IModelService.cs +++ b/backend/api/api/Services/IModelService.cs @@ -11,6 +11,7 @@ namespace api.Services List GetLatestModels(string username); //List GetPublicModels(); Model Create(Model model); + Model Replace(Model model); void Update(string username, string name, Model model); void Delete(string username, string name); bool CheckHyperparameters(int inputNeurons, int hiddenLayerNeurons, int hiddenLayers, int outputNeurons); diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs index eae8c78b..c2b4e692 100644 --- a/backend/api/api/Services/ModelService.cs +++ b/backend/api/api/Services/ModelService.cs @@ -20,6 +20,11 @@ namespace api.Services _model.InsertOne(model); return model; } + public Model Replace(Model model) + { + _model.ReplaceOne(m => m._id == model._id, model); + return model; + } public void Delete(string username, string name) { diff --git a/frontend/src/app/_elements/item-predictor/item-predictor.component.html b/frontend/src/app/_elements/item-predictor/item-predictor.component.html index b4690154..7ae26fd3 100644 --- a/frontend/src/app/_elements/item-predictor/item-predictor.component.html +++ b/frontend/src/app/_elements/item-predictor/item-predictor.component.html @@ -19,6 +19,8 @@ \ No newline at end of file diff --git a/frontend/src/app/_elements/item-predictor/item-predictor.component.ts b/frontend/src/app/_elements/item-predictor/item-predictor.component.ts index cc782f45..d864480a 100644 --- a/frontend/src/app/_elements/item-predictor/item-predictor.component.ts +++ b/frontend/src/app/_elements/item-predictor/item-predictor.component.ts @@ -15,4 +15,8 @@ export class ItemPredictorComponent implements OnInit { ngOnInit(): void { } + openPredictor() { + console.log("iskoristi") + } + } diff --git a/frontend/src/app/_pages/predict/predict.component.html b/frontend/src/app/_pages/predict/predict.component.html index 74a83b71..67d047b7 100644 --- a/frontend/src/app/_pages/predict/predict.component.html +++ b/frontend/src/app/_pages/predict/predict.component.html @@ -1 +1,60 @@ -

predict works!

+ +
+
+
+ + + +
+ +
+ +

Izabrani prediktor:

+
+ + +
+
+ +
+ +
+
+
+ + + +
+ + +
+
+ + +
+
+    + +
+ + + +
+
\ No newline at end of file diff --git a/frontend/src/app/_pages/predict/predict.component.ts b/frontend/src/app/_pages/predict/predict.component.ts index 0e313c65..d5cb22bd 100644 --- a/frontend/src/app/_pages/predict/predict.component.ts +++ b/frontend/src/app/_pages/predict/predict.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import Predictor from 'src/app/_data/Predictor'; @Component({ selector: 'app-predict', @@ -7,7 +8,10 @@ import { Component, OnInit } from '@angular/core'; }) export class PredictComponent implements OnInit { - constructor() { } + predictor:Predictor; + constructor() { + this.predictor = new Predictor(); + } ngOnInit(): void { } -- cgit v1.2.3 From 364d58591e949f50c42c6f686a3720cd959bbefa Mon Sep 17 00:00:00 2001 From: Nevena Bojovic Date: Wed, 30 Mar 2022 19:44:49 +0200 Subject: Linearni problem. --- backend/microservice/api/ml_service.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/microservice/api/ml_service.py b/backend/microservice/api/ml_service.py index efd24fdc..68595a89 100644 --- a/backend/microservice/api/ml_service.py +++ b/backend/microservice/api/ml_service.py @@ -34,6 +34,7 @@ class TrainingResult: tpr: float def train(dataset, params, callback): + problem_type = params["type"] data = pd.DataFrame() for col in params["inputColumns"]: data[col]=dataset[col] @@ -123,13 +124,17 @@ def train(dataset, params, callback): # # Test # - y_pred=classifier.predict(x_test) - y_pred=(y_pred>=0.5).astype('int') - #y_pred=(y_pred * 100).astype('int') - y_pred=y_pred.flatten() - result=pd.DataFrame({"Actual":y_test,"Predicted":y_pred}) - model_name = params['_id'] - classifier.save("temp/"+model_name, save_format='h5') + if(problem_type == "regresioni"): + classifier.evaluate(x_test, y_test) + classifier.save("temp/"+model_name, save_format='h5') + elif(problem_type == "binarni-klasifikacioni"): + y_pred=classifier.predict(x_test) + y_pred=(y_pred>=0.5).astype('int') + #y_pred=(y_pred * 100).astype('int') + y_pred=y_pred.flatten() + result=pd.DataFrame({"Actual":y_test,"Predicted":y_pred}) + model_name = params['_id'] + classifier.save("temp/"+model_name, save_format='h5') # # Metrike # -- cgit v1.2.3 From 158f1207206ccbb7955a17e0918c68d10216b3ec Mon Sep 17 00:00:00 2001 From: Nevena Bojovic Date: Wed, 30 Mar 2022 19:54:09 +0200 Subject: Prosiren scatter. --- frontend/src/app/scatterchart/scatterchart.component.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/scatterchart/scatterchart.component.ts b/frontend/src/app/scatterchart/scatterchart.component.ts index 1da88fe7..9dfef4c3 100644 --- a/frontend/src/app/scatterchart/scatterchart.component.ts +++ b/frontend/src/app/scatterchart/scatterchart.component.ts @@ -16,7 +16,14 @@ export class ScatterchartComponent implements OnInit { data: { datasets: [{ label: 'Scatter Example:', - data: [{x: 1, y: 11}, {x:2, y:12}, {x: 1, y: 2}, {x: 2, y: 4}, {x: 3, y: 8},{x: 4, y: 16}, {x: 1, y: 3}, {x: 3, y: 4}, {x: 4, y: 6}, {x: 6, y: 9}], + data: [{x: 1, y: 11}, {x:2, y:12}, {x: 1, y: 2}, {x: 2, y: 4}, {x: 3, y: 8},{x: 4, y: 16}, {x: 1, y: 3}, {x: 3, y: 4}, {x: 4, y: 6}, {x: 6, y: 9}, + {x: 11, y: 9}, + {x: 12, y: 8}, + {x: 13, y: 6}, + {x: 14, y: 0}, + {x: 15, y: 5}, + {x: 16, y: 3}, + {x: 17, y: 2}], backgroundColor: 'rgb(255, 99, 132)' }] }, -- cgit v1.2.3 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