Coder Social home page Coder Social logo

Comments (4)

michael-smirnov avatar michael-smirnov commented on September 13, 2024

@Denzzel @juraam @KarpenkoSergey @Destrouer @Nikita94
Предлагаю к обсуждению первый вариант архитектуры системы.

1. Интерфейс для долгих процессов

Такие процессы, как обучение решателей, чтение выборок из внешних файлов, загрузка выборок из БД могут выполняться достаточно долгое время. Такие процессы должны предоставлять возможность визуализации прогресса своей работы. Интерфейс, представленный ниже, предоставляет возможность подписаться на событие изменения прогресса текущей работы. Подписавшийся объект получает ссылку на объект, чье состояние изменилось (это sender) и текущее состояние прогресса в виде обобщенного типа T. Для простых событий проще всего сделать T=int, значения которого пробегают от 0 до 100 (процент завершенных действий), однако для процесса обучения T может быть сложным объектом, предоставляющим информацию не только о проценте завершенной работы:

public delegate void GenericProgress<T>(object sender, T progress);

public interface INotifyProgressChanged<T>
{
   event GenericProgress<T> ProgressChanged;
}

2. Интерфейс для загрузки выборок из внешних хранилищ

public interface IDataLoader: INotifyProgressChanged<int>
{
   DataSet Download(System.IO.Stream source);
   void Upload(DataSet data, System.IO.Stream destination);
}

3. Интерфейсы для задач

public class TaskTemplate
{
   public int XSize { get; private set; }
   public string[] XTypes { get; private set; }
   public string[] XNames { get; private set; }

   public int YSize { get; private set; }
   public string[] YTypes { get; private set; }
   public string[] YNames { get; private set; }

   public void AddX(string name, string type);
   public void AddY(string name, string type);

   public void RemoveX(string name);
   public void RemoveY(string name);
   public override bool Equals(object obj);
}

public static class AttributeFactory
{
   public static string[] AttributeTypes { get; private set; };
   public static IAttribute CreateAttribute(string name, string type);
   public static string GetTypeOf(IAttribute attribute);
}

public interface IAttribute
{
  string Name { get; }
  double Value { get; set; }
}

4. Интерфейсы для выборок

public class AttributeVector
{
   public int Size { get; private set; }
   public IAttribute this[int index] { get; private set;}
   public IAttribute this[string name] { get; private set;}

   public int XSize { get; private set;}
   public int YSize { get; private set;}
   public IAttribute[] X { get; private set;}
   public IAttribute[] Y { get; private set;}

   public void AddX(IAttribute attribute);
   public void AddY(IAttribute attribute);

   public void RemoveX(string name);
   public void RemoveY(string name);
}

public class DataSet
{
   public DataSet(TaskTemplate task);
   public int Size { get; private set; }
   public TaskTemplate Template { get; private set; }
   public AttributeVector[] DataRows { get; private set; }
   public void Add(AttributeVector row);
   public void Delete(AttributeVector row);
   public void Join(DataSet ds);
}

5. Конвертеры для выборок

public interface IAttributeConverter
{
   IAttribute[] Convert(IAttribute[] attributes);
}

public class DataSetConverter
{
   public DataSet Convert(DataSet source, TaskTemplate destTemplate, IAttributeConverter[] converters);
}

6. Решатели

public interface ISolver
{
   IAttribute[] Solve(IAttribute[] x);
   void SetParameters(IParameter[] parameters);
   IParameter[] GetParameters();
}

public interface IParameter
{
}

public static class SolverFactory
{
   public static string[] SolverTypes { get; private set; };
   public static ILearner CreateSolver(string type);
   public static string GetTypeOf(ISolver solver);
}

7. Алгоритмы обучения

public interface ILearningOperationsContainer
{
}

public interface ILearningProgress
{
   public int Percentage { get; }
   public double TrainError { get; }
}

