Jrip output in weka - weka

I am conducting an comparative study on weka. Using some of evaluation criterias such as; the average number of conditions.
avg number of condition = number of conditions in the antecedent part /
number of all generated rules
but i got the following output of JRIP algorithm:
(Wifes_education = 4) and (Number_of_children_ever_born >= 3) and (Wifes_age >= 34) and (Wifes_age <= 42) => Contraceptive_method_used=2 (141.0/56.0)
(Wifes_education = 4) and (Number_of_children_ever_born >= 3) and (Wifes_age >= 29) and (Wifes_age <= 48) and (Wifes_age >= 44) => Contraceptive_method_used=2 (53.0/24.0)
(Wifes_age <= 35) and (Number_of_children_ever_born >= 3) => Contraceptive_method_used=3 (377.0/171.0)
(Wifes_age <= 30) and (Number_of_children_ever_born >= 1) and (Wifes_age <= 22) => Contraceptive_method_used=3 (122.0/59.0)
**=> Contraceptive_method_used=1 (780.0/316.0)**
Number of Rules : 5
what about the last rule (bold rule)? its without antecedent part!
how can i obtain the number of conditions in the last rule?

The last rule (implicit) condition "captures" everything that has not been covered by the other rules. Its condition is "everything else".

Related

Why will my elseif statment never executed

