This example shows how to access the 'match metrics' assocaited with
a result from 51Degrees device detection.
Match metrics are various properties that indicate the level of confidence
that the supplied evidence corresponds to the result that has been returned.
29 from fiftyone_devicedetection_onpremise.devicedetection_onpremise_pipelinebuilder
import DeviceDetectionOnPremisePipelineBuilder
30 from fiftyone_devicedetection_examples.example_utils
import ExampleUtils
34 data_file = ExampleUtils.find_file(
"51Degrees-LiteV4.1.hash")
36 pipeline = DeviceDetectionOnPremisePipelineBuilder(
37 data_file_path = data_file,
39 performance_profile =
'MaxPerformance',
40 auto_update=
False).build()
45 flowdata = pipeline.create_flowdata()
48 iphone_ua =
"Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114" 50 flowdata.evidence.add(
"header.user-agent", iphone_ua)
58 if flowdata.device.deviceid.has_value():
59 print(
'Device ID: ' + str(flowdata.device.deviceID.value()))
61 Consists of four components separated by a hyphen symbol: 62 Hardware-Platform-Browser-IsCrawler where each Component 63 represents an ID of the corresponding Profile.""")
65 if flowdata.device.useragents.has_value():
66 print(
'Matched useragents: ' + str(flowdata.device.useragents.value()))
67 print(
"The matched useragents")
69 if flowdata.device.difference.has_value():
70 print(
'Difference: ' + str(flowdata.device.difference.value()))
72 Used when detection method is not Exact or None. 73 This is an integer value and the larger the value 74 the less confident the detector is in this result.""")
76 if flowdata.device.method.has_value():
77 print(
'Method: ' + str(flowdata.device.method.value()))
78 print(
"""Provides information about the algorithm that was used to perform detection for a particular User-Agent.""")
80 if flowdata.device.matchednodes.has_value():
81 print(
'Method: ' + str(flowdata.device.matchednodes.value()))
83 The number of hash nodes that have been matched before finding a result.""")