aboutsummaryrefslogtreecommitdiff
path: root/backend/api
diff options
context:
space:
mode:
Diffstat (limited to 'backend/api')
-rw-r--r--backend/api/api/Controllers/DatasetController.cs14
-rw-r--r--backend/api/api/Controllers/ExperimentController.cs35
-rw-r--r--backend/api/api/Controllers/ModelController.cs10
-rw-r--r--backend/api/api/Interfaces/IDatasetService.cs3
-rw-r--r--backend/api/api/Interfaces/IExperimentService.cs5
-rw-r--r--backend/api/api/Interfaces/IModelService.cs6
-rw-r--r--backend/api/api/Models/ColumnInfo.cs4
-rw-r--r--backend/api/api/Models/Dataset.cs1
-rw-r--r--backend/api/api/Models/Experiment.cs2
-rw-r--r--backend/api/api/Models/Model.cs5
-rw-r--r--backend/api/api/Services/DatasetService.cs31
-rw-r--r--backend/api/api/Services/ExperimentService.cs24
-rw-r--r--backend/api/api/Services/FillAnEmptyDb.cs82
-rw-r--r--backend/api/api/Services/ModelService.cs14
14 files changed, 156 insertions, 80 deletions
diff --git a/backend/api/api/Controllers/DatasetController.cs b/backend/api/api/Controllers/DatasetController.cs
index f61213c2..a6ebe8ac 100644
--- a/backend/api/api/Controllers/DatasetController.cs
+++ b/backend/api/api/Controllers/DatasetController.cs
@@ -18,14 +18,14 @@ namespace api.Controllers
private readonly IFileService _fileService;
private IJwtToken jwtToken;
- public DatasetController(IDatasetService datasetService, IConfiguration configuration,IJwtToken Token,IMlConnectionService mlConnectionService, IFileService fileService)
+ public DatasetController(IDatasetService datasetService, IConfiguration configuration, IJwtToken Token, IMlConnectionService mlConnectionService, IFileService fileService)
{
_datasetService = datasetService;
_mlConnectionService = mlConnectionService;
_fileService = fileService;
jwtToken = Token;
}
-
+
public string getUserId()
{
string userId;
@@ -116,7 +116,7 @@ namespace api.Controllers
if (userId == null)
return BadRequest();
- var dataset = _datasetService.GetOneDataset(userId, name);
+ var dataset = _datasetService.GetOneDatasetN(userId, name);
if (dataset == null)
return NotFound($"Dataset with name = {name} not found or dataset is not public or not preprocessed");
@@ -129,11 +129,13 @@ namespace api.Controllers
public async Task<ActionResult<Dataset>> Post([FromBody] Dataset dataset)
{
string uploaderId = getUserId();
-
+
+ dataset.uploaderId = uploaderId;
+
//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.uploaderId, dataset.name);
+ var existingDataset = _datasetService.GetOneDatasetN(dataset.uploaderId, dataset.name);
if (existingDataset != null)
return NotFound($"Dataset with this name already exists");
@@ -142,7 +144,7 @@ namespace api.Controllers
FileModel fileModel = _fileService.getFile(dataset.fileId);
dataset.isPreProcess = false;
_datasetService.Create(dataset);
- _mlConnectionService.PreProcess(dataset,fileModel.path,uploaderId);
+ _mlConnectionService.PreProcess(dataset, fileModel.path, uploaderId);
return Ok();
}
}
diff --git a/backend/api/api/Controllers/ExperimentController.cs b/backend/api/api/Controllers/ExperimentController.cs
index eecbe756..6f1bbd42 100644
--- a/backend/api/api/Controllers/ExperimentController.cs
+++ b/backend/api/api/Controllers/ExperimentController.cs
@@ -53,6 +53,7 @@ namespace api.Controllers
return BadRequest();
experiment.uploaderId = uploaderId;
+
var existingExperiment = _experimentService.Get(uploaderId, experiment.name);
if(existingExperiment != null)
return NotFound($"Experiment with this name exists");
@@ -99,17 +100,43 @@ namespace api.Controllers
if (uploaderId == null)
return BadRequest();
- var existingDataset = _experimentService.GetOneExperiment(uploaderId, id);
+ var existingExperiment = _experimentService.GetOneExperiment(uploaderId, id);
//ne mora da se proverava
- if (existingDataset == null)
+ if (existingExperiment == null)
return NotFound($"Experiment with ID = {id} or user with ID = {uploaderId} not found");
experiment.lastUpdated = DateTime.UtcNow;
- _experimentService.Update(uploaderId, id, experiment);
- return Ok($"Experiment with ID = {id} updated");
+ return Ok(_experimentService.Update(uploaderId, id, experiment));
}
+
+ // DELETE api/<ExperimentController>/name
+ [HttpDelete("{id}")]
+ [Authorize(Roles = "User")]
+ public ActionResult Delete(string id)
+ {
+ string uploaderId = getUserId();
+
+ if (uploaderId == null)
+ return BadRequest();
+
+ var experiment = _experimentService.GetOneExperiment(uploaderId, id);
+
+ if (experiment == null)
+ return NotFound($"Experiment with ID = {id} or user with ID = {uploaderId} not found");
+
+ _experimentService.Delete(experiment.uploaderId, experiment._id);
+
+ return Ok($"Experiment with ID = {id} deleted");
+
+ }
+
+ public void DeleteHelper(string uploaderId, string experimentId)
+ {
+ _experimentService.Delete(uploaderId, experimentId);
+ }
+
}
}
diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs
index 1c1ea364..a0e51e1f 100644
--- a/backend/api/api/Controllers/ModelController.cs
+++ b/backend/api/api/Controllers/ModelController.cs
@@ -91,10 +91,12 @@ namespace api.Controllers
return Ok();
}
-
-
-
-
+ // GET: api/<ModelController>/publicmodels
+ [HttpGet("publicmodels")]
+ public ActionResult<List<Model>> GetPublicModels()
+ {
+ return _modelService.GetPublicModels();
+ }
// GET: api/<ModelController>/mymodels
[HttpGet("mymodels")]
diff --git a/backend/api/api/Interfaces/IDatasetService.cs b/backend/api/api/Interfaces/IDatasetService.cs
index f493a2ec..2f7d0010 100644
--- a/backend/api/api/Interfaces/IDatasetService.cs
+++ b/backend/api/api/Interfaces/IDatasetService.cs
@@ -5,7 +5,8 @@ namespace api.Services
{
public interface IDatasetService
{
- Dataset GetOneDataset(string userId, string name);
+ Dataset GetOneDataset(string userId, string id);
+ Dataset GetOneDatasetN(string userId, string name);
Dataset GetOneDataset(string id);
List<Dataset> SearchDatasets(string name);
List<Dataset> GetMyDatasets(string userId);
diff --git a/backend/api/api/Interfaces/IExperimentService.cs b/backend/api/api/Interfaces/IExperimentService.cs
index 2a69cff9..7e59ace3 100644
--- a/backend/api/api/Interfaces/IExperimentService.cs
+++ b/backend/api/api/Interfaces/IExperimentService.cs
@@ -8,8 +8,9 @@ namespace api.Services
public Experiment Get(string id);
public List<Experiment> GetMyExperiments(string id);
public Experiment Get(string uploaderId, string name);
- Experiment GetOneExperiment(string userId, string name);
- void Update(string userId, string id, Experiment experiment);
+ Experiment GetOneExperiment(string userId, string id);
+ Experiment Update(string userId, string id, Experiment experiment);
+ void Delete(string userId, string id);
}
} \ No newline at end of file
diff --git a/backend/api/api/Interfaces/IModelService.cs b/backend/api/api/Interfaces/IModelService.cs
index 00299979..8c4543de 100644
--- a/backend/api/api/Interfaces/IModelService.cs
+++ b/backend/api/api/Interfaces/IModelService.cs
@@ -3,14 +3,14 @@ using api.Models;
namespace api.Services
{
- public interface IModelService
- {
+ public interface IModelService
+ {
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();
+ List<Model> GetPublicModels();
Model Create(Model model);
Model Replace(Model model);
void Update(string userId, string name, Model model);
diff --git a/backend/api/api/Models/ColumnInfo.cs b/backend/api/api/Models/ColumnInfo.cs
index dcf5171c..46aeadb6 100644
--- a/backend/api/api/Models/ColumnInfo.cs
+++ b/backend/api/api/Models/ColumnInfo.cs
@@ -4,10 +4,9 @@
{
public ColumnInfo() { }
- public ColumnInfo(string columnName, string columnType, bool isNumber, int numNulls, float mean, float min, float max, float median, string[] uniqueValues, int[]uniqueValuesCount, float[] uniqueValuesPercent, float q1, float q3)
+ public ColumnInfo(string columnName, bool isNumber, int numNulls, float mean, float min, float max, float median, string[] uniqueValues, int[]uniqueValuesCount, float[] uniqueValuesPercent, float q1, float q3)
{
this.columnName = columnName;
- this.columnType = columnType;
this.isNumber = isNumber;
this.numNulls = numNulls;
this.mean = mean;
@@ -22,7 +21,6 @@
}
public string columnName { get; set; }
- public string columnType { get; set; }
public bool isNumber { get; set; }
public int numNulls { get; set; }
public float mean { get; set; }
diff --git a/backend/api/api/Models/Dataset.cs b/backend/api/api/Models/Dataset.cs
index 7acd4382..beb66de9 100644
--- a/backend/api/api/Models/Dataset.cs
+++ b/backend/api/api/Models/Dataset.cs
@@ -28,6 +28,7 @@ namespace api.Models
public int nullRows { get; set; }
public bool isPreProcess { get; set; }
+ public float[][] cMatrix { get; set; }
}
}
diff --git a/backend/api/api/Models/Experiment.cs b/backend/api/api/Models/Experiment.cs
index 3af063be..d98e6cfc 100644
--- a/backend/api/api/Models/Experiment.cs
+++ b/backend/api/api/Models/Experiment.cs
@@ -21,6 +21,6 @@ namespace api.Models
public DateTime lastUpdated { get; set; }
public NullValues[] nullValuesReplacers { get; set; }
public ColumnEncoding[] encodings { get; set; }
-
+ public string[] columnTypes { get; set; }
}
}
diff --git a/backend/api/api/Models/Model.cs b/backend/api/api/Models/Model.cs
index d8921713..a2740ca9 100644
--- a/backend/api/api/Models/Model.cs
+++ b/backend/api/api/Models/Model.cs
@@ -27,7 +27,8 @@ namespace api.Models
public string lossFunction { get; set; }
//public int inputNeurons { get; set; }
public int hiddenLayers { get; set; }
- public int batchSize { get; set; }
+ public string batchSize { get; set; }
+ public string learningRate { get; set; }
// na izlazu je moguce da bude vise neurona (klasifikacioni problem sa vise od 2 klase)
public int outputNeurons { get; set; }
public Layer[] layers { get; set; }
@@ -40,6 +41,8 @@ namespace api.Models
public bool randomOrder { get; set; }
public bool randomTestSet { get; set; }
public float randomTestSetDistribution { get; set; }
+ public bool isPublic { get; set; }
+ public bool accessibleByLink { get; set; }
}
public class Layer
diff --git a/backend/api/api/Services/DatasetService.cs b/backend/api/api/Services/DatasetService.cs
index f39cac29..f38a363b 100644
--- a/backend/api/api/Services/DatasetService.cs
+++ b/backend/api/api/Services/DatasetService.cs
@@ -1,4 +1,5 @@
-using api.Interfaces;
+using api.Controllers;
+using api.Interfaces;
using api.Models;
using MongoDB.Driver;
@@ -7,11 +8,15 @@ namespace api.Services
public class DatasetService : IDatasetService
{
private readonly IMongoCollection<Dataset> _dataset;
+ private readonly IMongoCollection<Experiment> _experiment;
+ private readonly IExperimentService _experimentService;
- public DatasetService(IUserStoreDatabaseSettings settings, IMongoClient mongoClient)
+ public DatasetService(IUserStoreDatabaseSettings settings, IMongoClient mongoClient, IExperimentService experimentService)
{
var database = mongoClient.GetDatabase(settings.DatabaseName);
_dataset = database.GetCollection<Dataset>(settings.DatasetCollectionName);
+ _experiment = database.GetCollection<Experiment>(settings.ExperimentCollectionName);
+ _experimentService = experimentService;
}
public List<Dataset> SearchDatasets(string name)
@@ -29,7 +34,13 @@ namespace api.Services
//brisanje odredjenog name-a
public void Delete(string userId, string id)
{
- _dataset.DeleteOne(dataset => (dataset.uploaderId == userId && dataset._id == id));
+ List<Experiment> experiment = null;
+ _dataset.DeleteOne(dataset => (dataset.uploaderId == userId && dataset._id == id));
+
+ experiment = _experiment.Find(experiment => (experiment.datasetId == id && experiment.uploaderId == userId)).ToList();
+
+ foreach (Experiment experimentItem in experiment)
+ _experimentService.Delete(userId, experimentItem._id);
}
public List<Dataset> GetMyDatasets(string userId)
@@ -39,7 +50,7 @@ namespace api.Services
public List<Dataset> GetGuestDatasets()
{
//Join Igranonica public datasetove sa svim temp uploadanim datasetovima
- List<Dataset> datasets= _dataset.Find(dataset => dataset.uploaderId == "000000000000000000000000" && dataset.isPublic == true && dataset.isPreProcess).ToList();
+ List<Dataset> datasets = _dataset.Find(dataset => dataset.uploaderId == "000000000000000000000000" && dataset.isPublic == true && dataset.isPreProcess).ToList();
datasets.AddRange(_dataset.Find(dataset => dataset.uploaderId == "" && dataset.isPreProcess).ToList());
return datasets;
}
@@ -49,7 +60,7 @@ namespace api.Services
{
List<Dataset> list = _dataset.Find(dataset => dataset.uploaderId == userId && dataset.isPreProcess).ToList();
- if(ascdsc)
+ if (ascdsc)
list = list.OrderBy(dataset => dataset.lastUpdated).ToList();
else
list = list.OrderByDescending(dataset => dataset.lastUpdated).ToList();
@@ -62,7 +73,11 @@ namespace api.Services
return _dataset.Find(dataset => dataset.isPublic == true && dataset.isPreProcess).ToList();
}
- public Dataset GetOneDataset(string userId, string name)
+ public Dataset GetOneDataset(string userId, string id)
+ {
+ return _dataset.Find(dataset => dataset.uploaderId == userId && dataset._id == id && dataset.isPreProcess).FirstOrDefault();
+ }
+ public Dataset GetOneDatasetN(string userId, string name)
{
return _dataset.Find(dataset => dataset.uploaderId == userId && dataset.name == name && dataset.isPreProcess).FirstOrDefault();
}
@@ -74,13 +89,13 @@ namespace api.Services
}
//ako je potrebno da se zameni name ili ekstenzija
- public void Update(string userId, string id, Dataset dataset )
+ public void Update(string userId, string id, Dataset dataset)
{
_dataset.ReplaceOne(dataset => dataset.uploaderId == userId && dataset._id == id, dataset);
}
public void Update(Dataset dataset)
{
- _dataset.ReplaceOne(x=>x._id==dataset._id, dataset);
+ _dataset.ReplaceOne(x => x._id == dataset._id, dataset);
}
public string GetDatasetId(string fileId)
diff --git a/backend/api/api/Services/ExperimentService.cs b/backend/api/api/Services/ExperimentService.cs
index 539e4c08..dde9111d 100644
--- a/backend/api/api/Services/ExperimentService.cs
+++ b/backend/api/api/Services/ExperimentService.cs
@@ -7,10 +7,13 @@ namespace api.Services
public class ExperimentService : IExperimentService
{
private readonly IMongoCollection<Experiment> _experiment;
+ private readonly IMongoCollection<Predictor> _predictor;
+
public ExperimentService(IUserStoreDatabaseSettings settings, IMongoClient mongoClient)
{
var database = mongoClient.GetDatabase(settings.DatabaseName);
_experiment = database.GetCollection<Experiment>(settings.ExperimentCollectionName);
+ _predictor = database.GetCollection<Predictor>(settings.PredictorCollectionName);
}
public Experiment Create(Experiment experiment)
@@ -20,31 +23,38 @@ namespace api.Services
}
public Experiment Get(string id)
{
- return _experiment.Find(exp=>exp._id == id).FirstOrDefault();
+ return _experiment.Find(exp => exp._id == id).FirstOrDefault();
}
public Experiment Get(string uploaderId, string name)
{
- return _experiment.Find(exp => exp.uploaderId == uploaderId && exp.name == name ).FirstOrDefault();
+ return _experiment.Find(exp => exp.uploaderId == uploaderId && exp.name == name).FirstOrDefault();
}
public void Update(string id, Experiment experiment)
{
_experiment.ReplaceOne(experiment => experiment._id == id, experiment);
}
- public List<Experiment> GetMyExperiments(string id)
+ public List<Experiment> GetMyExperiments(string userId)
{
- return _experiment.Find(e=>e.uploaderId==id).ToList();
+ return _experiment.Find(experiment => experiment.uploaderId == userId).ToList();
}
- public Experiment GetOneExperiment(string userId, string name)
+ public Experiment GetOneExperiment(string userId, string id)
{
- return _experiment.Find(experiment => experiment.uploaderId == userId && experiment.name == name).FirstOrDefault();
+ return _experiment.Find(experiment => experiment.uploaderId == userId && experiment._id == id).FirstOrDefault();
}
- public void Update(string userId, string id, Experiment experiment)
+ public Experiment Update(string userId, string id, Experiment experiment)
{
_experiment.ReplaceOne(experiment => experiment.uploaderId == userId && experiment._id == id, experiment);
+ return _experiment.Find(experiment => experiment.uploaderId == userId && experiment._id == id).FirstOrDefault();
+ }
+
+ public void Delete(string userId, string id)
+ {
+ _experiment.DeleteOne(experiment => (experiment.uploaderId == userId && experiment._id == id));
+ _predictor.DeleteMany(predictor => (predictor.uploaderId == userId && predictor.experimentId == id));
}
}
}
diff --git a/backend/api/api/Services/FillAnEmptyDb.cs b/backend/api/api/Services/FillAnEmptyDb.cs
index 99bbb91f..520f3461 100644
--- a/backend/api/api/Services/FillAnEmptyDb.cs
+++ b/backend/api/api/Services/FillAnEmptyDb.cs
@@ -19,9 +19,9 @@ namespace api.Services
var database = mongoClient.GetDatabase(settings.DatabaseName);
_fileService = new FileService(settings, mongoClient);
- _datasetService = new DatasetService(settings, mongoClient);
- _modelService = new ModelService(settings, mongoClient);
_experimentService = new ExperimentService(settings, mongoClient);
+ _datasetService = new DatasetService(settings, mongoClient, _experimentService);
+ _modelService = new ModelService(settings, mongoClient);
_predictorService = new PredictorService(settings, mongoClient);
}
@@ -66,18 +66,18 @@ namespace api.Services
dataset.columnInfo = new[]
{
- new ColumnInfo( "PassengerId", "columnType", true, 0, 446, 1, 891, 446, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Survived", "columnType", true, 0, 0.38383838534355164f, 0, 1, 0, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Pclass", "columnType", true, 0, 2.3086419105529785f, 1, 3, 3, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Name", "columnType", 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 int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Sex", "columnType", false, 0, 0, 0, 0, 0, new string[]{ "male", "female" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Age", "columnType", true, 177, 29.69911766052246f, 0.41999998688697815f, 80, 28, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "SibSp", "columnType", true, 0, 0.523007869720459f, 0, 8, 0, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Parch", "columnType", true, 0, 0.3815937042236328f, 0, 6, 0, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Ticket", "columnType", 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 int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Fare", "columnType", true, 0, 32.20420837402344f, 0, 512.3292236328125f, 14.45419979095459f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Cabin", "columnType", false, 687, 0, 0, 0, 0, new string[]{ "B96 B98", "G6", "C23 C25 C27", "C22 C26", "F33", "F2", "E101", "D", "C78", "C93" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "Embarked", "columnType", false, 2, 0.3815937042236328f, 0, 6, 0, new string[]{ "S", "C", "Q" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "PassengerId", true, 0, 446, 1, 891, 446, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "Survived", true, 0, 0.38383838534355164f, 0, 1, 0, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "Pclass", true, 0, 2.3086419105529785f, 1, 3, 3, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ 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 int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "Sex", false, 0, 0, 0, 0, 0, new string[]{ "male", "female" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "Age", true, 177, 29.69911766052246f, 0.41999998688697815f, 80, 28, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "SibSp", true, 0, 0.523007869720459f, 0, 8, 0, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "Parch", true, 0, 0.3815937042236328f, 0, 6, 0, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ 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 int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "Fare", true, 0, 32.20420837402344f, 0, 512.3292236328125f, 14.45419979095459f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ 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 int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "Embarked", false, 2, 0.3815937042236328f, 0, 6, 0, new string[]{ "S", "C", "Q" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
};
dataset.rowCount = 891;
dataset.nullCols = 3;
@@ -99,11 +99,13 @@ namespace api.Services
model.optimizer = "Adam";
model.lossFunction = "mean_squared_error";
model.hiddenLayers = 5;
- model.batchSize = 8;
+ model.batchSize = "8";
model.outputNeurons = 0;
model.outputLayerActivationFunction = "sigmoid";
model.metrics = new string[] { };
model.epochs = 5;
+ model.isPublic = true;
+ model.accessibleByLink = true;
_modelService.Create(model);
@@ -116,7 +118,7 @@ namespace api.Services
experiment.ModelIds = new string[] { }.ToList();
experiment.datasetId = _datasetService.GetDatasetId(dataset.fileId);
experiment.uploaderId = "000000000000000000000000";
- experiment.inputColumns = new string[] { "Embarked" };
+ experiment.inputColumns = new string[] { "Embarked", "Survived" };
experiment.outputColumn = "Survived";
experiment.dateCreated = DateTime.Now;
experiment.lastUpdated = DateTime.Now;
@@ -127,6 +129,7 @@ namespace api.Services
new ColumnEncoding( "Survived", "label" ),
new ColumnEncoding("Embarked", "label" )
};
+ experiment.columnTypes = new string[] {"categorical"};
_experimentService.Create(experiment);
@@ -177,17 +180,17 @@ namespace api.Services
dataset.delimiter = "";
dataset.columnInfo = new[]
{
- new ColumnInfo( "Unnamed: 0", "columnType", true, 0, 26969.5f, 0, 53939, 26969.5f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "carat", "columnType", true, 0, 0.7979397773742676f, 0.20000000298023224f, 5.010000228881836f, 0.699999988079071f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "cut", "columnType", false, 0, 0, 0, 0, 0, new string[]{ "Ideal", "Premium", "Very Good", "Good", "Fair" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "color", "columnType", false, 0, 0, 0, 0, 0, new string[]{"G", "E", "F", "H", "D", "I", "I", "J"}, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "clarity", "columnType", false, 0, 0, 0, 0, 0, new string[]{ "SI1", "VS2","SI2", "VS1", "VVS2", "VVS1", "IF", "I1" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "depth", "columnType", true, 0, 61.74940490722656f, 43, 79, 61.79999923706055f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "table", "columnType", true, 0, 57.457183837890625f, 43, 95, 57, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "price", "columnType", true, 0, 3932.7998046875f, 326, 18823, 2401, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "x", "columnType", true, 0, 5.731157302856445f, 0, 10.739999771118164f, 5.699999809265137f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "y", "columnType", true, 0, 5.73452615737915f, 0, 58.900001525878906f, 5.710000038146973f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "z", "columnType", true, 0, 3.538733720779419f, 0, 31.799999237060547f, 3.5299999713897705f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f )
+ new ColumnInfo( "Unnamed: 0", true, 0, 26969.5f, 0, 53939, 26969.5f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "carat", true, 0, 0.7979397773742676f, 0.20000000298023224f, 5.010000228881836f, 0.699999988079071f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "cut", false, 0, 0, 0, 0, 0, new string[]{ "Ideal", "Premium", "Very Good", "Good", "Fair" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "color", false, 0, 0, 0, 0, 0, new string[]{"G", "E", "F", "H", "D", "I", "I", "J"}, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "clarity", false, 0, 0, 0, 0, 0, new string[]{ "SI1", "VS2","SI2", "VS1", "VVS2", "VVS1", "IF", "I1" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "depth", true, 0, 61.74940490722656f, 43, 79, 61.79999923706055f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "table", true, 0, 57.457183837890625f, 43, 95, 57, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "price", true, 0, 3932.7998046875f, 326, 18823, 2401, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "x", true, 0, 5.731157302856445f, 0, 10.739999771118164f, 5.699999809265137f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "y", true, 0, 5.73452615737915f, 0, 58.900001525878906f, 5.710000038146973f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "z", true, 0, 3.538733720779419f, 0, 31.799999237060547f, 3.5299999713897705f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f )
};
dataset.rowCount = 53940;
dataset.nullCols = 0;
@@ -210,11 +213,13 @@ namespace api.Services
model.optimizer = "Adam";
model.lossFunction = "mean_absolute_error";
model.hiddenLayers = 4;
- model.batchSize = 5;
+ model.batchSize = "8";
model.outputNeurons = 0;
model.outputLayerActivationFunction = "relu";
model.metrics = new string[] { };
model.epochs = 5;
+ model.isPublic = true;
+ model.accessibleByLink = true;
_modelService.Create(model);
@@ -227,7 +232,7 @@ namespace api.Services
experiment.ModelIds = new string[] { }.ToList();
experiment.datasetId = _datasetService.GetDatasetId(dataset.fileId);
experiment.uploaderId = "000000000000000000000000";
- experiment.inputColumns = new string[] { "Unnamed: 0", "carat", "cut", "color", "clarity", "depth", "table", "x", "y", "z" };
+ experiment.inputColumns = new string[] { "Unnamed: 0", "carat", "cut", "color", "clarity", "depth", "table", "x", "y", "z", "price" };
experiment.outputColumn = "price";
experiment.dateCreated = DateTime.Now;
experiment.lastUpdated = DateTime.Now;
@@ -247,6 +252,7 @@ namespace api.Services
new ColumnEncoding( "y", "label" ),
new ColumnEncoding( "z", "label" )
};
+ experiment.columnTypes = new string[] { "categorical", "numerical", "numerical", "categorical", "categorical", "categorical", "numerical", "numerical", "numerical", "numerical", "numerical" };
_experimentService.Create(experiment);
/*
@@ -291,11 +297,11 @@ namespace api.Services
dataset.delimiter = "";
dataset.columnInfo = new[]
{
- new ColumnInfo( "sepal_length", "columnType", true, 0, 5.8433332443237305f, 4.300000190734863f, 7.900000095367432f, 5.800000190734863f, new string[]{ }, new int[] {}, new float[] {}, 0.01f, 0.1f ),
- new ColumnInfo( "sepal_width", "columnType", true, 0, 3.053999900817871f, 2, 4.400000095367432f, 3, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "petal_length", "columnType", true, 0, 3.758666753768921f, 1, 6.900000095367432f, 4.349999904632568f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "petal_width", "columnType", true, 0, 1.1986666917800903f, 0.10000000149011612f, 2.5f, 1.2999999523162842f, new string[]{}, new int[] {}, new float[] {}, 0.01f,0.1f ),
- new ColumnInfo( "class", "columnType", false, 0, 0, 0, 0, 0, new string[]{ "Iris-setosa", "Iris-versicolor", "Iris-virginica" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "sepal_length", true, 0, 5.8433332443237305f, 4.300000190734863f, 7.900000095367432f, 5.800000190734863f, new string[]{ }, new int[] {}, new float[] {}, 0.01f, 0.1f ),
+ new ColumnInfo( "sepal_width", true, 0, 3.053999900817871f, 2, 4.400000095367432f, 3, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "petal_length", true, 0, 3.758666753768921f, 1, 6.900000095367432f, 4.349999904632568f, new string[]{ }, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "petal_width", true, 0, 1.1986666917800903f, 0.10000000149011612f, 2.5f, 1.2999999523162842f, new string[]{}, new int[] {}, new float[] {}, 0.01f,0.1f ),
+ new ColumnInfo( "class", false, 0, 0, 0, 0, 0, new string[]{ "Iris-setosa", "Iris-versicolor", "Iris-virginica" }, new int[] {}, new float[] {}, 0.01f,0.1f ),
};
dataset.nullCols = 150;
dataset.nullRows = 0;
@@ -316,11 +322,13 @@ namespace api.Services
model.optimizer = "Adam";
model.lossFunction = "sparse_categorical_crossentropy";
model.hiddenLayers = 3;
- model.batchSize = 4;
+ model.batchSize = "64";
model.outputNeurons = 0;
model.outputLayerActivationFunction = "softmax";
model.metrics = new string[] { };
model.epochs = 1;
+ model.isPublic = true;
+ model.accessibleByLink = true;
_modelService.Create(model);
@@ -333,7 +341,7 @@ namespace api.Services
experiment.ModelIds = new string[] { }.ToList();
experiment.datasetId = _datasetService.GetDatasetId(dataset.fileId);
experiment.uploaderId = "000000000000000000000000";
- experiment.inputColumns = new string[] { "sepal_length", "sepal_width", "petal_length", "petal_width" };
+ experiment.inputColumns = new string[] { "sepal_length", "sepal_width", "petal_length", "petal_width", "class" };
experiment.outputColumn = "class";
experiment.dateCreated = DateTime.Now;
experiment.lastUpdated = DateTime.Now;
@@ -347,6 +355,8 @@ namespace api.Services
new ColumnEncoding( "petal_width", "label" ),
new ColumnEncoding( "class", "label" )
};
+ experiment.columnTypes = new string[] { "categorical", "numerical", "numerical", "numerical", "categorical" };
+
_experimentService.Create(experiment);
/*
diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs
index 12297635..e852d71f 100644
--- a/backend/api/api/Services/ModelService.cs
+++ b/backend/api/api/Services/ModelService.cs
@@ -5,14 +5,16 @@ using MongoDB.Driver;
namespace api.Services
{
- public class ModelService : IModelService
+ public class ModelService : IModelService
{
private readonly IMongoCollection<Model> _model;
+ private readonly IMongoCollection<Predictor> _predictor;
public ModelService(IUserStoreDatabaseSettings settings, IMongoClient mongoClient)
{
var database = mongoClient.GetDatabase(settings.DatabaseName);
_model = database.GetCollection<Model>(settings.ModelCollectionName);
+ _predictor = database.GetCollection<Predictor>(settings.PredictorCollectionName);
}
public Model Create(Model model)
@@ -28,7 +30,11 @@ namespace api.Services
public void Delete(string userId, string name)
{
+ Model model = _model.Find(model => model.uploaderId == userId && model.name == name).FirstOrDefault();
+
_model.DeleteOne(model => (model.uploaderId == userId && model.name == name));
+ _predictor.DeleteMany(predictor => (predictor.uploaderId == userId && predictor.modelId == model._id));
+
}
public List<Model> GetMyModels(string userId)
@@ -48,12 +54,12 @@ namespace api.Services
return list;
}
- /*
+
public List<Model> GetPublicModels()
{
return _model.Find(model => model.isPublic == true).ToList();
}
- */
+
public Model GetOneModel(string userId, string name)
{
return _model.Find(model => model.uploaderId == userId && model.name == name).FirstOrDefault();
@@ -93,7 +99,7 @@ namespace api.Services
return false;
else
return true;
-
+
}
}
}