Any idea why the else if statment will be never executed ? The value of difference is constantly changing when the program runs.
double difference = abs(reale_x[0] - reale_x[1]);
if (0 <= difference < 45) {
timer_counter += 1;
if (timer_counter == 30) {
cout << "CLICK" << '\n';
}
}
else if (difference > 50) {
timer_counter = 0;
}
That is not how comparation works in c++.
What this code
if (0 <= difference < 45) {
does is it first compares if 0 is smaller or equal to difference. It is then "replaced" by a bool value either true or false. And then a bool value (so either 1 or 0) is compared to 45. And it will always be smaller than 45. What you have there is an always true statement.
So the way you would write this if statement is
if (difference >= 0 && difference < 45){
Note that because of your else if statement it will not execute if the difference is >44 and <51
if (0 <= difference < 45) will be executed as if ((0 <= difference) < 45), which will be either 0<45 or 1<45 and will always be true. That's why the else part is not getting executed.
in mathematics, we see and write 0 <= x < 45 or something like that to define the range of the variable x. But in order to tell the computer the same thing, you have to tell more clearly. Saying, to have to tell the compiler, that the value of x is greater than or equal to zero and at the same time, that value will be less than 45, and you can tell the compiler by this statement: difference >= && difference < 45 . the && is an 'AND' operator in most of the languages.

What does `!((n % 5 != 0) || (n % 20 == 0))` trasnform into? and why? I don't seem to get it [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Title. I need to know what !((n % 5 != 0) || (n % 20 == 0)) transforms into and why. I say transforms because it has the ! in the beginning.
I tried transforming it to ((n%5==0) || (n%20==0)) but I am pretty sure this is not the right answer.
Thanks!!
Negation is harder than it looks.
"A or B" is true if at least one of A and B is true.
Thus its negation, "not (A or B)", must be true if neither A nor B is true, which is the same as both A and B being false.
That is, the negation is equivalent to "(not A) and (not B)".
And that leads you to !(n % 5 != 0) && !(n % 20 == 0), or (n % 5 == 0) && (n % 20 != 0).
This is one of DeMorgan's laws, which you can memorise, but they are not diffult to "discover" for yourself, and you just need to remember to "invert" the operation as well as the operands.
Assuming you mean to use DeMorgan's Law, you can distribute the NOT into the expressions by NOT'ing each expression and flipping OR's to AND's (and vice versa).
So
!((n % 5 != 0) || (n % 20 == 0))
Can become
(!(n % 5 != 0) && !(n % 20 == 0))
Which can become
((n % 5 == 0) && (n % 20 != 0))
Original: !((n % 5 != 0) || (n % 20 == 0))
Applying De Morgan's laws: (!(n % 5 != 0) && !(n % 20 == 0))
Making it clearer (assuming n is something like int and operators are not overloaded):
((n % 5 == 0) && (n % 20 != 0))
Now you have the result.

How to use "And" and "Or" keywords together in a same "If" statement

I'm trying to use And and Orkeywords on a single If statement in my VB Script, which I use with VLC Media Player to stream using command line.
I tried it like:
If (CurrentEP >= 2) And (CStr(TSNStr) = CStr(PTSNStr)) And (((CInt(TSSEPStr) - CInt(PTSSEPStr)) <= 5) Or ((CInt(TSSEPStr) - CInt(PTSSEPStr)) >= -5)) Then
I tried putting parentheses for the whole If statement, but it did nothing.
If ((CurrentEP >= 2) And (CStr(TSNStr) = CStr(PTSNStr)) And (((CInt(TSSEPStr) - CInt(PTSSEPStr)) <= 5) Or ((CInt(TSSEPStr) - CInt(PTSSEPStr)) >= -5))) Then
When I execute my script, only below two conditions seems to work.
1.If ((CurrentEP >= 2) Then '<< FIRST CONDITION
2.If (CStr(TSNStr) = CStr(PTSNStr)) Then '<< SECOND CONDITION
The third condition
(((CInt(TSSEPStr) - CInt(PTSSEPStr)) <= 5) Or ((CInt(TSSEPStr) - CInt(PTSSEPStr)) >= -5)))
always evaluates to false, which should check if difference of TSSEPStr and PTSSEPStr is either less than / equal to 5 or greater than / equal to -5.
I want to know if is it possible to use an Or keyword in a statement that is also used with multiple other And keywords in VB Script.
With the help of #GaryEvans's answer, I found that this line always evaluated to false because usage of too many parentheses.
I just made an small change and the following line worked as I expected:
If (CurrentEP >= 2) And (CStr(TSNStr) = CStr(PTSNStr)) And (CInt(TSSEPStr) - CInt(PTSSEPStr) <= 5) And (CInt(TSSEPStr) - CInt(PTSSEPStr) >= -5) Then
And made it more shorter and clearer:
If (CurrentEP >= 2) And (CStr(TSNStr) = CStr(PTSNStr)) And (CInt(TSSEPStr - PTSSEPStr) <= 5) And (CInt(TSSEPStr - PTSSEPStr) >= -5) Then
Yes it is possible, the devil is in the detail, it is all about think of all possible paths and paying close attention to the bracketing which determines the order of evaluation (which from looking at your code, you are well aware of).
The deepest bracketed evaluations are performed first then the next level up until you reach the top. For example (and you can try this in Excel): -
5 / 4 * 3 / 2 = 1.875
5 / (4 * 3) / 2 = 0.208333333
The evaluations are:-
1.25 * 3 / 2
3.75 / 2
1.875
and
5 / 12 / 2
0.416666667 / 2
0.208333333
There is an arithmetic order of precedence that also comes into play here that you may want to read up on.
Also, (and you probably know this too) all elements in an AND evaluation must be True for the result to be True. Any elements in an OR evaluation that are True will result in a True.
True AND True AND True = True
True AND True AND False = False
True OR True OR True = True
True OR True OR False = True
You can then also add parenthesis to adjust the order evaluation: -
True AND (True AND True) = True
True AND (True OR False) = True
False OR (False AND True) = False
To your issue, I think you have your greater than and less than mixed up, there was slightly to much bracketing as well but it should have evaluated still.
1 > 2 = False
2 > 1 = True
2 > 2 = False
1 < 2 = True
2 < 1 = False
2 < 2 = False
Lets call CInt(TSSEPStr) - CInt(PTSSEPStr) i: -
i = 0
(i >= 5) Or (i <= -5) = (False) Or (False) = False
0 is not greater than or equal to 5, 0 is not less than or equal to -5
i = 10
(i >= 5) Or (i <= -5) = (True) Or (False) = True
10 is greater than or equal to 5, 10 is not less than or equal to -5
This is saying it must be out of the range of -5 to 5. if we flip the greater than/less than operators it says that is must be in the range of -5 to 5, also we need to change Or to And.
i = 0
(i <= 5) And (i >= -5) = (True) And (True) = True
0 is less than or equal to 5, 0 is greater than or equal to -5
i = 10
(i <= 5) And (i >= -5) = (False) And (True) = False
10 is not less than or equal to 5, 10 is greater than or equal to -5
If (CurrentEP >= 2) And (CStr(TSNStr) = CStr(PTSNStr)) And (CInt(TSSEPStr) - CInt(PTSSEPStr) >= 5) And (CInt(TSSEPStr) - CInt(PTSSEPStr) <= -5) Then
Hope this helps.
Having many conditions always makes the evaluation tricky because of Precedence and Order of Evaluation. You might want to review those rules in relation to vb-script. The solution is usually parentheses like you attempted but I suspect you need one more pair around the first two conditions like:
If (((CurrentEP >= 2) And (CStr(TSNStr) = CStr(PTSNStr))) And (((CInt(TSSEPStr) - CInt(PTSSEPStr)) <= 5) Or ((CInt(TSSEPStr) - CInt(PTSSEPStr)) >= -5))) Then

What does EXPECT_HRESULT_SUCCEEDED means in googletest?

I have found 4 googletest which are
ASSERT_HRESULT_SUCCEEDED(expression);
EXPECT_HRESULT_SUCCEEDED(expression);
ASSERT_HRESULT_FAILED(expression);
EXPECT_HRESULT_FAILED(expression);
my question is, what does this tests do according to proper expression. What will be the response in which kind of expression? Can you explain with example??
What I think is when we need to test something in customized form: EXPECT_HRESULT_SUCCEEDED(exp)
Example:
EXPECT_HRESULT_SUCCEEDED((number % 2 == 0) && (number <= 10) && (number >= 0));
unlike others:
EXPECT_EQ(), EXPECT_GT() ... which does only a specific check condition.

I got a code in c# if statement and just manually input it, but I got it wrong.

This first code is correct, whenever I run it in the console it gives the correct result
if ((number > 10) || (number < 0))
Console.WriteLine("Hey! The number should be 0 or more and 10 or less!");
else
Console.WriteLine("Good job!");
Whilst on this one, whenever I input an integer between 1-10 it just gives the "very wrong" statement.
if ((x > 10) || (x < 10))
Console.WriteLine("Very wrong!");
else
Console.WriteLine("Correct!");
Source is http://csharp.net-tutorials.com/basics/if-statement/
This code will only ever show Correct! if your value is exactly 10.
Change:
if ((x > 10) || (x < 10))
To:
if ((x > 10) || (x < 0))
If you want the same logic as the first set of code you provided.