fuzzy-theo
v0.1.42
Published
Fuzzy set theory utility javascript library
Downloads
1
Readme
Javascript Fuzzy Set Theory library
Fuzzy-theo is a fuzzy-set theory utility javascript library
This library is written in Javascript ES6 and it is based on the readings of the book: Neuro-Fuzzy and Soft Computing: A Computational Approach to Learning and Machine Intelligence, by J.-S. R. Jang, C.-T. Sun, E. Mizutani (See the book)
Installation
Fuzzy-theo can be installed using
$ npm install --save fuzzy-theo
Usage
// load fuzzy-theo
import FuzzySet from 'fuzzy-theo';
// discrete map fuzzy-sets
const mapMembershipGrades = {
'San Francisco': 0.9,
'Los Angeles': 0.6,
Boston: 0.8,
Amsterdam: 100,
Chennai: -100,
London: 'cloudy',
};
const fsDiscrete = new FuzzySet({ func: (x) => mapMembershipGrades[x] });
// continuous fuzzy sets
const fsContinuous = new FuzzySet({ func: (x) => x });
// membership grade
fsDiscrete.membershipGrade('San Francisco'); // 0.9
// Fuzzy set properties
const fs = new FuzzySet({
func: (x) => Math.abs(x),
dimension: 1, // dimension of the function
convex: false, // f(a*x1 + (1-a)*x2) >= min(f(x1), f(x2))
normal: false, // at least one x where this.membershipGrade(x) == 1
singleton: false, // only one x where f(x) == 1, all the others grades are 0,
crossoverPoints: [], // points where func(x) = 0.5
isSymmetricAroundC: () => false, // func(x + c) == func(x - c), for all x
bandwidth: 0, // width Math.abs(x1 - x2), being x1 and x2 the two unique crossover points
isOpenLeft: false, // lim fun(x) = 1, when x -> -Infinity
isOpenRight: false, // lim fun(x) = 1, when x -> +Infinity
isClosed: false, // lim fun(x) = 0, when x -> -Infinity OR x -> +Infinity
setType: null, // continuous, discrete
dataType: null, // numeric(quantitative), string(qualitative)
// setInterval: [a,b] (closed), [a,b) (open-right), (a,b] (open-left), (a,b) (open)
setInterval: null,
set: null, // [a, c, g ...]
});
// Fuzzy set types
import { BellFS, GaussianFS, LeftRightFS, SigmoidalFS, TrapezoidalFS, TriangularFS } from 'fuzzy-theo';
const fs = new BellFS(50, 4, 20); // Bell shaped fuzzy-set
const fs = new GaussianFS(50, 20); // Gaussian shaped fuzzy-set
const fs = new LeftRightFS(65, 60, 10); // LR fuzzy-set
const fs = new SigmoidalFS(50, 4); // Sigmoid shaped fuzzy-set
const fs = new TrapezoidalFS(20, 40, 60, 80); // Trapezoid shaped fuzzy-set
const fs = new TriangularFS(20, 60, 80); // Triangle shaped fuzzy-set
// TODO: explain fuzzy set operations
Test
To execute tests for the library, install the project dependencies once:
$ npm install
$ npm install -g gulp
Then, the tests can be executed with:
$ gulp test
To test code coverage of the tests:
$ npm test-coverage
To see the coverage results, open the generated report in your browser:
$ open ./coverage/lcov-report/index.html
Roadmap
1.0.0
- Add bignumber.js
- Bind operations to FuzzySet
- Implement more FS types
- Create a decent documentation
- Create gh-pages with examples