score
Use the score operator to execute statistical tests to verify the results produced by machine learning models.
Syntax
|score <scoring-method> <a_field_1, a_field_2, ... a_field_n> against <b_field_1, b_field_2, ... b_field_m> [normalize={true|false}]
<scoring-method>
|
Specify a scoring method:
|
<x_field_n> against <x_field_n> |
Comma-separated list of fields to compare. |
[normalize={true|false}]
|
The accuracy_score method supports an option to specify your data normalization preference:
The implicit default if this option is not specified is |
Usage
You can use the score operator to execute statistical tests to verify the results produced by machine learning models. The score operator is a versatile tool that can be applied across various use cases to validate models and their statistical outcomes. Depending on the nature of your data and the specific problem you aim to address, you can select the most appropriate scoring method provided by the score command.
The accuracy_score method supports pairwise comparisons between two sets of fields.
The other supported methods are used to compare the actual value and the predicted value.
Examples
Example 1: Calculate accuracy score with raw count of correctly classified samples.
|score accuracy_score a1,a2 against p1,p2 normalize=false
Example 2: Calculate accuracy score as fraction of correctly classified samples.
|score accuracy_score a1,a2 against p1,p2 normalize=true
Example 3: Generate confusion matrix for actual and predicted values.
|score confusion_matrix actual_value against predicted_value
Example 4: Calculate mean absolute error between actual and predicted values.
|score mean_absolute_error actual_value against predicted_value
Example 5: Calculate mean squared error between actual and predicted values.
test_score_table | score mean_squared_error actual against predicted
Example 6: Filters and cleans network flow fields, fills nulls with defaults, sorts by most recent event, then calculates the mean absolute error between source and destination port numbers.
ocsf | where severity in ('alert', 'info') | fields severity, src_endpoint.interface_name, src_endpoint.port, dst_endpoint.interface_name, dst_endpoint.port, src_endpoint.ip, dst_endpoint.ip | fillnull src_endpoint.interface_name value='no source' | fillnull src_endpoint.ip, dst_endpoint.ip | fillnull dst_endpoint.interface_name value='empty_dest' | sort event_time desc | score mean_absolute_error src_endpoint.port against dst_endpoint.port