sebs / es6-fuzz Goto Github PK
View Code? Open in Web Editor NEWfuzzylogic - experimental library
License: MIT License
fuzzylogic - experimental library
License: MIT License
Hello thank you for the lib. I want to use es5 i put the following code
var es6ify = require('./es6-fuzz-latest.js');
How can i do var logic = new Logic()
How do you require/import the Trapezoid class?
The second example is missing another closing bracket on the second line (new Triangle ...
)
Also the console.log(res)
always evaluates to hot, even if I try defuzzify small values?
var res = logic
.init('verycold', new Triangle(new Trapezoid(0, 0, 8, 12)) // until 10 degrees very cold
.and('cold', new Trapezoid(8, 12, 18, 20)) // until 12-18 around warm
.and('hot', new Trapezoid(12, 20, 30, 100)) // all up from 30 surely hot
.defuzzify(99);
console.log(res);
Hello,
i tried to istantiate the shape importing like this (found in issues):
const {Trapezoid} = logic.c;
it seems to work like this:
const Trapezoid = require('es6-fuzz/lib/curve/trapezoid');
Ideas on why?
Thanks
Hi,
I am trying to use this library, the fuzzification is quite clear but the defuzzification step is not clear to me using this library, anyways, I have this code that gives a wrong evaluation at the upper limit of a trapezoid, It seems to come from this library not from boon-js:
I have this function with two input fuzzy variables (likelihood and impact), the fifth evaluator function is the one that returns True when the input is assess(5, 10), while 10 as a value for impact should trigger the seventh evaluator to return true (securityTest_moderate_restricted ) and this should lead to have the function an output of "high", I tried to slightly modify the trapezoid declaration to make it work by cheating a little bit and pushing the last point of the trapezoid to 11: const restrictedImpact = new fuzzy.Trapezoid(7.5, 8.5, 10, 11);
And this gave me a correct result, which makes me think that there is a problem at the higher limit of the trapezoid.
Thanks,
This is the function:
const assess = (likelihood, impact) => {
var logicLikelihood = new fuzzy.Logic();
const lowLikelihood = new fuzzy.Trapezoid(0, 0, 2, 3);
const moderateLikelihood = new fuzzy.Trapezoid(2, 3, 7, 8);
const highLikelihood = new fuzzy.Trapezoid(7, 8, 10, 10);
logicLikelihood.init('low', lowLikelihood)
logicLikelihood.or('moderate', moderateLikelihood)
logicLikelihood.or('high', highLikelihood);
var logicImpact = new fuzzy.Logic();
const publicImpact = new fuzzy.Trapezoid(0, 0, 1.5, 2.5);
const internalImpact = new fuzzy.Trapezoid(1.5, 2.5, 4.5, 5.5);
const confidentialImpact = new fuzzy.Trapezoid(4.5, 5.5, 7.5, 8.5);
const restrictedImpact = new fuzzy.Trapezoid(7.5, 8.5, 10, 10);
logicImpact.init('public', publicImpact)
logicImpact.or('internal', internalImpact)
logicImpact.or('confidential', confidentialImpact);
logicImpact.or('restricted', restrictedImpact);
const tests = [];
// assessment very low
const securityTest_low_public = boon.getEvaluator('likelihood.low AND impact.public');
tests.push(securityTest_low_public);
// assessment low
const securityTest_low_internal = boon.getEvaluator('likelihood.low AND impact.internal');
tests.push(securityTest_low_internal);
// assessment medium
const securityTest_low_confidential = boon.getEvaluator('likelihood.low AND impact.confidential');
tests.push(securityTest_low_confidential);
// assessment high
const securityTest_low_restricted = boon.getEvaluator('likelihood.low AND impact.restricted');
tests.push(securityTest_low_restricted);
// assessment low
const securityTest_moderate_public = boon.getEvaluator('likelihood.moderate AND impact.public');
tests.push(securityTest_moderate_public);
// assessment medium
const securityTest_moderate_internal = boon.getEvaluator('likelihood.moderate AND impact.internal');
tests.push(securityTest_moderate_internal);
// assessment high
const securityTest_moderate_confidential = boon.getEvaluator('likelihood.moderate AND impact.confidential');
tests.push(securityTest_moderate_confidential);
// assessment very high
const securityTest_moderate_restricted = boon.getEvaluator('likelihood.moderate AND impact.restricted');
tests.push(securityTest_moderate_restricted);
// assessment low
const securityTest_high_public = boon.getEvaluator('likelihood.high AND impact.public');
tests.push(securityTest_high_public);
// assessment medium
const securityTest_high_internal = boon.getEvaluator('likelihood.high AND impact.internal');
tests.push(securityTest_high_internal);
// assessment high
const securityTest_high_confidential = boon.getEvaluator('likelihood.high AND impact.confidential');
tests.push(securityTest_high_confidential);
// assessment very high
const securityTest_high_restricted = boon.getEvaluator('likelihood.high AND impact.restricted');
tests.push(securityTest_high_restricted);
const resLikelihood = logicLikelihood.defuzzify(likelihood, 'likelihood');
const resImpact = logicImpact.defuzzify(impact, 'impact');
const jsBoonInput = { ...resLikelihood.boonJsInputs, ...resImpact.boonJsInputs }
const results = [];
for(let i = 0; i < tests.length; i++){
results.push( tests[i](jsBoonInput) );
}
if(results[0]) return "very low";
else if(results[1]) return "low";
else if(results[2]) return "medium";
else if(results[3]) return "high";
else if(results[4]) return "low";
else if(results[5]) return "medium";
else if(results[6]) return "high";
else if(results[7]) return "high";
else if(results[8]) return "low";
else if(results[9]) return "medium";
else if(results[10]) return "high";
else if(results[11]) return "very high";
else return "Unknown";
}
Hi,
Example 2 code shows result from example 1. Shouldn't it show 'hot' as the right answer instead of 'enragedAttack'?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.