Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get member name? #5

Closed
atakanyildirim opened this issue Mar 12, 2019 · 5 comments
Closed

How to get member name? #5

atakanyildirim opened this issue Mar 12, 2019 · 5 comments

Comments

@atakanyildirim
Copy link

atakanyildirim commented Mar 12, 2019

$fuzzy = new Fuzzy_Logic();

$fuzzy->setInputNames(array('sensitivity', 'confidence'));

$fuzzy->addMember($fuzzy->getInputName(0), 'low', 0.0, 0.0, 0.4, TRIANGLE);
$fuzzy->addMember($fuzzy->getInputName(0), 'medium', 0.0, 0.4, 1, TRIANGLE);
$fuzzy->addMember($fuzzy->getInputName(0), 'high', 0.4, 1, 1, TRIANGLE);

$fuzzy->addMember($fuzzy->getInputName(1), 'low', 0.0, 0.0, 0.4, TRIANGLE);
$fuzzy->addMember($fuzzy->getInputName(1), 'medium', 0.0, 0.4, 1, TRIANGLE);
$fuzzy->addMember($fuzzy->getInputName(1), 'high', 0.4, 1, 1, TRIANGLE);

$fuzzy->setOutputNames(array('decision'));

$fuzzy->addMember($fuzzy->getOutputName(0), 'no', 0.0, 0.0 , 0.5 , TRIANGLE);
$fuzzy->addMember($fuzzy->getOutputName(0), 'maybe', 0.0, 0.5, 1 , TRIANGLE);
$fuzzy->addMember($fuzzy->getOutputName(0), 'yes', 0.5, 1, 1 , TRIANGLE);

$fuzzy->addRule('IF sensitivity.low AND confidence.low THEN decision.maybe');
$fuzzy->addRule('IF sensitivity.low AND confidence.medium THEN decision.maybe');
$fuzzy->addRule('IF sensitivity.low AND confidence.high THEN decision.yes');
$fuzzy->addRule('IF sensitivity.medium AND confidence.low THEN decision.maybe');
$fuzzy->addRule('IF sensitivity.medium AND confidence.medium THEN decision.maybe');
$fuzzy->addRule('IF sensitivity.medium AND confidence.high THEN decision.yes');
$fuzzy->addRule('IF sensitivity.high AND confidence.low THEN decision.no');
$fuzzy->addRule('IF sensitivity.high AND confidence.medium THEN decision.maybe');
$fuzzy->addRule('IF sensitivity.high AND confidence.high THEN decision.yes');

$fuzzy->setRealInput('sensitivity',0.66);
$fuzzy->setRealInput('confidence',0.31);

$run = $fuzzy->calcFuzzy();
$Fuzzy = $run['decision'];
printf("%.2f",$Fuzzy); //result => 0.48 I want to see yes or maybe or no :)
@Kmicic
Copy link

Kmicic commented Mar 13, 2019

this is fuzzy logic and result is float value in range [0.0 ... 1.0] , for binary logic false is for example 0 ... 0.49 and true is 0.50 to 1.0. or vice versa.
$Fuzzy = $run['decision'];
$Binary = $Fuzzy<=0.49 ? false : true;
echo $Binary; // result is true or false...
//printf("%.2f",$Fuzzy); //result => 0.48 I want to see yes or maybe or no :)

@Kmicic
Copy link

Kmicic commented Mar 13, 2019

or :
if ($Fuzzy<=0.3) $state = 'no';
else if ($Fuzzy>=0.7) $state='yes';
else $state = 'maybe';

@chrisribe
Copy link

I agree with @Kmicic. +1

Also anyone know if the current pull requests will ever get merged?

@atakanyildirim
Copy link
Author

Thanks for answer. 👍

@Kmicic
Copy link

Kmicic commented Mar 14, 2019

Also anyone know if the current pull requests will ever get merged?
Do not understand the question ?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants