mode function in the Factory

The mode is the most frequent value in an attribute.

For example, the mode in the list [23; 26; 26; 26; 4; 7; 7; 98] is 26.

The Mode function is available also by:


Function and parameters

mode(column, group, usemissing)

Parameter

Description

column

It identifies the column to which you want to apply the formula. The column parameter is mandatory.

group

It allows you to group the results by a certain column.

usemissing

A Boolean which indicates whether missing values should be considered or not in the computation of the statistics. The default value, if not otherwise specified, is True.


Example

The following example uses the HR-employee-attrition dataset.

Description

Screenshot

  • In the example here, we want to retrieve the mode of the Job Role attribute. We write the following formula:

  • mode($"JobRole")

  • The mode of the Job Role attribute is Sales Executive.

  • Then ,we want to group our results by the Education Field attribute, and to have a 0 when a value is missing.

  • So the formula is:

  • mode($"JobRole",$"EducationField")

  • The results are as follows:

    • The mode of the Job Role for the Life Sciences education field is Research Scientist.

    • The mode of the Job Role for the Other education fields is Laboratory Technician.