Giter VIP home page Giter VIP logo

easycbr's Introduction

EasyCBR 1.0.4

Nuget
  • The easy way to implement CBR (Case Based Reasoning) in C#.

Documentation

  • 4R methods:

    • Retrieve(query case, number of the closest cases that you want): Retrive the closest cases.
    • Reuse(select type): Reuse the one of cases depending on a way.
    • Revise(correct value): Revise the value, you may not pass any value.
    • Retain(): Retain the case.
  • Similarity functions:

    • BasicSimilarityFunction
    • LinearSimilarityFunction
    • TableSimilarityFunction
    • CustomSimilarityFunction

Demo

  • Prepare your data:
 var laptopList = new List<Laptop>()
 {
    new Laptop("ModelX1", Manufacture.Asus, 4, "I3_G5", false, 200),
    new Laptop("ModelX2", Manufacture.Dell, 4, "I3_G6", false, 220),
    new Laptop("ModelX3", Manufacture.Asus, 4, "I3_G7", false, 250),
    new Laptop("ModelX4", Manufacture.Hp, 8, "I5_G8", false, 300),
    new Laptop("ModelX5", Manufacture.Lenovo, 8, "I5_G8", false, 280),
    new Laptop("ModelX6", Manufacture.Dell, 16, "I5_G11", true, 500),
    new Laptop("ModelX7", Manufacture.Lenovo, 12, "I5_G10", false, 400),
    new Laptop("ModelX8", Manufacture.Hp, 16, "I5_G12", true, 600),
    new Laptop("ModelX9", Manufacture.Lenovo, 32, "I5_G12", true, 650),
    new Laptop("ModelX10", Manufacture.Asus, 16, "I5_G11", true, 450),
 };
  • Write a custom similarity function (if you need it):
 Func<string, string, double> cpuSimilarity = (value, queryValue) =>
 {
     double result = 0;
     var values = value.Split('_');
     var queryValues = queryValue.Split('_');
     if (values[0] == queryValues[0])
     {
         result += 0.5;
     }
 
     if (values[1] == queryValues[1])
     {
         result += 0.5;
     }
 
     return result;
 };
  • Write a custom table (if you need it):
 Table<Manufacture> _manufactureSimilarity = new()
 {
     [Manufacture.Dell, Manufacture.Hp] = 0.5,
     [Manufacture.Asus, Manufacture.Dell] = 0.5
 };
  • Run it:
 var result = CBR<Laptop, decimal>
     .Create(laptopList)
     .Output(order => order.Price)
     .SetSimilarityFunctions
     (
         (nameof(Laptop.Manufacture), new TableSimilarityFunction<Manufacture>(_manufactureSimilarity)),
         (nameof(Laptop.RAM), new LinearSimilarityFunction<int>(4, 32, 2)),
         (nameof(Laptop.SSD), new BasicSimilarityFunction<bool>(2)),
         (nameof(Laptop.CPU), new CustomSimilarityFunction<string>(cpuSimilarity, 4))
     )
     .Retrieve(new Laptop("ModelX", Manufacture.Asus, 32, "I5_G11", true, 0), 3)
     .Reuse(SelectType.AverageValue)
     .Revise()
     .Retain()
     .Run();
  • Enjoy ..

easycbr's People

Contributors

osamaalrashed avatar

Stargazers

 avatar

Watchers

 avatar

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.