diff options
author | Nevena Bojovic <nenabojov@gmail.com> | 2022-04-19 21:06:28 +0200 |
---|---|---|
committer | Nevena Bojovic <nenabojov@gmail.com> | 2022-04-19 21:06:28 +0200 |
commit | ba8a9752a72a07840e12320dbb448f1391fdccad (patch) | |
tree | cd9a52c3f02dfbb2c9a24a90ccfea679c44472b3 | |
parent | 5d5aef8ad980934b98c48391bf53fb41e2481b5d (diff) | |
parent | 3ee39c4a5c0dfccc4fcb429762e5a7cc026da4a0 (diff) |
Merge branch 'dev' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into dev
# Conflicts:
# frontend/src/app/app.module.ts
23 files changed, 556 insertions, 180 deletions
diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs index ce1759ca..fb30a7a2 100644 --- a/backend/api/api/Controllers/ModelController.cs +++ b/backend/api/api/Controllers/ModelController.cs @@ -109,6 +109,24 @@ namespace api.Controllers return _modelService.GetMyModels(uploaderId); } + // GET: api/<ModelController>/mymodels + [HttpGet("mymodelsbytype/{problemtype}")] + [Authorize(Roles = "User")] + public ActionResult<List<Model>> GetMyModelsByType(string problemType) + { + string uploaderId = getUserId(); + + if (uploaderId == null) + return BadRequest(); + + List<Model> modeli = _modelService.GetMyModelsByType(uploaderId, problemType); + + if (modeli == null) + return NoContent(); + else + return modeli; + } + // vraca svoj model prema nekom imenu // GET api/<ModelController>/{name} [HttpGet("{name}")] diff --git a/backend/api/api/Models/ColumnEncoding.cs b/backend/api/api/Models/ColumnEncoding.cs index b5f61070..2a2fce8b 100644 --- a/backend/api/api/Models/ColumnEncoding.cs +++ b/backend/api/api/Models/ColumnEncoding.cs @@ -2,6 +2,12 @@ { public class ColumnEncoding { + public ColumnEncoding(string columnName, string encoding) + { + this.columnName = columnName; + this.encoding = encoding; + } + public string columnName { get; set; } public string encoding { get; set; } } diff --git a/backend/api/api/Models/ColumnInfo.cs b/backend/api/api/Models/ColumnInfo.cs index 99418732..04450fef 100644 --- a/backend/api/api/Models/ColumnInfo.cs +++ b/backend/api/api/Models/ColumnInfo.cs @@ -2,6 +2,20 @@ { public class ColumnInfo { + public ColumnInfo() { } + + public ColumnInfo(string columnName, bool isNumber, int numNulls, float mean, float min, float max, float median, string[] uniqueValues) + { + this.columnName = columnName; + this.isNumber = isNumber; + this.numNulls = numNulls; + this.mean = mean; + this.min = min; + this.max = max; + this.median = median; + this.uniqueValues = uniqueValues; + } + public string columnName { get; set; } public bool isNumber { get; set; } public int numNulls { get; set; } diff --git a/backend/api/api/Models/Experiment.cs b/backend/api/api/Models/Experiment.cs index 6f665c52..f7bec083 100644 --- a/backend/api/api/Models/Experiment.cs +++ b/backend/api/api/Models/Experiment.cs @@ -10,6 +10,7 @@ namespace api.Models public string _id { get; set; } public string name { get; set; } public string description { get; set; } + public string type { get; set; } public List<string> ModelIds { get; set; } public string datasetId { get; set; } public string uploaderId { get; set; } diff --git a/backend/api/api/Models/Predictor.cs b/backend/api/api/Models/Predictor.cs index 8608d766..342c5b5d 100644 --- a/backend/api/api/Models/Predictor.cs +++ b/backend/api/api/Models/Predictor.cs @@ -21,9 +21,8 @@ namespace api.Models public string modelId { get; set; } public string h5FileId { get; set; } public Metric[] metrics { get; set; } - - } + public class Metric { string Name { get; set; } @@ -32,12 +31,15 @@ namespace api.Models } } -/* +/** +* Paste one or more documents here + { - "_id" : "", - "username" : "ivan123", - "name" : "Neki prediktor", - "description" : "Neki opis prediktora koji je unet tamo", + "_id": { + "$oid": "625dc348b7856ace8a6f8702" + + }, + "uploaderId" : "6242ea59486c664208d4255c", "inputs": ["proba", "proba2", "proba3" @@ -46,6 +48,8 @@ namespace api.Models "isPublic" : true, "accessibleByLink" : true, "dateCreated" : "2022-04-11T20:33:26.937+00:00", - "experimentId" : "Neki id eksperimenta" -} -*/
\ No newline at end of file + "experimentId" : "Neki id eksperimenta", + "modelId" : "Neki id eksperimenta", + "h5FileId" : "Neki id eksperimenta", + "metrics" : [{ }] +}*/
\ No newline at end of file diff --git a/backend/api/api/Services/FillAnEmptyDb.cs b/backend/api/api/Services/FillAnEmptyDb.cs index 33c1ada6..6d5683bd 100644 --- a/backend/api/api/Services/FillAnEmptyDb.cs +++ b/backend/api/api/Services/FillAnEmptyDb.cs @@ -1,5 +1,6 @@ using api.Interfaces; using api.Models; +using Microsoft.AspNetCore.SignalR; using MongoDB.Driver; namespace api.Services @@ -32,10 +33,10 @@ namespace api.Services if (_fileService.CheckDb()) { - /* + FileModel file = new FileModel(); - string folderName = "UploadedFiles/Igrannonica"; + string folderName = "UploadedFiles"; var folderPath = Path.Combine(Directory.GetCurrentDirectory(), folderName, "Igrannonica"); var fullPath = Path.Combine(folderPath, "titanic.csv"); @@ -51,9 +52,9 @@ namespace api.Services Dataset dataset = new Dataset(); dataset._id = ""; - dataset.username = "Igrannonica"; + dataset.uploaderId = "Igrannonica"; dataset.name = "Titanik dataset"; - dataset.description = "Opis dataseta 1"; + dataset.description = "Titanik dataset"; dataset.header = new string[] { "PassengerId", "Survived", "Pclass", "Name", "Sex", "Age", "SibSp", "Parch", "Ticket", "Fare", "Cabin", "Embarked" }; dataset.fileId = _fileService.GetFileId(fullPath); dataset.extension = ".csv"; @@ -64,9 +65,25 @@ namespace api.Services dataset.delimiter = ""; dataset.hasHeader = true; dataset.columnInfo = new ColumnInfo[] { }; + dataset.columnInfo = new[] + { + new ColumnInfo( "PassengerId", true, 0, 446, 1, 891, 446, new string[]{ }), + new ColumnInfo( "Survived", true, 0, 0.38383838534355164f, 0, 1, 0, new string[]{ }), + new ColumnInfo( "Pclass", true, 0, 2.3086419105529785f, 1, 3, 3, new string[]{ }), + new ColumnInfo( "Name", false, 0, 0, 0, 0, 0, new string[]{"Braund, Mr. Owen Harris", "Boulos, Mr. Hanna", "Frolicher-Stehli, Mr. Maxmillian", "Gilinski, Mr. Eliezer", "Murdlin, Mr. Joseph", "Rintamaki, Mr. Matti", "Stephenson, Mrs. Walter Bertram (Martha Eustis)", "Elsbury, Mr. William James", "Bourke, Miss. Mary", "Chapman, Mr. John Henry"}), + new ColumnInfo( "Sex", false, 0, 0, 0, 0, 0, new string[]{ "male", "female" }), + new ColumnInfo( "Age", true, 177, 29.69911766052246f, 0.41999998688697815f, 80, 28, new string[]{ }), + new ColumnInfo( "SibSp", true, 0, 0.523007869720459f, 0, 8, 0, new string[]{ }), + new ColumnInfo( "Parch", true, 0, 0.3815937042236328f, 0, 6, 0, new string[]{ }), + new ColumnInfo( "Ticket", false, 0, 0, 0, 0, 0, new string[]{ "347082", "CA. 2343", "1601", "3101295", "CA 2144", "347088", "S.O.C. 14879", "382652", "LINE", "PC 17757" }), + new ColumnInfo( "Fare", true, 0, 32.20420837402344f, 0, 512.3292236328125f, 14.45419979095459f, new string[]{ }), + new ColumnInfo( "Cabin", false, 687, 0, 0, 0, 0, new string[]{ "B96 B98", "G6", "C23 C25 C27", "C22 C26", "F33", "F2", "E101", "D", "C78", "C93" }), + new ColumnInfo( "Embarked", false, 2, 0.3815937042236328f, 0, 6, 0, new string[]{ "S", "C", "Q" }), + }; + dataset.rowCount = 891; dataset.nullCols = 3; dataset.nullRows = 708; - dataset.isPreProcess = false; + dataset.isPreProcess = true; _datasetService.Create(dataset); @@ -74,25 +91,22 @@ namespace api.Services Model model = new Model(); model._id = ""; - model.username = "Igrannonica"; - model.name = "Titanik model"; - model.description = "Opis modela 1"; + model.uploaderId = "Igrannonica"; + model.name = "Model Titanik"; + model.description = "Model Titanik"; model.dateCreated = DateTime.Now; model.lastUpdated = DateTime.Now; - model.experimentId = ""; - model.type = "regresioni"; - model.encoding = "label"; + model.type = "binarni-klasifikacioni"; model.optimizer = "Adam"; model.lossFunction = "mean_squared_error"; - model.hiddenLayerNeurons = 1; - model.hiddenLayers = 1; - model.batchSize = 5; + model.hiddenLayerNeurons = 3; + model.hiddenLayers = 5; + model.batchSize = 8; model.outputNeurons = 0; - model.hiddenLayerActivationFunctions = new string[] { "sigmoid" }; + model.hiddenLayerActivationFunctions = new string[] { "relu", "relu", "relu", "relu", "relu" }; model.outputLayerActivationFunction = "sigmoid"; model.metrics = new string[] { }; model.epochs = 5; - model.isTrained = false; _modelService.Create(model); @@ -100,18 +114,35 @@ namespace api.Services Experiment experiment = new Experiment(); experiment._id = ""; + experiment.name = "Eksperiment Titanik"; + experiment.description = "Binarno klasifikacioni, label"; + experiment.ModelIds = new string[] { }.ToList(); experiment.datasetId = _datasetService.GetDatasetId(dataset.fileId); experiment.uploaderId = "Igrannonica"; - experiment.inputColumns = new string[] { }; - experiment.outputColumn = ""; - experiment.randomOrder = false; - experiment.randomTestSet = false; - experiment.randomTestSetDistribution = 0; - experiment.nullValues = ""; + experiment.inputColumns = new string[] { "Embarked" }; + experiment.outputColumn = "Survived"; + experiment.randomOrder = true; + experiment.randomTestSet = true; + experiment.randomTestSetDistribution = 0.30000001192092896f; + experiment.nullValues = "delete_rows"; experiment.nullValuesReplacers = new NullValues[] { }; + experiment.encodings = new[] + { + new ColumnEncoding( "Survived", "label" ), + new ColumnEncoding("Embarked", "label" ) + }; _experimentService.Create(experiment); + var experiment1 = _experimentService.Get(experiment._id); + var dataset1 = _datasetService.GetOneDataset(experiment.datasetId); + var filepath1 = _fileService.GetFilePath(dataset.fileId, "Igrannonica"); + var model1 = _modelService.GetOneModel(model._id); + + + //_mlService.TrainModel(model1, experiment1, filepath1, dataset1, "Igrannonica"); + + /* Predictor predictor = new Predictor(); @@ -127,7 +158,7 @@ namespace api.Services predictor.experimentId = "0"; //izmeni experiment id - _predictorService.Create(predictor); + _predictorService.Create(predictor);*/ //-------------------------------------------------------------------- @@ -142,14 +173,13 @@ namespace api.Services _fileService.Create(file); - + dataset = new Dataset(); dataset._id = ""; - dataset.username = "Igrannonica"; + dataset.uploaderId = "Igrannonica"; dataset.name = "Diamonds dataset"; - dataset.description = "Opis dataseta 2"; - dataset.header = new string[] { "carat", "cut", "color", "clarity", "depth", "table", "price", "x", "y", "z" }; + dataset.description = "Diamonds dataset"; dataset.fileId = _fileService.GetFileId(fullPath); dataset.extension = ".csv"; dataset.isPublic = true; @@ -157,57 +187,91 @@ namespace api.Services dataset.dateCreated = DateTime.Now; dataset.lastUpdated = DateTime.Now; dataset.delimiter = ""; - dataset.hasHeader = true; - dataset.columnInfo = new ColumnInfo[] { }; + dataset.hasHeader = true; + dataset.columnInfo = new[] + { + new ColumnInfo( "Unnamed: 0", true, 0, 26969.5f, 0, 53939, 26969.5f, new string[]{ }), + new ColumnInfo( "carat", true, 0, 0.7979397773742676f, 0.20000000298023224f, 5.010000228881836f, 0.699999988079071f, new string[]{ }), + new ColumnInfo( "cut", false, 0, 0, 0, 0, 0, new string[]{ "Ideal", "Premium", "Very Good", "Good", "Fair" }), + new ColumnInfo( "color", false, 0, 0, 0, 0, 0, new string[]{"G", "E", "F", "H", "D", "I", "I", "J"}), + new ColumnInfo( "clarity", false, 0, 0, 0, 0, 0, new string[]{ "SI1", "VS2","SI2", "VS1", "VVS2", "VVS1", "IF", "I1" }), + new ColumnInfo( "depth", true, 0, 61.74940490722656f, 43, 79, 61.79999923706055f, new string[]{ }), + new ColumnInfo( "table", true, 0, 57.457183837890625f, 43, 95, 57, new string[]{ }), + new ColumnInfo( "price", true, 0, 3932.7998046875f, 326, 18823, 2401, new string[]{ }), + new ColumnInfo( "x", true, 0, 5.731157302856445f, 0, 10.739999771118164f, 5.699999809265137f, new string[]{ }), + new ColumnInfo( "y", true, 0, 5.73452615737915f, 0, 58.900001525878906f, 5.710000038146973f, new string[]{ }), + new ColumnInfo( "z", true, 0, 3.538733720779419f, 0, 31.799999237060547f, 3.5299999713897705f, new string[]{ }) + }; + dataset.rowCount = 53940; dataset.nullCols = 0; dataset.nullRows = 0; - dataset.isPreProcess = false; + dataset.isPreProcess = true; _datasetService.Create(dataset); - */ - /* + + model = new Model(); model._id = ""; - model.username = "Igrannonica"; - model.name = "Igrannonica model 2"; - model.description = "Opis modela 2"; + model.uploaderId = "Igrannonica"; + model.name = "Diamonds model"; + model.description = "Diamonds model"; model.dateCreated = DateTime.Now; model.lastUpdated = DateTime.Now; - model.experimentId = ""; - model.type = ""; - model.encoding = ""; - model.optimizer = ""; - model.lossFunction = ""; - model.hiddenLayerNeurons = 0; - model.hiddenLayers = 0; - model.batchSize = 0; + model.type = "regresioni"; + model.optimizer = "Adam"; + model.lossFunction = "mean_absolute_error"; + model.hiddenLayerNeurons = 2; + model.hiddenLayers = 4; + model.batchSize = 5; model.outputNeurons = 0; - model.hiddenLayerActivationFunctions = new string[] { "sigmoid" }; - model.outputLayerActivationFunction = ""; + model.hiddenLayerActivationFunctions = new string[] { "relu", "relu", "relu", "relu" }; + model.outputLayerActivationFunction = "relu"; model.metrics = new string[] { }; - model.epochs = 0; - model.isTrained = false; + model.epochs = 5; _modelService.Create(model); - + experiment = new Experiment(); experiment._id = ""; + experiment.name = "Diamonds eksperiment"; + experiment.description = "Diamonds eksperiment"; + experiment.ModelIds = new string[] { }.ToList(); experiment.datasetId = _datasetService.GetDatasetId(dataset.fileId); experiment.uploaderId = "Igrannonica"; - experiment.inputColumns = new string[] { }; - experiment.outputColumn = ""; - experiment.randomOrder = false; - experiment.randomTestSet = false; - experiment.randomTestSetDistribution = 0; - experiment.nullValues = ""; - experiment.nullValuesReplacers = new NullValues[] { }; - + experiment.inputColumns = new string[] { "Unnamed: 0", "carat", "cut", "color", "clarity", "depth", "table", "x", "y", "z" }; + experiment.outputColumn = "price"; + experiment.randomOrder = true; + experiment.randomTestSet = true; + experiment.randomTestSetDistribution = 0.30000001192092896f; + experiment.nullValues = "delete_rows"; + experiment.nullValuesReplacers = new NullValues[] { }; + experiment.encodings = new[] + { + new ColumnEncoding( "Unnamed: 0", "label" ), + new ColumnEncoding( "carat", "label" ), + new ColumnEncoding( "cut", "label" ), + new ColumnEncoding( "color", "label" ), + new ColumnEncoding( "clarity", "label" ), + new ColumnEncoding( "depth", "label" ), + new ColumnEncoding( "table", "label" ), + new ColumnEncoding( "price", "label" ), + new ColumnEncoding( "x", "label" ), + new ColumnEncoding( "y", "label" ), + new ColumnEncoding( "z", "label" ) + }; + _experimentService.Create(experiment); + experiment1 = _experimentService.Get(experiment._id); + dataset1 = _datasetService.GetOneDataset(experiment.datasetId); + filepath1 = _fileService.GetFilePath(dataset.fileId, "Igrannonica"); + model1 = _modelService.GetOneModel(model._id); + //_mlService.TrainModel(model1, experiment1, filepath1, dataset1, "Igrannonica"); + /* predictor = new Predictor(); @@ -224,12 +288,12 @@ namespace api.Services //izmeni experiment id _predictorService.Create(predictor); - + */ //-------------------------------------------------------------------- file = new FileModel(); - fullPath = Path.Combine(folderPath, "IMDB-Movie-Data.csv"); + fullPath = Path.Combine(folderPath, "iris.csv"); file._id = ""; file.type = ".csv"; file.uploaderId = "Igrannonica"; @@ -242,10 +306,9 @@ namespace api.Services dataset = new Dataset(); dataset._id = ""; - dataset.username = "Igrannonica"; - dataset.name = "Igrannonica dataset 3"; - dataset.description = "Opis dataseta 3"; - dataset.header = new string[] { "PassengerId", "Survived", "Pclass", "Name", "Sex", "Age", "SibSp", "Parch", "Ticket", "Fare", "Cabin", "Embarked" }; + dataset.uploaderId = "Igrannonica"; + dataset.name = "Iris dataset"; + dataset.description = "Iris dataset"; dataset.fileId = _fileService.GetFileId(fullPath); dataset.extension = ".csv"; dataset.isPublic = true; @@ -254,56 +317,77 @@ namespace api.Services dataset.lastUpdated = DateTime.Now; dataset.delimiter = ""; dataset.hasHeader = true; - dataset.columnInfo = new ColumnInfo[] { }; - dataset.nullCols = 0; + dataset.columnInfo = new[] + { + new ColumnInfo( "sepal_length", true, 0, 5.8433332443237305f, 4.300000190734863f, 7.900000095367432f, 5.800000190734863f, new string[]{ }), + new ColumnInfo( "sepal_width", true, 0, 3.053999900817871f, 2, 4.400000095367432f, 3, new string[]{ }), + new ColumnInfo( "petal_length", true, 0, 3.758666753768921f, 1, 6.900000095367432f, 4.349999904632568f, new string[]{ }), + new ColumnInfo( "petal_width", true, 0, 1.1986666917800903f, 0.10000000149011612f, 2.5f, 1.2999999523162842f, new string[]{}), + new ColumnInfo( "class", false, 0, 0, 0, 0, 0, new string[]{ "Iris-setosa", "Iris-versicolor", "Iris-virginica" }), + }; + dataset.nullCols = 150; dataset.nullRows = 0; - dataset.isPreProcess = false; + dataset.isPreProcess = true; _datasetService.Create(dataset); - + model = new Model(); model._id = ""; - model.username = "Igrannonica"; - model.name = "Igrannonica model 3"; - model.description = "Opis modela 3"; + model.uploaderId = "Igrannonica"; + model.name = "Model Iris"; + model.description = "Model Iris"; model.dateCreated = DateTime.Now; model.lastUpdated = DateTime.Now; - model.experimentId = ""; - model.type = ""; - model.encoding = ""; - model.optimizer = ""; - model.lossFunction = ""; - model.hiddenLayerNeurons = 0; - model.hiddenLayers = 0; - model.batchSize = 0; + model.type = "multi-klasifikacioni"; + model.optimizer = "Adam"; + model.lossFunction = "sparse_categorical_crossentropy"; + model.hiddenLayerNeurons = 3; + model.hiddenLayers = 3; + model.batchSize = 4; model.outputNeurons = 0; - model.hiddenLayerActivationFunctions = new string[] { "sigmoid" }; - model.outputLayerActivationFunction = ""; + model.hiddenLayerActivationFunctions = new string[] { "relu", "relu", "softmax" }; + model.outputLayerActivationFunction = "softmax"; model.metrics = new string[] { }; - model.epochs = 0; - model.isTrained = false; + model.epochs = 1; _modelService.Create(model); - + experiment = new Experiment(); experiment._id = ""; + experiment.name = "Iris eksperiment"; + experiment.description = "Iris eksperiment"; + experiment.ModelIds = new string[] { }.ToList(); experiment.datasetId = _datasetService.GetDatasetId(dataset.fileId); experiment.uploaderId = "Igrannonica"; - experiment.inputColumns = new string[] { }; - experiment.outputColumn = ""; - experiment.randomOrder = false; - experiment.randomTestSet = false; - experiment.randomTestSetDistribution = 0; - experiment.nullValues = ""; - experiment.nullValuesReplacers = new NullValues[] { }; + experiment.inputColumns = new string[] { "sepal_length", "sepal_width", "petal_length", "petal_width" }; + experiment.outputColumn = "class"; + experiment.randomOrder = true; + experiment.randomTestSet = true; + experiment.randomTestSetDistribution = 0.20000000298023224f; + experiment.nullValues = "delete_rows"; + experiment.nullValuesReplacers = new NullValues[] { }; + experiment.encodings = new[] + { + new ColumnEncoding( "sepal_length", "label" ), + new ColumnEncoding("sepal_width", "label" ), + new ColumnEncoding( "petal_length", "label" ), + new ColumnEncoding( "petal_width", "label" ), + new ColumnEncoding( "class", "label" ) + }; _experimentService.Create(experiment); + experiment1 = _experimentService.Get(experiment._id); + dataset1 = _datasetService.GetOneDataset(experiment.datasetId); + filepath1 = _fileService.GetFilePath(dataset.fileId, "Igrannonica"); + model1 = _modelService.GetOneModel(model._id); + //_mlService.TrainModel(model1, experiment1, filepath1, dataset1, "Igrannonica"); + /* predictor = new Predictor(); predictor._id = ""; diff --git a/backend/api/api/Services/IModelService.cs b/backend/api/api/Services/IModelService.cs index bcb82e2d..00299979 100644 --- a/backend/api/api/Services/IModelService.cs +++ b/backend/api/api/Services/IModelService.cs @@ -8,6 +8,7 @@ namespace api.Services Model GetOneModel(string userId, string name); Model GetOneModel(string id); List<Model> GetMyModels(string userId); + List<Model> GetMyModelsByType(string userId, string problemType); List<Model> GetLatestModels(string userId); //List<Model> GetPublicModels(); Model Create(Model model); diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs index d3ff9bf9..c35e5374 100644 --- a/backend/api/api/Services/ModelService.cs +++ b/backend/api/api/Services/ModelService.cs @@ -35,6 +35,10 @@ namespace api.Services { return _model.Find(model => model.uploaderId == userId).ToList(); } + public List<Model> GetMyModelsByType(string userId, string problemType) + { + return _model.Find(model => (model.uploaderId == userId && model.type == problemType)).ToList(); + } public List<Model> GetLatestModels(string userId) { List<Model> list = _model.Find(model => model.uploaderId == userId).ToList(); diff --git a/backend/api/api/UploadedFiles/Igrannonica/iris.csv b/backend/api/api/UploadedFiles/Igrannonica/iris.csv new file mode 100644 index 00000000..0713e5cb --- /dev/null +++ b/backend/api/api/UploadedFiles/Igrannonica/iris.csv @@ -0,0 +1,151 @@ +sepal_length,sepal_width,petal_length,petal_width,class +5.1,3.5,1.4,0.2,Iris-setosa +4.9,3.0,1.4,0.2,Iris-setosa +4.7,3.2,1.3,0.2,Iris-setosa +4.6,3.1,1.5,0.2,Iris-setosa +5.0,3.6,1.4,0.2,Iris-setosa +5.4,3.9,1.7,0.4,Iris-setosa +4.6,3.4,1.4,0.3,Iris-setosa +5.0,3.4,1.5,0.2,Iris-setosa +4.4,2.9,1.4,0.2,Iris-setosa +4.9,3.1,1.5,0.1,Iris-setosa +5.4,3.7,1.5,0.2,Iris-setosa +4.8,3.4,1.6,0.2,Iris-setosa +4.8,3.0,1.4,0.1,Iris-setosa +4.3,3.0,1.1,0.1,Iris-setosa +5.8,4.0,1.2,0.2,Iris-setosa +5.7,4.4,1.5,0.4,Iris-setosa +5.4,3.9,1.3,0.4,Iris-setosa +5.1,3.5,1.4,0.3,Iris-setosa +5.7,3.8,1.7,0.3,Iris-setosa +5.1,3.8,1.5,0.3,Iris-setosa +5.4,3.4,1.7,0.2,Iris-setosa +5.1,3.7,1.5,0.4,Iris-setosa +4.6,3.6,1.0,0.2,Iris-setosa +5.1,3.3,1.7,0.5,Iris-setosa +4.8,3.4,1.9,0.2,Iris-setosa +5.0,3.0,1.6,0.2,Iris-setosa +5.0,3.4,1.6,0.4,Iris-setosa +5.2,3.5,1.5,0.2,Iris-setosa +5.2,3.4,1.4,0.2,Iris-setosa +4.7,3.2,1.6,0.2,Iris-setosa +4.8,3.1,1.6,0.2,Iris-setosa +5.4,3.4,1.5,0.4,Iris-setosa +5.2,4.1,1.5,0.1,Iris-setosa +5.5,4.2,1.4,0.2,Iris-setosa +4.9,3.1,1.5,0.1,Iris-setosa +5.0,3.2,1.2,0.2,Iris-setosa +5.5,3.5,1.3,0.2,Iris-setosa +4.9,3.1,1.5,0.1,Iris-setosa +4.4,3.0,1.3,0.2,Iris-setosa +5.1,3.4,1.5,0.2,Iris-setosa +5.0,3.5,1.3,0.3,Iris-setosa +4.5,2.3,1.3,0.3,Iris-setosa +4.4,3.2,1.3,0.2,Iris-setosa +5.0,3.5,1.6,0.6,Iris-setosa +5.1,3.8,1.9,0.4,Iris-setosa +4.8,3.0,1.4,0.3,Iris-setosa +5.1,3.8,1.6,0.2,Iris-setosa +4.6,3.2,1.4,0.2,Iris-setosa +5.3,3.7,1.5,0.2,Iris-setosa +5.0,3.3,1.4,0.2,Iris-setosa +7.0,3.2,4.7,1.4,Iris-versicolor +6.4,3.2,4.5,1.5,Iris-versicolor +6.9,3.1,4.9,1.5,Iris-versicolor +5.5,2.3,4.0,1.3,Iris-versicolor +6.5,2.8,4.6,1.5,Iris-versicolor +5.7,2.8,4.5,1.3,Iris-versicolor +6.3,3.3,4.7,1.6,Iris-versicolor +4.9,2.4,3.3,1.0,Iris-versicolor +6.6,2.9,4.6,1.3,Iris-versicolor +5.2,2.7,3.9,1.4,Iris-versicolor +5.0,2.0,3.5,1.0,Iris-versicolor +5.9,3.0,4.2,1.5,Iris-versicolor +6.0,2.2,4.0,1.0,Iris-versicolor +6.1,2.9,4.7,1.4,Iris-versicolor +5.6,2.9,3.6,1.3,Iris-versicolor +6.7,3.1,4.4,1.4,Iris-versicolor +5.6,3.0,4.5,1.5,Iris-versicolor +5.8,2.7,4.1,1.0,Iris-versicolor +6.2,2.2,4.5,1.5,Iris-versicolor +5.6,2.5,3.9,1.1,Iris-versicolor +5.9,3.2,4.8,1.8,Iris-versicolor +6.1,2.8,4.0,1.3,Iris-versicolor +6.3,2.5,4.9,1.5,Iris-versicolor +6.1,2.8,4.7,1.2,Iris-versicolor +6.4,2.9,4.3,1.3,Iris-versicolor +6.6,3.0,4.4,1.4,Iris-versicolor +6.8,2.8,4.8,1.4,Iris-versicolor +6.7,3.0,5.0,1.7,Iris-versicolor +6.0,2.9,4.5,1.5,Iris-versicolor +5.7,2.6,3.5,1.0,Iris-versicolor +5.5,2.4,3.8,1.1,Iris-versicolor +5.5,2.4,3.7,1.0,Iris-versicolor +5.8,2.7,3.9,1.2,Iris-versicolor +6.0,2.7,5.1,1.6,Iris-versicolor +5.4,3.0,4.5,1.5,Iris-versicolor +6.0,3.4,4.5,1.6,Iris-versicolor +6.7,3.1,4.7,1.5,Iris-versicolor +6.3,2.3,4.4,1.3,Iris-versicolor +5.6,3.0,4.1,1.3,Iris-versicolor +5.5,2.5,4.0,1.3,Iris-versicolor +5.5,2.6,4.4,1.2,Iris-versicolor +6.1,3.0,4.6,1.4,Iris-versicolor +5.8,2.6,4.0,1.2,Iris-versicolor +5.0,2.3,3.3,1.0,Iris-versicolor +5.6,2.7,4.2,1.3,Iris-versicolor +5.7,3.0,4.2,1.2,Iris-versicolor +5.7,2.9,4.2,1.3,Iris-versicolor +6.2,2.9,4.3,1.3,Iris-versicolor +5.1,2.5,3.0,1.1,Iris-versicolor +5.7,2.8,4.1,1.3,Iris-versicolor +6.3,3.3,6.0,2.5,Iris-virginica +5.8,2.7,5.1,1.9,Iris-virginica +7.1,3.0,5.9,2.1,Iris-virginica +6.3,2.9,5.6,1.8,Iris-virginica +6.5,3.0,5.8,2.2,Iris-virginica +7.6,3.0,6.6,2.1,Iris-virginica +4.9,2.5,4.5,1.7,Iris-virginica +7.3,2.9,6.3,1.8,Iris-virginica +6.7,2.5,5.8,1.8,Iris-virginica +7.2,3.6,6.1,2.5,Iris-virginica +6.5,3.2,5.1,2.0,Iris-virginica +6.4,2.7,5.3,1.9,Iris-virginica +6.8,3.0,5.5,2.1,Iris-virginica +5.7,2.5,5.0,2.0,Iris-virginica +5.8,2.8,5.1,2.4,Iris-virginica +6.4,3.2,5.3,2.3,Iris-virginica +6.5,3.0,5.5,1.8,Iris-virginica +7.7,3.8,6.7,2.2,Iris-virginica +7.7,2.6,6.9,2.3,Iris-virginica +6.0,2.2,5.0,1.5,Iris-virginica +6.9,3.2,5.7,2.3,Iris-virginica +5.6,2.8,4.9,2.0,Iris-virginica +7.7,2.8,6.7,2.0,Iris-virginica +6.3,2.7,4.9,1.8,Iris-virginica +6.7,3.3,5.7,2.1,Iris-virginica +7.2,3.2,6.0,1.8,Iris-virginica +6.2,2.8,4.8,1.8,Iris-virginica +6.1,3.0,4.9,1.8,Iris-virginica +6.4,2.8,5.6,2.1,Iris-virginica +7.2,3.0,5.8,1.6,Iris-virginica +7.4,2.8,6.1,1.9,Iris-virginica +7.9,3.8,6.4,2.0,Iris-virginica +6.4,2.8,5.6,2.2,Iris-virginica +6.3,2.8,5.1,1.5,Iris-virginica +6.1,2.6,5.6,1.4,Iris-virginica +7.7,3.0,6.1,2.3,Iris-virginica +6.3,3.4,5.6,2.4,Iris-virginica +6.4,3.1,5.5,1.8,Iris-virginica +6.0,3.0,4.8,1.8,Iris-virginica +6.9,3.1,5.4,2.1,Iris-virginica +6.7,3.1,5.6,2.4,Iris-virginica +6.9,3.1,5.1,2.3,Iris-virginica +5.8,2.7,5.1,1.9,Iris-virginica +6.8,3.2,5.9,2.3,Iris-virginica +6.7,3.3,5.7,2.5,Iris-virginica +6.7,3.0,5.2,2.3,Iris-virginica +6.3,2.5,5.0,1.9,Iris-virginica +6.5,3.0,5.2,2.0,Iris-virginica +6.2,3.4,5.4,2.3,Iris-virginica +5.9,3.0,5.1,1.8,Iris-virginica diff --git a/backend/microservice/api/newmlservice.py b/backend/microservice/api/newmlservice.py index 604e4d3c..f5122a06 100644 --- a/backend/microservice/api/newmlservice.py +++ b/backend/microservice/api/newmlservice.py @@ -156,6 +156,15 @@ def train(dataset, paramsModel,paramsExperiment,paramsDataset,callback): # ### Enkodiranje encodings=paramsExperiment["encodings"] + + from sklearn.preprocessing import LabelEncoder + kategorijskekolone=data.select_dtypes(include=['object']).columns + encoder=LabelEncoder() + for kolona in data.columns: + if(kolona in kategorijskekolone): + data[kolona]=encoder.fit_transform(data[kolona]) + ''' + encoding=paramsExperiment["encoding"] datafront=dataset.copy() svekolone=datafront.columns kategorijskekolone=datafront.select_dtypes(include=['object']).columns @@ -207,6 +216,8 @@ def train(dataset, paramsModel,paramsExperiment,paramsDataset,callback): category_columns.append(col) encoder=ce.BaseNEncoder(cols=category_columns, return_df=True, base=5) encoder.fit_transform(data) + + ''' # # Input - output # @@ -301,7 +312,7 @@ def train(dataset, paramsModel,paramsExperiment,paramsDataset,callback): - classifier.compile(loss =paramsModel["lossFunction"] , optimizer = paramsModel['optimizer'] , metrics =paramsModel['metrics']) + classifier.compile(loss =paramsModel["lossFunction"] , optimizer = paramsModel['optimizer'] , metrics =['accuracy','mae','mse']) history=classifier.fit(x_train, y_train, epochs = paramsModel['epochs'],batch_size=paramsModel['batchSize'],callbacks=callback(x_test, y_test,paramsModel['_id'])) @@ -333,7 +344,7 @@ def train(dataset, paramsModel,paramsExperiment,paramsDataset,callback): classifier.add(tf.keras.layers.Dense(units=paramsModel['hiddenLayerNeurons'], activation=paramsModel['hiddenLayerActivationFunctions'][i+1]))#i-ti skriveni sloj classifier.add(tf.keras.layers.Dense(units=1, activation=paramsModel['outputLayerActivationFunction']))#izlazni sloj - classifier.compile(loss =paramsModel["lossFunction"] , optimizer = paramsModel['optimizer'] , metrics =paramsModel['metrics']) + classifier.compile(loss =paramsModel["lossFunction"] , optimizer = paramsModel['optimizer'] , metrics =['accuracy','mae','mse']) history=classifier.fit(x_train, y_train, epochs = paramsModel['epochs'],batch_size=paramsModel['batchSize'],callbacks=callback(x_test, y_test,paramsModel['_id'])) hist=history.history @@ -359,7 +370,7 @@ def train(dataset, paramsModel,paramsExperiment,paramsDataset,callback): classifier.add(tf.keras.layers.Dense(units=paramsModel['hiddenLayerNeurons'], activation=paramsModel['hiddenLayerActivationFunctions'][i+1]))#i-ti skriveni sloj classifier.add(tf.keras.layers.Dense(units=1)) - classifier.compile(loss =paramsModel["lossFunction"] , optimizer = paramsModel['optimizer'] , metrics =paramsModel['metrics']) + classifier.compile(loss =paramsModel["lossFunction"] , optimizer = paramsModel['optimizer'] , metrics =['accuracy','mae','mse']) history=classifier.fit(x_train, y_train, epochs = paramsModel['epochs'],batch_size=paramsModel['batchSize'],callbacks=callback(x_test, y_test,paramsModel['_id'])) hist=history.history @@ -529,7 +540,7 @@ def manageH5(dataset,params,h5model): h5model.summary() #ann_viz(h5model, title="My neural network") - h5model.compile(loss=params['lossFunction'], optimizer=params['optimizer'], metrics=params['metrics']) + h5model.compile(loss=params['lossFunction'], optimizer=params['optimizer'], metrics=params['accuracy','']) history=h5model.fit(x2, y2, epochs = params['epochs'],batch_size=params['batchSize']) diff --git a/frontend/package.json b/frontend/package.json index c02a1fb0..7df35a97 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -29,13 +29,14 @@ "@popperjs/core": "^2.10.2", "bootstrap": "^5.1.3", "chart.js": "^3.7.1", + "chartjs-plugin-datalabels": "^0.7.0", "csv-parser": "^3.0.0", "d3-graphviz": "^2.6.1", "jquery": "^3.6.0", "mdb-angular-ui-kit": "^2.0.0", "ng-multiselect-dropdown": "^0.3.8", "ng-uikit-pro-standard": "^1.0.0", - "ng2-charts": "^3.0.8", + "ng2-charts": "^3.0.9", "ng2-search-filter": "^0.5.1", "ngx-cookie-service": "^13.1.2", "popper.js": "^1.16.1", diff --git a/frontend/src/app/_data/Model.ts b/frontend/src/app/_data/Model.ts index b273f56a..7d383584 100644 --- a/frontend/src/app/_data/Model.ts +++ b/frontend/src/app/_data/Model.ts @@ -16,7 +16,7 @@ export default class Model { public inputNeurons: number = 1, public hiddenLayerNeurons: number = 1, public hiddenLayers: number = 1, - public batchSize: number = 5, + public batchSize: number = 4, public hiddenLayerActivationFunctions: string[] = ['sigmoid'], public outputLayerActivationFunction: ActivationFunction = ActivationFunction.Sigmoid, public uploaderId: string = '', @@ -94,7 +94,7 @@ export enum LossFunctionBinaryClassification { HingeLoss = 'hinge_loss', } export enum LossFunctionMultiClassification { - CategoricalCrossEntropy = 'categorical_crossentropy', + //CategoricalCrossEntropy = 'categorical_crossentropy', SparseCategoricalCrossEntropy = 'sparse_categorical_crossentropy', KLDivergence = 'kullback_leibler_divergence', } diff --git a/frontend/src/app/_elements/line-chart/line-chart.component.css b/frontend/src/app/_elements/line-chart/line-chart.component.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/frontend/src/app/_elements/line-chart/line-chart.component.css diff --git a/frontend/src/app/_elements/line-chart/line-chart.component.html b/frontend/src/app/_elements/line-chart/line-chart.component.html new file mode 100644 index 00000000..8607aac5 --- /dev/null +++ b/frontend/src/app/_elements/line-chart/line-chart.component.html @@ -0,0 +1,9 @@ +<div class="chart-wrapper"> + <canvas baseChart + [datasets]="lineChartData" + [labels]="lineChartLabels" + [options]="lineChartOptions" + [legend]="lineChartLegend" + [plugins]="lineChartPlugins"> + </canvas> +</div>
\ No newline at end of file diff --git a/frontend/src/app/_elements/line-chart/line-chart.component.spec.ts b/frontend/src/app/_elements/line-chart/line-chart.component.spec.ts new file mode 100644 index 00000000..0c5e7ef5 --- /dev/null +++ b/frontend/src/app/_elements/line-chart/line-chart.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LineChartComponent } from './line-chart.component'; + +describe('LineChartComponent', () => { + let component: LineChartComponent; + let fixture: ComponentFixture<LineChartComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LineChartComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(LineChartComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/_elements/line-chart/line-chart.component.ts b/frontend/src/app/_elements/line-chart/line-chart.component.ts new file mode 100644 index 00000000..7a06ecf5 --- /dev/null +++ b/frontend/src/app/_elements/line-chart/line-chart.component.ts @@ -0,0 +1,57 @@ +import { Component, OnInit } from '@angular/core'; +import { ChartOptions } from 'chart.js'; +import { BaseChartDirective } from 'ng2-charts'; + +@Component({ + selector: 'app-line-chart', + templateUrl: './line-chart.component.html', + styleUrls: ['./line-chart.component.css'] +}) +export class LineChartComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + lineChartData:Array<any> = [ + {data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A'}, + {data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B'}, + {data: [18, 48, 77, 9, 100, 27, 40], label: 'Series C'} + ]; + lineChartLabels: BaseChartDirective["labels"] = ['January', 'February', 'March', 'April', 'May', 'June']; + lineChartOptions = { + responsive: true, + }; + lineChartColors:Array<any> = [ + { // grey + backgroundColor: 'rgba(148,159,177,0.2)', + borderColor: 'rgba(148,159,177,1)', + pointBackgroundColor: 'rgba(148,159,177,1)', + pointBorderColor: '#fff', + pointHoverBackgroundColor: '#fff', + pointHoverBorderColor: 'rgba(148,159,177,0.8)' + }, + { // dark grey + backgroundColor: 'rgba(77,83,96,0.2)', + borderColor: 'rgba(77,83,96,1)', + pointBackgroundColor: 'rgba(77,83,96,1)', + pointBorderColor: '#fff', + pointHoverBackgroundColor: '#fff', + pointHoverBorderColor: 'rgba(77,83,96,1)' + }, + { // grey + backgroundColor: 'rgba(148,159,177,0.2)', + borderColor: 'rgba(148,159,177,1)', + pointBackgroundColor: 'rgba(148,159,177,1)', + pointBorderColor: '#fff', + pointHoverBackgroundColor: '#fff', + pointHoverBorderColor: 'rgba(148,159,177,0.8)' + } + ]; + lineChartLegend = true; + lineChartPlugins = []; + lineChartType = 'line'; + +} + + diff --git a/frontend/src/app/_elements/model-load/model-load.component.html b/frontend/src/app/_elements/model-load/model-load.component.html index dcb35c21..a1e6abd6 100644 --- a/frontend/src/app/_elements/model-load/model-load.component.html +++ b/frontend/src/app/_elements/model-load/model-load.component.html @@ -1,12 +1,10 @@ <div> <div class="d-flex flex-row justify-content-center align-items-center mt-3 mb-5"> - <button type="button" id="btnMyModel" class="btn" (click)="viewMyModelsForm()" - [ngClass]="{'btnType1': showMyModels, 'btnType2': !showMyModels}"> + <button type="button" id="btnMyModel" class="btn" (click)="viewMyModelsForm()" [ngClass]="{'btnType1': showMyModels, 'btnType2': !showMyModels}"> Izaberite model iz kolekcije </button> <h3 class="mt-3 mx-3">ili</h3> - <button type="button" id="btnNewModel" class="btn" (click)="viewNewModelForm()" - [ngClass]="{'btnType1': !showMyModels, 'btnType2': showMyModels}"> + <button type="button" id="btnNewModel" class="btn" (click)="viewNewModelForm()" [ngClass]="{'btnType1': !showMyModels, 'btnType2': showMyModels}"> Dodajte novi model </button> </div> @@ -17,8 +15,7 @@ <div *ngIf="showMyModels" class="px-5"> <div class="overflow-auto" style="max-height: 500px;"> <ul class="list-group"> - <li class="list-group-item p-3" *ngFor="let model of myModels|filter:term|filter:(forExperiment ? forExperiment.type : '')" - [ngClass]="{'selectedModelClass': this.selectedModel == model}"> + <li class="list-group-item p-3" *ngFor="let model of myModels|filter:((forExperiment != undefined) ? forExperiment.type : '')" [ngClass]="{'selectedModelClass': this.selectedModel == model}"> <app-item-model name="usersModel" [model]="model" (click)="selectThisModel(model);"> </app-item-model> </li> @@ -43,7 +40,7 @@ <textarea class="form-control" name="desc" rows="3" [(ngModel)]="newModel.description"></textarea> </div> </div> - + </div> <h2 class="mt-5 mb-4 mx-5">Parametri treniranja modela:</h2> <div> @@ -54,8 +51,7 @@ <label for="type" class="col-form-label">Tip problema: </label> </div> <div class="col-2"> - <select id=typeOptions class="form-select" name="type" [(ngModel)]="newModel.type" - (change)="filterOptions()"> + <select id=typeOptions class="form-select" name="type" [(ngModel)]="newModel.type" (change)="filterOptions()"> <option *ngFor="let option of Object.keys(ProblemType); let optionName of Object.values(ProblemType)" [value]="option"> @@ -68,10 +64,7 @@ <label for="hiddenLayers" class="col-form-label">Broj skrivenih slojeva: </label> </div> <div class="col-1"> - <input type="number" min="1" class="form-control" name="hiddenLayers" - [(ngModel)]="newModel.hiddenLayers" - (change)="newModel.hiddenLayerActivationFunctions = [].constructor(newModel.hiddenLayers).fill(newModel.hiddenLayerActivationFunctions[0])" - (ngModelChange)="updateGraph()"> + <input type="number" min="1" class="form-control" name="hiddenLayers" [(ngModel)]="newModel.hiddenLayers" (change)="newModel.hiddenLayerActivationFunctions = [].constructor(newModel.hiddenLayers).fill(newModel.hiddenLayerActivationFunctions[0])" (ngModelChange)="updateGraph()"> </div> </div> @@ -96,8 +89,7 @@ <label for="hiddenLayerNeurons" class="col-form-label">Broj neurona skrivenih slojeva: </label> </div> <div class="col-1"> - <input type="number" min="1" class="form-control" name="hiddenLayerNeurons" - [(ngModel)]="newModel.hiddenLayerNeurons" (ngModelChange)="updateGraph()"> + <input type="number" min="1" class="form-control" name="hiddenLayerNeurons" [(ngModel)]="newModel.hiddenLayerNeurons" (ngModelChange)="updateGraph()"> </div> </div> @@ -107,8 +99,7 @@ <label for="lossFunction" class="col-form-label">Funkcija troška: </label> </div> <div class="col-2"> - <select id=lossFunctionOptions class="form-select" name="lossFunction" - [(ngModel)]="newModel.lossFunction" aria-checked="true"> + <select id=lossFunctionOptions class="form-select" name="lossFunction" [(ngModel)]="newModel.lossFunction" aria-checked="true"> <option *ngFor="let option of Object.keys(lossFunction); let optionName of Object.values(lossFunction)" [value]="option"> @@ -118,23 +109,21 @@ </div> <div class="col-1"></div> <div class="col-3"> - <label for="batchSize" class="col-form-label">Broj uzorka po iteraciji: </label> + <label for="batchSize" class="col-form-label">Broj uzorka po iteraciji: <b>{{newModel.batchSize}}</b><br>(izaberite stepen dvojke)</label> </div> <div class="col-1"> - - <input type="number" min="0" step="1" max="7" class="form-control" name="batchSizePower" [(ngModel)]="batchSizePower" (click)="updateBatchSize()" > - {{newModel.batchSize}} - + + <input type="number" min="0" step="1" max="7" class="form-control" name="batchSizePower" [(ngModel)]="batchSizePower" (click)="updateBatchSize()"> + </div> - + <div class="row p-2"> <div class="col-1"></div> <div class="col-3 m-1"> <label for="epochs" class="col-form-label">Broj epoha: </label> </div> <div class="col-1"> - <input type="number" min="1" max="1000" class="form-control" name="epochs" - [(ngModel)]="newModel.epochs"> + <input type="number" min="1" max="1000" class="form-control" name="epochs" [(ngModel)]="newModel.epochs"> </div> </div> </div> @@ -148,8 +137,7 @@ <div class="row p-2" style="align-self: center;"> <div class="col-1"></div> <div class="col-3"> - <label for="hiddenLayerActivationFunction" class="col-form-label" - style="text-align: center;">Funkcija aktivacije<br>skrivenih slojeva:</label> + <label for="hiddenLayerActivationFunction" class="col-form-label" style="text-align: center;">Funkcija aktivacije<br>skrivenih slojeva:</label> </div> <div class="col-2 mt-2"> <div *ngFor="let item of [].constructor(newModel.hiddenLayers); let i = index"> @@ -157,8 +145,7 @@ <div class="input-group-prepend"> <span class="input-group-text">#{{i+1}}</span> </div> - <select [id]="'hiddenLayerActivationFunctionOption_'+i" class="form-select" - [(ngModel)]="newModel.hiddenLayerActivationFunctions[i]" > + <select [id]="'hiddenLayerActivationFunctionOption_'+i" class="form-select" [(ngModel)]="newModel.hiddenLayerActivationFunctions[i]"> <option *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)" [value]="option"> @@ -170,12 +157,10 @@ </div> <div class="col-1"></div> <div class="col-2"> - <label for="outputLayerActivationFunction" class="col-form-label" - style="text-align: center;">Funkcija aktivacije<br>izlaznog sloja:</label> + <label for="outputLayerActivationFunction" class="col-form-label" style="text-align: center;">Funkcija aktivacije<br>izlaznog sloja:</label> </div> <div class="col-2 mt-2"> - <select id=outputLayerActivationFunctionOptions class="form-select" - name="outputLayerActivationFunction" [(ngModel)]="newModel.outputLayerActivationFunction"> + <select id=outputLayerActivationFunctionOptions class="form-select" name="outputLayerActivationFunction" [(ngModel)]="newModel.outputLayerActivationFunction"> <option *ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)" [value]="option"> @@ -192,22 +177,19 @@ <h3>Izaberite metrike:</h3> <div id="divMetricsinput" class="mt-2 mx-5"> - <div *ngFor="let option of Object.keys(metrics); let optionName of Object.values(metrics) " - class="form-check form-check-inline"> + <div *ngFor="let option of Object.keys(metrics); let optionName of Object.values(metrics) " class="form-check form-check-inline"> - <input name="cbmetrics" class="form-check-input" type="checkbox" value="{{option}}" - id="metrics_{{option}}" style="float: left;" checked> + <input name="cbmetrics" class="form-check-input" type="checkbox" value="{{option}}" id="metrics_{{option}}" style="float: left;" checked> <label class="form-check-label" for="metrics_{{option}}" for="inlineCheckbox2"> {{optionName}} </label> </div> </div> </div> - + <div class="form-group row mt-3 mb-3"> <div class="col"></div> - <button class="btn btn-lg col-4" style="background-color:#003459; color:white;" - (click)="uploadModel();">Sačuvaj + <button class="btn btn-lg col-4" style="background-color:#003459; color:white;" (click)="uploadModel();">Sačuvaj model</button> <div class="col"></div> </div> diff --git a/frontend/src/app/_elements/model-load/model-load.component.ts b/frontend/src/app/_elements/model-load/model-load.component.ts index dbca3d17..5f9caf9d 100644 --- a/frontend/src/app/_elements/model-load/model-load.component.ts +++ b/frontend/src/app/_elements/model-load/model-load.component.ts @@ -31,21 +31,32 @@ export class ModelLoadComponent implements OnInit { shared = Shared; term: string = ""; - selectedProblemType: string = ''; selectedMetrics = []; lossFunction: any = LossFunction; showMyModels: boolean = true; + batchSizePower: number = 2; + constructor(private modelsService: ModelsService) { - this.modelsService.getMyModels().subscribe((models) => { - this.myModels = models; - }); + //console.log("forExperiment = ", this.forExperiment); + + //if (this.forExperiment == undefined) { + this.modelsService.getMyModels().subscribe((models) => { + this.myModels = models; + }); + /*} + else { + this.modelsService.getMyModelsByType(ProblemType.Regression).subscribe((models) => { + this.myModels = models; + console.log("modeli po tipu: ", this.myModels); + }); + }*/ } ngOnInit(): void { } - batchSizePower:number=1; + updateBatchSize() { this.newModel.batchSize=2**this.batchSizePower; @@ -73,8 +84,6 @@ export class ModelLoadComponent implements OnInit { this.modelsService.addModel(this.newModel).subscribe((response) => { Shared.openDialog('Model dodat', 'Model je uspešno dodat u bazu.'); - // treba da se selektuje nov model u listi modela - //this.selectedModel = }, (error) => { Shared.openDialog('Greška', 'Model sa unetim nazivom već postoji u Vašoj kolekciji. Promenite naziv modela i nastavite sa kreiranim datasetom.'); }); diff --git a/frontend/src/app/_services/models.service.ts b/frontend/src/app/_services/models.service.ts index 44383828..1130b12c 100644 --- a/frontend/src/app/_services/models.service.ts +++ b/frontend/src/app/_services/models.service.ts @@ -1,6 +1,6 @@ import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import Model from '../_data/Model'; +import Model, { ProblemType } from '../_data/Model'; import { AuthService } from './auth.service'; import { Observable } from 'rxjs'; import Dataset from '../_data/Dataset'; @@ -31,20 +31,16 @@ export class ModelsService { addModel(model: Model): Observable<any> { return this.http.post(`${Configuration.settings.apiURL}/model/add`, model, { headers: this.authService.authHeader() }); } - addDataset(dataset: Dataset): Observable<any> { - return this.http.post(`${Configuration.settings.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader() }); - } trainModel(modelId: string, experimentId: string): Observable<any> { return this.http.post(`${Configuration.settings.apiURL}/model/trainmodel`, { ModelId: modelId, ExperimentId: experimentId }, { headers: this.authService.authHeader(), responseType: 'text' }); } - getMyDatasets(): Observable<Dataset[]> { - return this.http.get<Dataset[]>(`${Configuration.settings.apiURL}/dataset/mydatasets`, { headers: this.authService.authHeader() }); - } - getMyModels(): Observable<Model[]> { return this.http.get<Model[]>(`${Configuration.settings.apiURL}/model/mymodels`, { headers: this.authService.authHeader() }); } + getMyModelsByType(problemType: ProblemType): Observable<Model[]> { + return this.http.get<Model[]>(`${Configuration.settings.apiURL}/model/mymodelsbytype/` + problemType, { headers: this.authService.authHeader() }); + } editModel(model: Model): Observable<Model> { return this.http.put<Model>(`${Configuration.settings.apiURL}/model/`, model, { headers: this.authService.authHeader() }); @@ -53,4 +49,5 @@ export class ModelsService { deleteModel(model: Model) { return this.http.delete(`${Configuration.settings.apiURL}/model/` + model.name, { headers: this.authService.authHeader(), responseType: "text" }); } + } diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index cd891801..22ad96da 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -52,6 +52,7 @@ import { PointLinechartComponent } from './point-linechart/point-linechart.compo import { GraficiComponent } from './grafici/grafici.component'; import { MixedChartComponent } from './mixed-chart/mixed-chart.component'; +import { LineChartComponent } from './_elements/line-chart/line-chart.component'; export function initializeApp(appConfig: Configuration) { return () => appConfig.load(); } @@ -93,7 +94,8 @@ export function initializeApp(appConfig: Configuration) { YesNoDialogComponent, PointLinechartComponent, GraficiComponent, - MixedChartComponent + MixedChartComponent, + LineChartComponent ], imports: [ BrowserModule, diff --git a/frontend/src/app/experiment/experiment.component.ts b/frontend/src/app/experiment/experiment.component.ts index 7e2f0b29..84fdbf0f 100644 --- a/frontend/src/app/experiment/experiment.component.ts +++ b/frontend/src/app/experiment/experiment.component.ts @@ -199,10 +199,6 @@ export class ExperimentComponent implements OnInit { this.experimentsService.addExperiment(this.experiment).subscribe((response) => { this.experiment = response; - this.selectedColumnsInfoArray = []; - this.selectedNotNullColumnsArray = []; - this.experiment.encodings = []; - Shared.openDialog("Obaveštenje", "Eksperiment je uspešno kreiran."); this.router.navigate(['/training', this.experiment._id]); diff --git a/frontend/src/app/training/training.component.html b/frontend/src/app/training/training.component.html index 672e75fb..2bee3b12 100644 --- a/frontend/src/app/training/training.component.html +++ b/frontend/src/app/training/training.component.html @@ -9,29 +9,27 @@ <h2>1. Izaberite eksperiment iz kolekcije</h2> <div class="px-5 mt-5 mb-3"> - <input type="text" class="form-control" placeholder="Pretraga" - [(ngModel)]="term"> + <input type="text" class="form-control" placeholder="Pretraga" [(ngModel)]="term"> </div> <div class="overflow-auto px-5" style="max-height: 500px;"> <ul class="list-group"> - <li class="list-group-item p-3" *ngFor="let experiment of myExperiments|filter:term" - [ngClass]="{'selectedExperimentClass': this.selectedExperiment == experiment}"> - <app-item-experiment [experiment]="experiment" - (click)="selectThisExperiment(experiment);"></app-item-experiment> + <li class="list-group-item p-3" *ngFor="let experiment of myExperiments|filter:term" [ngClass]="{'selectedExperimentClass': this.selectedExperiment == experiment}"> + <app-item-experiment [experiment]="experiment" (click)="selectThisExperiment(experiment);"></app-item-experiment> </li> </ul> </div> - + <h2 class="mt-5 mb-2">2. Izaberite model</h2> - <app-model-load (selectedModelChangeEvent)="selectModel($event)" [forExperiment]="selectedExperiment"></app-model-load> - + <app-model-load *ngIf="selectedExperiment" (selectedModelChangeEvent)="selectModel($event)" [forExperiment]="selectedExperiment"></app-model-load> + <h3 *ngIf="!selectedExperiment">Morate prvo izabrati eksperiment.</h3> + <h2 class="my-5">3. Treniranje modela</h2> <div class="d-flex flex-row justify-content-center align-items-center my-3"> <button class="btn btn-lg col-4" style="background-color:#003459; color:white;" (click)="trainModel();">Treniraj model</button> </div> - + <h2 class="mt-5">Rezultati treniranja</h2> <div class="m-3" *ngIf="trainingResult"> <h2 class="my-2">Rezultati treniranja:</h2> diff --git a/frontend/src/app/training/training.component.ts b/frontend/src/app/training/training.component.ts index f60734cc..c82a6b79 100644 --- a/frontend/src/app/training/training.component.ts +++ b/frontend/src/app/training/training.component.ts @@ -1,8 +1,9 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import Shared from '../Shared'; import Experiment from '../_data/Experiment'; -import Model from '../_data/Model'; +import Model, { ProblemType } from '../_data/Model'; +import { ModelLoadComponent } from '../_elements/model-load/model-load.component'; import { ExperimentsService } from '../_services/experiments.service'; import { ModelsService } from '../_services/models.service'; @@ -13,6 +14,8 @@ import { ModelsService } from '../_services/models.service'; }) export class TrainingComponent implements OnInit{ + @ViewChild(ModelLoadComponent) modelLoadComponent?: ModelLoadComponent; + myExperiments?: Experiment[]; selectedExperiment?: Experiment; selectedModel?: Model; @@ -26,17 +29,20 @@ export class TrainingComponent implements OnInit{ ngOnInit(): void { this.route.queryParams.subscribe(params => { - let expId =this.route.snapshot.paramMap.get("id"); + let experimentId =this.route.snapshot.paramMap.get("id"); this.experimentsService.getMyExperiments().subscribe((experiments) => { this.myExperiments = experiments; - this.selectedExperiment = this.myExperiments.filter(x => x._id == expId)[0]; + + this.selectedExperiment = this.myExperiments.filter(x => x._id == experimentId)[0]; + console.log("selektovan exp u training comp: ", this.selectedExperiment); }); }); } selectThisExperiment(experiment: Experiment) { this.selectedExperiment = experiment; + this.modelLoadComponent!.newModel.type = this.selectedExperiment.type; } selectModel(model: Model) { |