public interface ILearnable: ISolver
{
   ILearningOperationsContainer GetOperationsForLearning();
}

public static class LearnableFactory
{
   public static string[] GetLearnableTypes(ISolver solver);
   public static ILearner CreateLearnable(string type, ISolver solver);
   public static string GetTypeOf(ILearnable learnable);
}

public interface ILearner: INotifyProgressChanged<ILearningProgress>
{
   void Learn(ILearnable method, DataSet trainSet);
}

public static class LearnerFactory
{
   public static string[] LearnerTypes { get; private set; };
   public static ILearner CreateLearner(string type);
   public static string GetTypeOf(ILearner learner);
}

8. Анализ качества обучения

public class TestStatistics
{
   public double TestError { get; private set; }
   public double TrainError { get; private set; }
   public double ValidationError { get; private set; }
}

public interface IDataSetDivider
{
   void Set(DataSet dataSet);
   DataSet[] GetTest();
   DataSet[] GetTrain();
   DataSet GetValidation();
}

public interface IAnalyser
{
   TestStatistic Analyse(DataSet dataSet, ISolver solver, IDataSetDivider analysingProcess);
}

9. База данных

public class SolverDataBase
{
    ISolver GetSolver(string typeName, string solverName, string taskName);
    void AddSolver(ISolver solver, string solverName, string taskName);
    void DeleteSolver(string typeName, string solverName, string taskName);
    void UpdateSolver(ISolver solver, string solverName, string taskName);
    string[] GetSolverTypes(string taskName);
        string[] GetSolverNames(string taskName);
    string[] GetSolverNames(string typeName, string taskName);
}
public class TaskDataBase
{
    TaskTemplate GetTaskTemplate(string taskName);
    void AddTask(TaskTemplate template, string taskName);
    void DeleteTask(string taskName);
    void UpdateTask(TaskTemplate solver, string taskName);
    string[] GetTaskNames();
}
public class DataSetBase
{
    DataSet GetDataSet(string taskName, string dataSetName);
    void AddDataSet (DataSet dataSet, string dataSetName);
    void DeleteDataSet (string taskName, string dataSetName);
    void UpdateDataSet (DataSet dataSet, string dataSetName);
    string[] GetDataSetNames(string taskName);
}

from data-mining-tool-system.

michael-smirnov avatar michael-smirnov commented on September 13, 2024

Пока так. Еще нет интерфейса для работы БД и статистики анализа качества, т.к. в БД еще не спроектированы сущности под это дело, насколько я помню.

from data-mining-tool-system.

juraam avatar juraam commented on September 13, 2024

Мне кажется слишком сложно насчет задач, выборок и вообще БД. Мне кажется по правилному для БД сделать
class DataBaseConnection
class DataBaseManager
{
List ExecSelectQuery(query, handle);
DataBaseResponse ExedDeleteQuery(query);
}

и тоже самое для инсерта и апдэйта сделать.
Я так уже и сделал на локальном репозитории.
Абстрактный класс для маппера данных из БД.
abstact class Mapper
{
protected DataBaseManager manager;
DataBaseResponse delete(T object);
DataBaseResponse instert(T object);
}
и еще к нему добавить методы присущие всем мапперам( не помню что у меня там было).

допустим есть класс Task.
Для этого класса есть его Mapper
TaskMapper: Mapper
{
}

который перегружает абстрактные методы и добавляет сообственные, характерные для этого маппера. Т е по сути здесь формируется sql запросы и парсинг при селекте допустим с помощлью калбэков.
Т е для любой сущности в БД, будет свой маппер. Все мапперы используют один и тот же DataBaseManager(он в виде синглтона сделан).
Просто Миш, у тебя очень много нагромождено лишнего на мой взгляд для работы с бд.

from data-mining-tool-system.

juraam avatar juraam commented on September 13, 2024

Если будет возможность, сегодня вечером гляну код, завтра покажу подробнее.

from data-mining-tool-system.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.