Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2389


Ignore:
Timestamp:
09/24/09 17:37:00 (15 years ago)
Author:
mkommend
Message:

adapted modeling database (ticket #759)

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/Model.cs

    r2371 r2389  
    4646    public int Id {
    4747      get { return this.id; }
    48       private set { this.id = value; }
     48      set { this.id = value; }
    4949    }
    5050
  • trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs

    r2384 r2389  
    9595    }
    9696
    97     public IModel CreateModel(ModelType modelType, IAlgorithm algorithm, IVariable targetVariable,
    98 int trainingSamplesStart, int trainingSamplesEnd, int validationSamplesStart, int validationSamplesEnd, int testSamplesStart, int testSamplesEnd) {
    99       return CreateModel(null, modelType, algorithm, targetVariable, trainingSamplesStart, trainingSamplesEnd, validationSamplesStart, validationSamplesEnd, testSamplesStart, testSamplesEnd);
     97    public IModel CreateModel(int id, string modelName, ModelType modelType, IAlgorithm algorithm, IVariable targetVariable,
     98        int trainingSamplesStart, int trainingSamplesEnd, int validationSamplesStart, int validationSamplesEnd, int testSamplesStart, int testSamplesEnd) {
     99      Model m = (Model)CreateModel(modelName, modelType, algorithm, targetVariable, trainingSamplesStart, trainingSamplesEnd, validationSamplesStart, validationSamplesEnd, testSamplesStart, testSamplesEnd);
     100      m.Id = id;
     101      return m;
    100102    }
    101103
     
    142144
    143145    public Dataset GetDataset() {
    144       if (ctx.Problems.Count() != 1)
    145         throw new InvalidOperationException("Could not get dataset. No or more than one problems are persisted in the database.");
    146       Problem problem = ctx.Problems.Single();
    147       return problem.Dataset;
     146      if (ctx.Problems.Count() > 1)
     147        throw new InvalidOperationException("Could not get dataset. More than one problems are persisted in the database.");
     148      if (ctx.Problems.Count() == 1)
     149        return ctx.Problems.Single().Dataset;
     150      return null;
    148151    }
    149152
     
    192195        ctx.SubmitChanges();
    193196      }
     197    }
     198
     199    public IInputVariable GetInputVariable(IModel model, string inputVariableName) {
     200      var inputVariables = ctx.InputVariables.Where(i => i.Model == model && i.Variable.Name == inputVariableName);
     201      if (inputVariables.Count() == 1)
     202        return inputVariables.Single();
     203
     204      if (inputVariables.Count() > 1)
     205        throw new ArgumentException("More than one input variable with the same name are for the given model persisted.");
     206
     207      return null;
    194208    }
    195209
     
    258272    }
    259273
    260     public void PersistModelResults(IModel model,IEnumerable<IModelResult> modelResults) {
     274    public void PersistModelResults(IModel model, IEnumerable<IModelResult> modelResults) {
    261275      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
    262276        ctx.ModelResults.DeleteAllOnSubmit(GetModelResults(model).Cast<ModelResult>());
     
    277291    }
    278292
    279     public void PersistInputVariableResults(IModel model,IEnumerable<IInputVariableResult> inputVariableResults) {
     293    public void PersistInputVariableResults(IModel model, IEnumerable<IInputVariableResult> inputVariableResults) {
    280294      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
    281295        ctx.InputVariableResults.DeleteAllOnSubmit(GetInputVariableResults(model).Cast<InputVariableResult>());
     
    306320
    307321    public IModel Persist(HeuristicLab.Modeling.IAnalyzerModel model, string algorithmName, string algorithmDescription) {
    308       Algorithm algorithm = (Algorithm) GetOrPersistAlgorithm(algorithmName);
    309       Variable targetVariable  = (Variable)GetVariable (model.TargetVariable);
    310 
    311       Model m = (Model)CreateModel(model.Type, algorithm, targetVariable, model.TrainingSamplesStart, model.TrainingSamplesEnd,
     322      Algorithm algorithm = (Algorithm)GetOrPersistAlgorithm(algorithmName);
     323      Variable targetVariable = (Variable)GetVariable(model.TargetVariable);
     324
     325      Model m = (Model)CreateModel(null, model.Type, algorithm, targetVariable, model.TrainingSamplesStart, model.TrainingSamplesEnd,
    312326        model.ValidationSamplesStart, model.ValidationSamplesEnd, model.TestSamplesStart, model.TestSamplesEnd);
    313327      PersistModel(m);
  • trunk/sources/HeuristicLab.Modeling.Database/3.2/IModel.cs

    r2382 r2389  
    2727namespace HeuristicLab.Modeling.Database {
    2828  public interface IModel {
     29    int Id { get; }
    2930    IVariable TargetVariable { get; }
    3031    IAlgorithm Algorithm { get; }
  • trunk/sources/HeuristicLab.Modeling.Database/3.2/IModelingDatabase.cs

    r2384 r2389  
    4242    IModel Persist(HeuristicLab.Modeling.IAnalyzerModel model, string algorithmName, string algorithmDescription);
    4343
    44     IModel CreateModel(ModelType modelType, IAlgorithm algorithm, IVariable targetVariable,
    45      int trainingSamplesStart, int trainingSamplesEnd, int validationSamplesStart, int validationSamplesEnd, int testSamplesStart, int testSamplesEnd);
    4644    IModel CreateModel(string modelName, ModelType modelType, IAlgorithm algorithm, IVariable targetVariable,
    4745      int trainingSamplesStart, int trainingSamplesEnd, int validationSamplesStart, int validationSamplesEnd, int testSamplesStart, int testSamplesEnd);
     46    IModel CreateModel(int id,string modelName, ModelType modelType, IAlgorithm algorithm, IVariable targetVariable,
     47    int trainingSamplesStart, int trainingSamplesEnd, int validationSamplesStart, int validationSamplesEnd, int testSamplesStart, int testSamplesEnd);
    4848    void PersistModel(IModel model);
    4949    void DeleteModel(IModel model);
     
    5555    IPredictor GetModelPredictor(IModel model);
    5656    void PersistPredictor(IModel model, IPredictor predictor);
     57    IInputVariable GetInputVariable(IModel model, string inputVariableName);
    5758
    5859    IAlgorithm GetOrPersistAlgorithm(string algorithmName);
Note: See TracChangeset for help on using the changeset viewer.