aboutsummaryrefslogtreecommitdiff
path: root/backend/api
diff options
context:
space:
mode:
authorDanijel Andjelkovic <adanijel99@gmail.com>2022-04-20 00:12:42 +0000
committerDanijel Andjelkovic <adanijel99@gmail.com>2022-04-20 00:12:42 +0000
commitb814ef17d31dca80a3f23b3fbe4ce56885192a4c (patch)
treed7a297db46d57267b5516a8c20ee906dd39571ed /backend/api
parent9a480b28ac9b93dee082925b9cb4beef3244b135 (diff)
parente6d9e3fd2dcf83c90db8560e749544dfd9910d07 (diff)
Merge branch 'dev' into 'master'
Merge master See merge request igrannonica/neuronstellar!27
Diffstat (limited to 'backend/api')
-rw-r--r--backend/api/api/.gitignore1
-rw-r--r--backend/api/api/Controllers/DatasetController.cs78
-rw-r--r--backend/api/api/Controllers/FileController.cs24
-rw-r--r--backend/api/api/Controllers/ModelController.cs91
-rw-r--r--backend/api/api/Controllers/PredictorController.cs143
-rw-r--r--backend/api/api/Models/ColumnEncoding.cs14
-rw-r--r--backend/api/api/Models/ColumnInfo.cs14
-rw-r--r--backend/api/api/Models/Dataset.cs2
-rw-r--r--backend/api/api/Models/Experiment.cs3
-rw-r--r--backend/api/api/Models/Model.cs2
-rw-r--r--backend/api/api/Models/Predictor.cs38
-rw-r--r--backend/api/api/Program.cs14
-rw-r--r--backend/api/api/Properties/launchSettings.json46
-rw-r--r--backend/api/api/Services/DatasetService.cs28
-rw-r--r--backend/api/api/Services/FillAnEmptyDb.cs262
-rw-r--r--backend/api/api/Services/IDatasetService.cs12
-rw-r--r--backend/api/api/Services/IMlConnectionService.cs3
-rw-r--r--backend/api/api/Services/IModelService.cs11
-rw-r--r--backend/api/api/Services/IPredictorService.cs25
-rw-r--r--backend/api/api/Services/MlApiCheckActionFilter.cs50
-rw-r--r--backend/api/api/Services/MlConnectionService.cs24
-rw-r--r--backend/api/api/Services/ModelService.cs26
-rw-r--r--backend/api/api/Services/PredictorService.cs28
-rw-r--r--backend/api/api/Services/TempRemovalService.cs6
-rw-r--r--backend/api/api/Services/UserService.cs12
-rw-r--r--backend/api/api/UploadedFiles/Igrannonica/iris.csv151
-rw-r--r--backend/api/api/api.csproj1
-rw-r--r--backend/api/api/appsettings.json42
28 files changed, 742 insertions, 409 deletions
diff --git a/backend/api/api/.gitignore b/backend/api/api/.gitignore
index 17288e4c..3c45979c 100644
--- a/backend/api/api/.gitignore
+++ b/backend/api/api/.gitignore
@@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
##Ignore contents for UploadedFiles Folder
+PredictorFiles/*
UploadedFiles/*
!UploadedFiles/Igrannonica
TempFiles/*
diff --git a/backend/api/api/Controllers/DatasetController.cs b/backend/api/api/Controllers/DatasetController.cs
index add85aba..0a9fe0bd 100644
--- a/backend/api/api/Controllers/DatasetController.cs
+++ b/backend/api/api/Controllers/DatasetController.cs
@@ -25,22 +25,23 @@ namespace api.Controllers
_fileService = fileService;
jwtToken = Token;
}
- public string getUsername()
+
+ public string getUserId()
{
- string username;
+ string userId;
var header = Request.Headers[HeaderNames.Authorization];
if (AuthenticationHeaderValue.TryParse(header, out var headerValue))
{
var scheme = headerValue.Scheme;
var parameter = headerValue.Parameter;
- username = jwtToken.TokenToUsername(parameter);
- if (username == null)
+ userId = jwtToken.TokenToId(parameter);
+ if (userId == null)
return null;
}
else
return null;
- return username;
+ return userId;
}
// GET: api/<DatasetController>/mydatasets
@@ -48,17 +49,17 @@ namespace api.Controllers
[Authorize(Roles = "User,Guest")]
public ActionResult<List<Dataset>> Get()
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- if (username == "")
+ if (userId == "")
return _datasetService.GetGuestDatasets();
//ako bude trebao ID, samo iz baze uzeti
- return _datasetService.GetMyDatasets(username);
+ return _datasetService.GetMyDatasets(userId);
}
// GET: api/<DatasetController>/datesort/{ascdsc}/{latest}
@@ -69,12 +70,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Dataset>> SortDatasets(bool ascdsc, int latest)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- List<Dataset> lista = _datasetService.SortDatasets(username, ascdsc, latest);
+ List<Dataset> lista = _datasetService.SortDatasets(userId, ascdsc, latest);
if (latest == 0)
return lista;
@@ -100,14 +101,7 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Dataset>> Search(string name)
{
- string username = getUsername();
-
- if (username == null)
- return BadRequest();
-
- //ako bude trebao ID, samo iz baze uzeti
-
- return _datasetService.SearchDatasets(name, username);
+ return _datasetService.SearchDatasets(name);
}
@@ -117,12 +111,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<Dataset> Get(string name)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var dataset = _datasetService.GetOneDataset(username, name);
+ var dataset = _datasetService.GetOneDataset(userId, name);
if (dataset == null)
return NotFound($"Dataset with name = {name} not found or dataset is not public or not preprocessed");
@@ -134,25 +128,15 @@ namespace api.Controllers
[Authorize(Roles = "User,Guest")]
public async Task<ActionResult<Dataset>> Post([FromBody] Dataset dataset)
{
- string uploaderId;
- var header = Request.Headers[HeaderNames.Authorization];
- if (AuthenticationHeaderValue.TryParse(header, out var headerValue))
- {
- var scheme = headerValue.Scheme;
- var parameter = headerValue.Parameter;
- uploaderId = jwtToken.TokenToId(parameter);
- if (uploaderId == null)
- return null;
- }
- else
- return BadRequest();
+ string uploaderId = getUserId();
+
//da li ce preko tokena da se ubaci username ili front salje
//dataset.username = usernameToken;
//username = "" ako je GUEST DODAO
- var existingDataset = _datasetService.GetOneDataset(dataset.username, dataset.name);
+ var existingDataset = _datasetService.GetOneDataset(dataset.uploaderId, dataset.name);
if (existingDataset != null)
- return NotFound($"Dateset with name = {dataset.name} exisits");
+ return NotFound($"Dataset with this name already exists");
else
{
FileModel fileModel = _fileService.getFile(dataset.fileId);
@@ -169,20 +153,20 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Put(string name, [FromBody] Dataset dataset)
{
- string username = getUsername();
+ string uploaderId = getUserId();
- if (username == null)
+ if (uploaderId == null)
return BadRequest();
- var existingDataset = _datasetService.GetOneDataset(username, name);
+ var existingDataset = _datasetService.GetOneDataset(uploaderId, name);
//ne mora da se proverava
if (existingDataset == null)
- return NotFound($"Dataset with name = {name} or user with username = {username} not found");
+ return NotFound($"Dataset with name = {name} or user with ID = {uploaderId} not found");
dataset.lastUpdated = DateTime.UtcNow;
- _datasetService.Update(username, name, dataset);
+ _datasetService.Update(uploaderId, name, dataset);
return Ok($"Dataset with name = {name} updated");
}
@@ -192,17 +176,17 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Delete(string name)
{
- string username = getUsername();
+ string uploaderId = getUserId();
- if (username == null)
+ if (uploaderId == null)
return BadRequest();
- var dataset = _datasetService.GetOneDataset(username, name);
+ var dataset = _datasetService.GetOneDataset(uploaderId, name);
if (dataset == null)
- return NotFound($"Dataset with name = {name} or user with username = {username} not found");
+ return NotFound($"Dataset with name = {name} or user with ID = {uploaderId} not found");
- _datasetService.Delete(dataset.username, dataset.name);
+ _datasetService.Delete(dataset.uploaderId, dataset.name);
return Ok($"Dataset with name = {name} deleted");
diff --git a/backend/api/api/Controllers/FileController.cs b/backend/api/api/Controllers/FileController.cs
index b9b31500..68d2ebed 100644
--- a/backend/api/api/Controllers/FileController.cs
+++ b/backend/api/api/Controllers/FileController.cs
@@ -44,27 +44,13 @@ namespace api.Controllers
}
[HttpPost("h5")]
- [Authorize(Roles = "User,Guest")]
- public async Task<ActionResult<string>> H5Upload([FromForm] IFormFile file)
+ public async Task<ActionResult<string>> H5Upload([FromForm] IFormFile file,[FromForm] string uploaderId)
{
//get username from jwtToken
- string folderName;
-
- string uploaderId = getUserId();
+ string folderName="PredictorFiles";
- if (uploaderId == null)
- return BadRequest();
-
- if (uploaderId == "")
- {
- folderName = "TempFiles";
- }
- else
- {
- folderName = "UploadedFiles";
- }
//Check filetype
@@ -75,7 +61,7 @@ namespace api.Controllers
{
return BadRequest("Wrong file type");
}
- var folderPath = Path.Combine(Directory.GetCurrentDirectory(), folderName, uploaderId);
+ var folderPath = Path.Combine(Directory.GetCurrentDirectory(), folderName,uploaderId);
//Check Directory
if (!Directory.Exists(folderPath))
{
@@ -98,14 +84,14 @@ namespace api.Controllers
await file.CopyToAsync(stream);
}
FileModel fileModel = new FileModel();
- fileModel.type = "h5";
+ fileModel.type = ".h5";
fileModel.path = fullPath;
fileModel.uploaderId = uploaderId;
fileModel.date = DateTime.Now.ToUniversalTime();
fileModel = _fileservice.Create(fileModel);
- return Ok(fileModel);
+ return Ok(fileModel._id);
}
[HttpGet("csvread/{hasHeader}/{fileId}")]
diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs
index c31b24e1..fb30a7a2 100644
--- a/backend/api/api/Controllers/ModelController.cs
+++ b/backend/api/api/Controllers/ModelController.cs
@@ -56,23 +56,6 @@ namespace api.Controllers
return uploaderId;
}
- public string getUsername()
- {
- string username;
- var header = Request.Headers[HeaderNames.Authorization];
- if (AuthenticationHeaderValue.TryParse(header, out var headerValue))
- {
- var scheme = headerValue.Scheme;
- var parameter = headerValue.Parameter;
- username = jwtToken.TokenToUsername(parameter);
- if (username == null)
- return null;
- }
- else
- return null;
-
- return username;
- }
[HttpPost("trainModel")]
[Authorize(Roles = "User,Guest")]
@@ -81,28 +64,29 @@ namespace api.Controllers
string experimentId = trainModelObject.ExperimentId;
string modelId = trainModelObject.ModelId;
- string uploaderId = getUserId();
+ string userId = getUserId();
- if (uploaderId == null)
+ if (userId == null)
return BadRequest();
var experiment=_experimentService.Get(experimentId);
var dataset = _datasetService.GetOneDataset(experiment.datasetId);
- var filepath = _fileService.GetFilePath(dataset.fileId, uploaderId);
+ var filepath = _fileService.GetFilePath(dataset.fileId, userId);
var model = _modelService.GetOneModel(modelId);
- _mlService.TrainModel(model,experiment,filepath,dataset,uploaderId);//To do Obavestiti korisnika kada se model istrenira
+ _mlService.TrainModel(model,experiment,filepath,dataset, userId);//To do Obavestiti korisnika kada se model istrenira
return Ok();
}
[HttpPost("epoch")]
+ [ServiceFilter(typeof(MlApiCheckActionFilter))]
public async Task<ActionResult<string>> Epoch([FromBody] Epoch info)
{
var model=_modelService.GetOneModel(info.ModelId);
- var user = _userService.GetUserByUsername(model.username);
+ var user = _userService.GetUserById(model.uploaderId);
if (ChatHub.CheckUser(user._id))
- await _ichat.Clients.Client(ChatHub.Users[user._id]).SendAsync("NotifyEpoch",info.ModelId,info.Stat,model.epochs);
+ await _ichat.Clients.Client(ChatHub.Users[user._id]).SendAsync("NotifyEpoch",model.name,info.ModelId,info.Stat,model.epochs,info.EpochNum);
return Ok();
}
@@ -117,12 +101,30 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Model>> Get()
{
- string username = getUsername();
-
- if (username == null)
+ string uploaderId = getUserId();
+
+ if (uploaderId == null)
return BadRequest();
- return _modelService.GetMyModels(username);
+ 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
@@ -131,12 +133,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<Model> Get(string name)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var model = _modelService.GetOneModel(username, name);
+ var model = _modelService.GetOneModel(userId, name);
if (model == null)
return NotFound($"Model with name = {name} not found");
@@ -155,14 +157,14 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Model>> GetLatestModels(int latest)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
//ako bude trebao ID, samo iz baze uzeti
- List<Model> lista = _modelService.GetLatestModels(username);
+ List<Model> lista = _modelService.GetLatestModels(userId);
List<Model> novaLista = new List<Model>();
@@ -185,7 +187,7 @@ namespace api.Controllers
/*if (_modelService.CheckHyperparameters(1, model.hiddenLayerNeurons, model.hiddenLayers, model.outputNeurons) == false)
return BadRequest("Bad parameters!");*/
- var existingModel = _modelService.GetOneModel(model.username, model.name);
+ var existingModel = _modelService.GetOneModel(model.uploaderId, model.name);
if (existingModel != null && !overwrite)
return NotFound($"Model with name = {model.name} exisits");
@@ -209,18 +211,18 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Put(string name, [FromBody] Model model)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var existingModel = _modelService.GetOneModel(username, name);
+ var existingModel = _modelService.GetOneModel(userId, name);
if (existingModel == null)
- return NotFound($"Model with name = {name} or user with username = {username} not found");
+ return NotFound($"Model with name = {name} or user with ID = {userId} not found");
- _modelService.Update(username, name, model);
+ _modelService.Update(userId, name, model);
return NoContent();
}
@@ -229,17 +231,17 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Delete(string name)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var model = _modelService.GetOneModel(username, name);
+ var model = _modelService.GetOneModel(userId, name);
if (model == null)
- return NotFound($"Model with name = {name} or user with username = {username} not found");
+ return NotFound($"Model with name = {name} or user with ID = {userId} not found");
- _modelService.Delete(model.username, model.name);
+ _modelService.Delete(model.uploaderId, model.name);
return Ok($"Model with name = {name} deleted");
@@ -256,6 +258,7 @@ namespace api.Controllers
public class Epoch
{
public string ModelId { get; set; }
+ public int EpochNum { get; set; }
public string Stat { get; set; }
}
}
diff --git a/backend/api/api/Controllers/PredictorController.cs b/backend/api/api/Controllers/PredictorController.cs
index 233ea401..dd5aa5fd 100644
--- a/backend/api/api/Controllers/PredictorController.cs
+++ b/backend/api/api/Controllers/PredictorController.cs
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;
using System.Net.Http.Headers;
using System.Diagnostics;
+using Microsoft.AspNetCore.SignalR;
namespace api.Controllers
{
@@ -15,30 +16,38 @@ namespace api.Controllers
private readonly IPredictorService _predictorService;
private IJwtToken jwtToken;
private readonly IMlConnectionService _mlConnectionService;
+ private readonly IExperimentService _experimentService;
+ private readonly IUserService _userService;
+ private readonly IHubContext<ChatHub> _ichat;
+ private readonly IModelService _modelService;
- public PredictorController(IPredictorService predictorService, IConfiguration configuration, IJwtToken Token, IMlConnectionService mlConnectionService)
+ public PredictorController(IPredictorService predictorService, IConfiguration configuration, IJwtToken Token, IMlConnectionService mlConnectionService, IExperimentService experimentService,IUserService userService, IHubContext<ChatHub> ichat,IModelService modelService)
{
_predictorService = predictorService;
jwtToken = Token;
_mlConnectionService = mlConnectionService;
+ _experimentService = experimentService;
+ _userService = userService;
+ _ichat = ichat;
+ _modelService = modelService;
}
- public string getUsername()
+ public string getUserId()
{
- string username;
+ string uploaderId;
var header = Request.Headers[HeaderNames.Authorization];
if (AuthenticationHeaderValue.TryParse(header, out var headerValue))
{
var scheme = headerValue.Scheme;
var parameter = headerValue.Parameter;
- username = jwtToken.TokenToUsername(parameter);
- if (username == null)
+ uploaderId = jwtToken.TokenToId(parameter);
+ if (uploaderId == null)
return null;
}
else
return null;
- return username;
+ return uploaderId;
}
// GET: api/<PredictorController>/mypredictors
@@ -46,12 +55,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Predictor>> Get()
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- return _predictorService.GetMyPredictors(username);
+ return _predictorService.GetMyPredictors(userId);
}
// GET: api/<PredictorController>/publicpredictors
@@ -63,29 +72,30 @@ namespace api.Controllers
//SEARCH za predictore (public ili private sa ovim imenom )
// GET api/<PredictorController>/search/{name}
- [HttpGet("search/{name}")]
- [Authorize(Roles = "User")]
- public ActionResult<List<Predictor>> Search(string name)
- {
- string username = getUsername();
+
+ //[HttpGet("search/{name}")]
+ //[Authorize(Roles = "User")]
+ //public ActionResult<List<Predictor>> Search(string name)
+ //{
+ // string username = getUsername();
- if (username == null)
- return BadRequest();
+ // if (username == null)
+ // return BadRequest();
- return _predictorService.SearchPredictors(name, username);
- }
+ // return _predictorService.SearchPredictors(name, username);
+ //}
// GET api/<PredictorController>/getpredictor/{name}
[HttpGet("getpredictor/{id}")]
[Authorize(Roles = "User,Guest")]
public ActionResult<Predictor> GetPredictor(string id)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- Predictor predictor = _predictorService.GetPredictor(username, id);
+ Predictor predictor = _predictorService.GetPredictor(userId, id);
if (predictor == null)
return NotFound($"Predictor with id = {id} not found");
@@ -96,17 +106,18 @@ namespace api.Controllers
// GET api/<PredictorController>/{name}
[HttpGet("{name}")]
[Authorize(Roles = "User")]
- public ActionResult<Predictor> Get(string name)
+ public ActionResult<Predictor> Get(string id)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var predictor = _predictorService.GetOnePredictor(username, name);
+ //treba userId da se salje GetOnePredictor
+ var predictor = _predictorService.GetOnePredictor(id);
if (predictor == null)
- return NotFound($"Predictor with name = {name} not found or predictor is not public");
+ return NotFound($"Predictor with id = {id} not found or predictor is not public");
return predictor;
}
@@ -120,12 +131,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Predictor>> SortPredictors(bool ascdsc, int latest)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- List<Predictor> lista = _predictorService.SortPredictors(username, ascdsc, latest);
+ List<Predictor> lista = _predictorService.SortPredictors(userId, ascdsc, latest);
if(latest == 0)
return lista;
@@ -142,77 +153,83 @@ namespace api.Controllers
// POST api/<PredictorController>/add
[HttpPost("add")]
- [Authorize(Roles = "User")]
- public ActionResult<Predictor> Post([FromBody] Predictor predictor)
+ public async Task<ActionResult<Predictor>> Post([FromBody] Predictor predictor)
{
- var existingPredictor = _predictorService.GetOnePredictor(predictor.username, predictor.name);
-
- if (existingPredictor != null)
- return NotFound($"Predictor with name = {predictor.name} exisits");
- else
- {
- _predictorService.Create(predictor);
-
- return CreatedAtAction(nameof(Get), new { id = predictor._id }, predictor);
- }
+ var user=_userService.GetUserById(predictor.uploaderId);
+ predictor.dateCreated = DateTime.Now.ToUniversalTime();
+ var model = _modelService.GetOneModel(predictor.modelId);
+ if (model == null || user==null)
+ return BadRequest("Model not found or user doesnt exist");
+ _predictorService.Create(predictor);
+ if (ChatHub.CheckUser(user._id))
+ await _ichat.Clients.Client(ChatHub.Users[user._id]).SendAsync("NotifyPredictor", predictor._id,model.name);
+ return CreatedAtAction(nameof(Get), new { id = predictor._id }, predictor);
+
}
// POST api/<PredictorController>/usepredictor {predictor,inputs}
[HttpPost("usepredictor/{id}")]
[Authorize(Roles = "User,Guest")]
- public ActionResult UsePredictor(String id, [FromBody] PredictorColumns[] inputs)
+ public async Task<ActionResult> UsePredictor(String id, [FromBody] PredictorColumns[] inputs)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- Predictor predictor = _predictorService.GetPredictor(username, id);
-
+ Predictor predictor = _predictorService.GetPredictor(userId, id);
+
+ Experiment e = _experimentService.Get(predictor.experimentId);
+
+ string result = await _mlConnectionService.Predict(predictor, e, inputs);
+
+ //salji ml
+
+ /*
foreach(PredictorColumns i in inputs)
- Debug.WriteLine(i.value.ToString());
- return NoContent();
+ Debug.WriteLine(i.value.ToString());*/
+ return Ok(result);
}
// PUT api/<PredictorController>/{name}
[HttpPut("{name}")]
[Authorize(Roles = "User")]
- public ActionResult Put(string name, [FromBody] Predictor predictor)
+ public ActionResult Put(string id, [FromBody] Predictor predictor)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var existingPredictor = _predictorService.GetOnePredictor(username, name);
+ var existingPredictor = _predictorService.GetOnePredictor(id);
//ne mora da se proverava
if (existingPredictor == null)
- return NotFound($"Predictor with name = {name} or user with username = {username} not found");
+ return NotFound($"Predictor with id = {id} or user with ID = {userId} not found");
- _predictorService.Update(username, name, predictor);
+ _predictorService.Update(id, predictor);
- return Ok($"Predictor with name = {name} updated");
+ return Ok($"Predictor with id = {id} updated");
}
// DELETE api/<PredictorController>/name
- [HttpDelete("{name}")]
+ [HttpDelete("{id}")]
[Authorize(Roles = "User")]
- public ActionResult Delete(string name)
+ public ActionResult Delete(string id)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var predictor = _predictorService.GetOnePredictor(username, name);
+ var predictor = _predictorService.GetOnePredictor(id);
if (predictor == null)
- return NotFound($"Predictor with name = {name} or user with username = {username} not found");
+ return NotFound($"Predictor with id = {id} or user with ID = {userId} not found");
- _predictorService.Delete(predictor.username, predictor.name);
+ _predictorService.Delete(id, userId);
- return Ok($"Predictor with name = {name} deleted");
+ return Ok($"Predictor with id = {id} deleted");
}
}
diff --git a/backend/api/api/Models/ColumnEncoding.cs b/backend/api/api/Models/ColumnEncoding.cs
new file mode 100644
index 00000000..2a2fce8b
--- /dev/null
+++ b/backend/api/api/Models/ColumnEncoding.cs
@@ -0,0 +1,14 @@
+namespace api.Models
+{
+ 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/Dataset.cs b/backend/api/api/Models/Dataset.cs
index 47814449..cc7185f0 100644
--- a/backend/api/api/Models/Dataset.cs
+++ b/backend/api/api/Models/Dataset.cs
@@ -7,7 +7,7 @@ namespace api.Models
public class Dataset
{
public Dataset() { }
- public string username { get; set; }
+ public string uploaderId { get; set; }
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]//mongo data type to .net
diff --git a/backend/api/api/Models/Experiment.cs b/backend/api/api/Models/Experiment.cs
index bf029116..f7bec083 100644
--- a/backend/api/api/Models/Experiment.cs
+++ b/backend/api/api/Models/Experiment.cs
@@ -10,7 +10,7 @@ namespace api.Models
public string _id { get; set; }
public string name { get; set; }
public string description { get; set; }
- public string encoding { get; set; }
+ public string type { get; set; }
public List<string> ModelIds { get; set; }
public string datasetId { get; set; }
public string uploaderId { get; set; }
@@ -21,6 +21,7 @@ namespace api.Models
public float randomTestSetDistribution { get; set; }
public string nullValues { get; set; }
public NullValues[] nullValuesReplacers { get; set; }
+ public ColumnEncoding[] encodings { get; set; }
}
}
diff --git a/backend/api/api/Models/Model.cs b/backend/api/api/Models/Model.cs
index 72ee093b..a9dbfbdd 100644
--- a/backend/api/api/Models/Model.cs
+++ b/backend/api/api/Models/Model.cs
@@ -9,7 +9,7 @@ namespace api.Models
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]//mongo data type to .net
public string _id { get; set; }
- public string username { get; set; }
+ public string uploaderId { get; set; }
public string name { get; set; }
diff --git a/backend/api/api/Models/Predictor.cs b/backend/api/api/Models/Predictor.cs
index b1d6444b..342c5b5d 100644
--- a/backend/api/api/Models/Predictor.cs
+++ b/backend/api/api/Models/Predictor.cs
@@ -9,25 +9,37 @@ namespace api.Models
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]//mongo data type to .net
public string _id { get; set; }
- public string username { get; set; }
- public string name { get; set; }
- public string description { get; set; }
+ public string uploaderId { get; set; }
+ //public string name { get; set; }
+ //public string description { get; set; }
public string[] inputs { get; set; }
public string output { get; set; }
public bool isPublic { get; set; }
public bool accessibleByLink { get; set; }
public DateTime dateCreated { get; set; }
public string experimentId { get; set; }
-
+ public string modelId { get; set; }
+ public string h5FileId { get; set; }
+ public Metric[] metrics { get; set; }
}
+
+ public class Metric
+ {
+ string Name { get; set; }
+ string JsonValue { get; set; }
+
+ }
}
-/*
+/**
+* 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"
@@ -36,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/Program.cs b/backend/api/api/Program.cs
index 576093fe..56abc016 100644
--- a/backend/api/api/Program.cs
+++ b/backend/api/api/Program.cs
@@ -39,7 +39,14 @@ builder.Services.AddScoped<IExperimentService, ExperimentService>();
builder.Services.AddHostedService<TempFileService>();
builder.Services.AddHostedService<FillAnEmptyDb>();
-
+//Ml Api Ip Filter
+builder.Services.AddScoped<MlApiCheckActionFilter>(container =>
+{
+ var loggerFactory = container.GetRequiredService<ILoggerFactory>();
+ var logger=loggerFactory.CreateLogger<MlApiCheckActionFilter>();
+ var MlIp = builder.Configuration.GetValue<string>("AppSettings:MlIp");
+ return new MlApiCheckActionFilter(MlIp, logger);
+});
@@ -64,11 +71,12 @@ builder.Services.Configure<FormOptions>(x =>
builder.Services.AddSignalR();
builder.Services.AddControllers();
-
+string frontApi = builder.Configuration.GetValue<string>("AppSettings:FrontApi");
+string mlApi = builder.Configuration.GetValue<string>("AppSettings:MlApi");
builder.Services.AddCors(options =>
{
options.AddPolicy("CorsPolicy", builder => builder
- .WithOrigins("http://localhost:4200")
+ .WithOrigins(frontApi, mlApi)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
diff --git a/backend/api/api/Properties/launchSettings.json b/backend/api/api/Properties/launchSettings.json
index 5c9dd2a8..f6c3fe8b 100644
--- a/backend/api/api/Properties/launchSettings.json
+++ b/backend/api/api/Properties/launchSettings.json
@@ -1,31 +1,23 @@
{
- "$schema": "https://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:61918",
- "sslPort": 0
- }
- },
- "profiles": {
- "api": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": false,
- "launchUrl": "",
- "applicationUrl": "http://localhost:5283",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:61918",
+ "sslPort": 0
+ }
},
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": false,
- "launchUrl": "",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
+ "profiles": {
+ "api": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": false,
+ "launchUrl": "",
+ "applicationUrl": "http://localhost:5283",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
}
- }
}
diff --git a/backend/api/api/Services/DatasetService.cs b/backend/api/api/Services/DatasetService.cs
index 176ab424..f260a1ba 100644
--- a/backend/api/api/Services/DatasetService.cs
+++ b/backend/api/api/Services/DatasetService.cs
@@ -14,7 +14,7 @@ namespace api.Services
_dataset = database.GetCollection<Dataset>(settings.DatasetCollectionName);
}
- public List<Dataset> SearchDatasets(string name, string username)
+ public List<Dataset> SearchDatasets(string name)
{
return _dataset.Find(dataset => dataset.name == name && dataset.isPublic == true && dataset.isPreProcess).ToList();
}
@@ -27,27 +27,27 @@ namespace api.Services
}
//brisanje odredjenog name-a
- public void Delete(string username, string name)
+ public void Delete(string userId, string id)
{
- _dataset.DeleteOne(dataset => (dataset.username == username && dataset.name == name));
+ _dataset.DeleteOne(dataset => (dataset.uploaderId == userId && dataset._id == id));
}
- public List<Dataset> GetMyDatasets(string username)
+ public List<Dataset> GetMyDatasets(string userId)
{
- return _dataset.Find(dataset => dataset.username == username && dataset.isPreProcess).ToList();
+ return _dataset.Find(dataset => dataset.uploaderId == userId && dataset.isPreProcess).ToList();
}
public List<Dataset> GetGuestDatasets()
{
//Join Igranonica public datasetove sa svim temp uploadanim datasetovima
- List<Dataset> datasets= _dataset.Find(dataset => dataset.username == "Igrannonica" && dataset.isPublic == true && dataset.isPreProcess).ToList();
- datasets.AddRange(_dataset.Find(dataset => dataset.username == "" && dataset.isPreProcess).ToList());
+ List<Dataset> datasets= _dataset.Find(dataset => dataset.uploaderId == "Igrannonica" && dataset.isPublic == true && dataset.isPreProcess).ToList();
+ datasets.AddRange(_dataset.Find(dataset => dataset.uploaderId == "" && dataset.isPreProcess).ToList());
return datasets;
}
//poslednji datasetovi
- public List<Dataset> SortDatasets(string username, bool ascdsc, int latest)
+ public List<Dataset> SortDatasets(string userId, bool ascdsc, int latest)
{
- List<Dataset> list = _dataset.Find(dataset => dataset.username == username && dataset.isPreProcess).ToList();
+ List<Dataset> list = _dataset.Find(dataset => dataset.uploaderId == userId && dataset.isPreProcess).ToList();
if(ascdsc)
list = list.OrderBy(dataset => dataset.lastUpdated).ToList();
@@ -62,9 +62,9 @@ namespace api.Services
return _dataset.Find(dataset => dataset.isPublic == true && dataset.isPreProcess).ToList();
}
- public Dataset GetOneDataset(string username, string name)
+ public Dataset GetOneDataset(string userId, string name)
{
- return _dataset.Find(dataset => dataset.username == username && dataset.name == name && dataset.isPreProcess).FirstOrDefault();
+ return _dataset.Find(dataset => dataset.uploaderId == userId && dataset.name == name && dataset.isPreProcess).FirstOrDefault();
}
//odraditi za pretragu getOne
@@ -74,9 +74,9 @@ namespace api.Services
}
//ako je potrebno da se zameni name ili ekstenzija
- public void Update(string username, string name, Dataset dataset )
+ public void Update(string userId, string id, Dataset dataset )
{
- _dataset.ReplaceOne(dataset => dataset.username == username && dataset.name == name, dataset);
+ _dataset.ReplaceOne(dataset => dataset.uploaderId == userId && dataset._id == id, dataset);
}
public void Update(Dataset dataset)
{
@@ -85,7 +85,7 @@ namespace api.Services
public string GetDatasetId(string fileId)
{
- Dataset dataset = _dataset.Find(dataset => dataset.fileId == fileId && dataset.username == "Igrannonica").FirstOrDefault();
+ Dataset dataset = _dataset.Find(dataset => dataset.fileId == fileId && dataset.uploaderId == "Igrannonica").FirstOrDefault();
return dataset._id;
}
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/IDatasetService.cs b/backend/api/api/Services/IDatasetService.cs
index c6138943..f493a2ec 100644
--- a/backend/api/api/Services/IDatasetService.cs
+++ b/backend/api/api/Services/IDatasetService.cs
@@ -5,15 +5,15 @@ namespace api.Services
{
public interface IDatasetService
{
- Dataset GetOneDataset(string username, string name);
+ Dataset GetOneDataset(string userId, string name);
Dataset GetOneDataset(string id);
- List<Dataset> SearchDatasets(string name, string username);
- List<Dataset> GetMyDatasets(string username);
- List<Dataset> SortDatasets(string username, bool ascdsc, int latest);
+ List<Dataset> SearchDatasets(string name);
+ List<Dataset> GetMyDatasets(string userId);
+ List<Dataset> SortDatasets(string userId, bool ascdsc, int latest);
List<Dataset> GetPublicDatasets();
Dataset Create(Dataset dataset);
- void Update(string username, string name, Dataset dataset);
- void Delete(string username, string name);
+ void Update(string userId, string id, Dataset dataset);
+ void Delete(string userId, string id);
public List<Dataset> GetGuestDatasets();
public void Update(Dataset dataset);
string GetDatasetId(string fileId);
diff --git a/backend/api/api/Services/IMlConnectionService.cs b/backend/api/api/Services/IMlConnectionService.cs
index d161bf49..d5dda9f2 100644
--- a/backend/api/api/Services/IMlConnectionService.cs
+++ b/backend/api/api/Services/IMlConnectionService.cs
@@ -8,6 +8,9 @@ namespace api.Services
Task<string> SendModelAsync(object model, object dataset);
Task PreProcess(Dataset dataset, string filePath,string id);
Task TrainModel(Model model, Experiment experiment, string filePath, Dataset dataset, string id);
+
+ Task<string> Predict(Predictor predictor, Experiment experiment, PredictorColumns[] inputs);
+
//Task<Dataset> PreProcess(Dataset dataset, byte[] file, string filename);
}
} \ No newline at end of file
diff --git a/backend/api/api/Services/IModelService.cs b/backend/api/api/Services/IModelService.cs
index e10b8f3b..00299979 100644
--- a/backend/api/api/Services/IModelService.cs
+++ b/backend/api/api/Services/IModelService.cs
@@ -5,16 +5,17 @@ namespace api.Services
{
public interface IModelService
{
- Model GetOneModel(string username, string name);
+ Model GetOneModel(string userId, string name);
Model GetOneModel(string id);
- List<Model> GetMyModels(string username);
- List<Model> GetLatestModels(string username);
+ List<Model> GetMyModels(string userId);
+ List<Model> GetMyModelsByType(string userId, string problemType);
+ List<Model> GetLatestModels(string userId);
//List<Model> GetPublicModels();
Model Create(Model model);
Model Replace(Model model);
- void Update(string username, string name, Model model);
+ void Update(string userId, string name, Model model);
public void Update(string id, Model model);
- void Delete(string username, string name);
+ void Delete(string userId, string name);
bool CheckHyperparameters(int inputNeurons, int hiddenLayerNeurons, int hiddenLayers, int outputNeurons);
bool CheckDb();
}
diff --git a/backend/api/api/Services/IPredictorService.cs b/backend/api/api/Services/IPredictorService.cs
index 729dd0b6..16f0432a 100644
--- a/backend/api/api/Services/IPredictorService.cs
+++ b/backend/api/api/Services/IPredictorService.cs
@@ -1,19 +1,16 @@
-using System;
-using api.Models;
+using api.Models;
namespace api.Services
{
- public interface IPredictorService
- {
- Predictor GetOnePredictor(string username, string name);
- Predictor GetPredictor(string username, string GetPredictor);
- List<Predictor> SearchPredictors(string name, string username);
- List<Predictor> GetMyPredictors(string username);
- List<Predictor> SortPredictors(string username, bool ascdsc, int latest);
- List<Predictor> GetPublicPredictors();
+ public interface IPredictorService
+ {
Predictor Create(Predictor predictor);
- void Update(string username, string name, Predictor predictor);
- void Delete(string username, string name);
+ void Delete(string id, string userId);
+ List<Predictor> GetMyPredictors(string userId);
+ Predictor GetOnePredictor(string id);
+ Predictor GetPredictor(string userId, string id);
+ List<Predictor> GetPublicPredictors();
+ List<Predictor> SortPredictors(string userId, bool ascdsc, int latest);
+ void Update(string id, Predictor predictor);
}
-}
-
+} \ No newline at end of file
diff --git a/backend/api/api/Services/MlApiCheckActionFilter.cs b/backend/api/api/Services/MlApiCheckActionFilter.cs
new file mode 100644
index 00000000..d1c020b0
--- /dev/null
+++ b/backend/api/api/Services/MlApiCheckActionFilter.cs
@@ -0,0 +1,50 @@
+using System.Net;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+
+namespace api.Services
+{
+ public class MlApiCheckActionFilter:ActionFilterAttribute
+ {
+ private readonly ILogger _logger;
+ private readonly string _safelist;
+
+ public MlApiCheckActionFilter(string safelist,ILogger logger)
+ {
+ _logger = logger;
+ _safelist = safelist;
+ }
+ public override void OnActionExecuting(ActionExecutingContext context)
+ {
+ var remoteIp = context.HttpContext.Connection.RemoteIpAddress;
+ _logger.LogDebug("Remote IpAddress: {RemoteIp}", remoteIp);
+ var ip = _safelist.Split(';');
+ var badIp = true;
+
+ if (remoteIp.IsIPv4MappedToIPv6)
+ {
+ remoteIp = remoteIp.MapToIPv4();
+ }
+
+ foreach (var address in ip)
+ {
+ var testIp = IPAddress.Parse(address);
+
+ if (testIp.Equals(remoteIp))
+ {
+ badIp = false;
+ break;
+ }
+ }
+
+ if (badIp)
+ {
+ _logger.LogWarning("Forbidden Request from IP: {RemoteIp}", remoteIp);
+ context.Result = new StatusCodeResult(StatusCodes.Status403Forbidden);
+ return;
+ }
+
+ base.OnActionExecuting(context);
+ }
+ }
+}
diff --git a/backend/api/api/Services/MlConnectionService.cs b/backend/api/api/Services/MlConnectionService.cs
index bde9ce4c..17c0f8b8 100644
--- a/backend/api/api/Services/MlConnectionService.cs
+++ b/backend/api/api/Services/MlConnectionService.cs
@@ -14,8 +14,9 @@ namespace api.Services
private readonly IModelService _modelService;
private readonly IHubContext<ChatHub> _ichat;
private readonly IConfiguration _configuration;
+ private readonly IFileService _fileService;
- public MlConnectionService(IConfiguration configuration,IDatasetService datasetService,IHubContext<ChatHub> ichat)
+ public MlConnectionService(IConfiguration configuration,IDatasetService datasetService,IHubContext<ChatHub> ichat, IFileService fileService)
{
_configuration = configuration;
@@ -23,6 +24,7 @@ namespace api.Services
_datasetService=datasetService;
_ichat=ichat;
+ _fileService = fileService;
}
public async Task<string> SendModelAsync(object model, object dataset)//Don't Use
@@ -41,11 +43,7 @@ namespace api.Services
//request.AddFile("file", file,filename);
request.AddFile("file", filePath);
request.AddHeader("Content-Type", "multipart/form-data");
- var result = await this.client.ExecuteAsync(request);
-
- if (ChatHub.CheckUser(id))
- await _ichat.Clients.Client(ChatHub.Users[id]).SendAsync("NotifyModel",model.name,model._id);
-
+ this.client.ExecuteAsync(request);
return;
}
@@ -67,8 +65,20 @@ namespace api.Services
}
-
+ public async Task<string> Predict(Predictor predictor, Experiment experiment, PredictorColumns[] inputs)
+ {
+ string filePath = _fileService.GetFilePath(predictor.h5FileId, predictor.uploaderId);
+ var request = new RestRequest("predict", Method.Post);
+ request.AddParameter("predictor", JsonConvert.SerializeObject(predictor));
+ request.AddParameter("experiment", JsonConvert.SerializeObject(experiment));
+ request.AddFile("file", filePath);
+ request.AddHeader("Content-Type", "multipart/form-data");
+
+ var result = await this.client.ExecuteAsync(request);
+ return result.Content;
+
+ }
}
}
diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs
index c21844f7..c35e5374 100644
--- a/backend/api/api/Services/ModelService.cs
+++ b/backend/api/api/Services/ModelService.cs
@@ -26,18 +26,22 @@ namespace api.Services
return model;
}
- public void Delete(string username, string name)
+ public void Delete(string userId, string name)
{
- _model.DeleteOne(model => (model.username == username && model.name == name));
+ _model.DeleteOne(model => (model.uploaderId == userId && model.name == name));
}
- public List<Model> GetMyModels(string username)
+ public List<Model> GetMyModels(string userId)
{
- return _model.Find(model => model.username == username).ToList();
+ return _model.Find(model => model.uploaderId == userId).ToList();
}
- public List<Model> GetLatestModels(string username)
+ public List<Model> GetMyModelsByType(string userId, string problemType)
{
- List<Model> list = _model.Find(model => model.username == username).ToList();
+ 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();
list = list.OrderByDescending(model => model.lastUpdated).ToList();
@@ -50,9 +54,9 @@ namespace api.Services
return _model.Find(model => model.isPublic == true).ToList();
}
*/
- public Model GetOneModel(string username, string name)
+ public Model GetOneModel(string userId, string name)
{
- return _model.Find(model => model.username == username && model.name == name).FirstOrDefault();
+ return _model.Find(model => model.uploaderId == userId && model.name == name).FirstOrDefault();
}
public Model GetOneModel(string id)
@@ -60,9 +64,9 @@ namespace api.Services
return _model.Find(model => model._id == id).FirstOrDefault();
}
- public void Update(string username, string name, Model model)
+ public void Update(string userId, string name, Model model)
{
- _model.ReplaceOne(model => model.username == username && model.name == name, model);
+ _model.ReplaceOne(model => model.uploaderId == userId && model.name == name, model);
}
public void Update(string id, Model model)
{
@@ -83,7 +87,7 @@ namespace api.Services
public bool CheckDb()
{
Model? model = null;
- model = _model.Find(model => model.username == "igrannonica").FirstOrDefault();
+ model = _model.Find(model => model.uploaderId == "Igrannonica").FirstOrDefault();
if (model != null)
return false;
diff --git a/backend/api/api/Services/PredictorService.cs b/backend/api/api/Services/PredictorService.cs
index b89eaded..756cc943 100644
--- a/backend/api/api/Services/PredictorService.cs
+++ b/backend/api/api/Services/PredictorService.cs
@@ -14,10 +14,6 @@ namespace api.Services
_predictor = database.GetCollection<Predictor>(settings.PredictorCollectionName);
}
- public List<Predictor> SearchPredictors(string name, string username)
- {
- return _predictor.Find(predictor => predictor.name == name && predictor.isPublic == true).ToList();
- }
public Predictor Create(Predictor predictor)
{
@@ -25,30 +21,30 @@ namespace api.Services
return predictor;
}
- public void Delete(string username, string name)
+ public void Delete(string id, string userId)
{
- _predictor.DeleteOne(predictor => (predictor.username == username && predictor.name == name));
+ _predictor.DeleteOne(predictor => (predictor._id == id && predictor.uploaderId == userId));
}
- public List<Predictor> GetMyPredictors(string username)
+ public List<Predictor> GetMyPredictors(string userId)
{
- return _predictor.Find(predictor => predictor.username == username).ToList();
+ return _predictor.Find(predictor => predictor.uploaderId == userId).ToList();
}
- public Predictor GetOnePredictor(string username, string name)
+ public Predictor GetOnePredictor(string id)
{
- return _predictor.Find(predictor => predictor.username == username && predictor.name == name).FirstOrDefault();
+ return _predictor.Find(predictor => predictor._id == id).FirstOrDefault();
}
- public Predictor GetPredictor(string username, string id)
+ public Predictor GetPredictor(string userId, string id)
{
- return _predictor.Find(predictor => predictor._id == id && (predictor.username == username || predictor.isPublic == true)).FirstOrDefault();
+ return _predictor.Find(predictor => predictor._id == id && (predictor.uploaderId == userId || predictor.isPublic == true)).FirstOrDefault();
}
- public List<Predictor> SortPredictors(string username, bool ascdsc, int latest)
+ public List<Predictor> SortPredictors(string userId, bool ascdsc, int latest)
{
- List<Predictor> list = _predictor.Find(predictor => predictor.username == username).ToList();
+ List<Predictor> list = _predictor.Find(predictor => predictor.uploaderId == userId).ToList();
if (ascdsc)
list = list.OrderBy(predictor => predictor.dateCreated).ToList();
@@ -62,9 +58,9 @@ namespace api.Services
return _predictor.Find(predictor => predictor.isPublic == true).ToList();
}
- public void Update(string username, string name, Predictor predictor)
+ public void Update(string id, Predictor predictor)
{
- _predictor.ReplaceOne(predictor => predictor.username == username && predictor.name == name, predictor);
+ _predictor.ReplaceOne(predictor => predictor._id == id, predictor);
}
}
}
diff --git a/backend/api/api/Services/TempRemovalService.cs b/backend/api/api/Services/TempRemovalService.cs
index e7f366a3..302ca974 100644
--- a/backend/api/api/Services/TempRemovalService.cs
+++ b/backend/api/api/Services/TempRemovalService.cs
@@ -27,7 +27,7 @@ namespace api.Services
if ((DateTime.Now.ToUniversalTime() - file.date).TotalDays >= 1)
{
DeleteFile(file._id);
- List<Dataset> datasets = _dataset.Find(dataset => dataset.fileId == file._id && dataset.username=="").ToList();
+ List<Dataset> datasets = _dataset.Find(dataset => dataset.fileId == file._id && dataset.uploaderId=="").ToList();
foreach(var dataset in datasets)
{
DeleteDataset(dataset._id);
@@ -37,7 +37,7 @@ namespace api.Services
DeleteExperiment(experiment._id);
foreach(var modelId in experiment.ModelIds)
{
- var delModel=_model.Find(model=> modelId== model._id && model.username=="").FirstOrDefault();
+ var delModel=_model.Find(model=> modelId== model._id && model.uploaderId=="").FirstOrDefault();
if(delModel!= null)
DeleteModel(delModel._id);
}
@@ -48,7 +48,7 @@ namespace api.Services
}
}
//Brisanje modela ukoliko gost koristi vec postojeci dataset
- List<Model> models1= _model.Find(model =>model.username == "").ToList();
+ List<Model> models1= _model.Find(model =>model.uploaderId == "").ToList();
foreach(var model in models1)
{
if ((DateTime.Now.ToUniversalTime() - model.dateCreated.ToUniversalTime()).TotalDays >= 1)
diff --git a/backend/api/api/Services/UserService.cs b/backend/api/api/Services/UserService.cs
index 7fc4bdb1..b53f5fdc 100644
--- a/backend/api/api/Services/UserService.cs
+++ b/backend/api/api/Services/UserService.cs
@@ -51,17 +51,17 @@ namespace api.Services
using (var session = _client.StartSession())
{
if(username!=user.Username)
- if(_users.Find(u => u.Username == user.Username).FirstOrDefault()!=null)
- {
- return false;
- }
+ if(_users.Find(u => u.Username == user.Username).FirstOrDefault()!=null)
+ {
+ return false;
+ }
//Trenutan MongoDB Server ne podrzava transakcije.Omoguciti Podrsku
//session.StartTransaction();
try
{
_users.ReplaceOne(user => user.Username == username, user);
- if (username != user.Username)
+ /*if (username != user.Username)
{
var builderModel = Builders<Model>.Update;
var builderDataset = Builders<Dataset>.Update;
@@ -70,7 +70,7 @@ namespace api.Services
_datasets.UpdateMany(x => x.username == username, builderDataset.Set(x => x.username, user.Username));
_predictors.UpdateMany(x => x.username == username, builderPredictor.Set(x => x.username, user.Username));
}
-
+ */
//session.AbortTransaction();
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/api/api/api.csproj b/backend/api/api/api.csproj
index 7275f67c..3d245333 100644
--- a/backend/api/api/api.csproj
+++ b/backend/api/api/api.csproj
@@ -21,6 +21,7 @@
</ItemGroup>
<ItemGroup>
+ <Folder Include="PredictorFiles\" />
<Folder Include="TempFiles\" />
</ItemGroup>
diff --git a/backend/api/api/appsettings.json b/backend/api/api/appsettings.json
index 42f62b75..c2310978 100644
--- a/backend/api/api/appsettings.json
+++ b/backend/api/api/appsettings.json
@@ -1,27 +1,29 @@
{
"AppSettings": {
"JwtToken": "2mnttqPtRb4GIWHFtagm",
- "MlApi": "http://127.0.0.1:5543"
+ "MlApi": "http://127.0.0.1:5543",
+ "FrontApi": "http://localhost:4200",
+ "MlIp":"127.0.0.1;::1"
},
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
- },
- "AllowedHosts": "*",
- "UserStoreDatabaseSettings": {
- /* LocalHost*/
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+ "UserStoreDatabaseSettings": {
+ /* LocalHost*/
- "ConnectionString": "mongodb://127.0.0.1:27017/",
- "DatabaseName": "si_project",
- "CollectionName": "users",
- "DatasetCollectionName": "Dataset",
- "ModelCollectionName": "Model",
- "PredictorCollectionName": "Predictor",
- "FilesCollectionName": "Files",
- "ExperimentCollectionName": "Experiment"
- /*
+ "ConnectionString": "mongodb://127.0.0.1:27017/",
+ "DatabaseName": "si_project",
+ "CollectionName": "users",
+ "DatasetCollectionName": "Dataset",
+ "ModelCollectionName": "Model",
+ "PredictorCollectionName": "Predictor",
+ "FilesCollectionName": "Files",
+ "ExperimentCollectionName": "Experiment"
+ /*
"ConnectionString": "mongodb+srv://si_user:si_user@sidatabase.twtfm.mongodb.net/myFirstDatabase?retryWrites=true&w=majority",
"DatabaseName": "si_db",
"CollectionName": "users",
@@ -30,5 +32,5 @@
"PredictorCollectionName": "Predictor",
"FilesCollectionName": "Files",
"ExperimentCollectionName": "Experiment" */
- }
+ }
} \ No newline at end of file