@@ -75,7 +75,7 @@ impl IntentClassifier for LogRegIntentClassifier {
7575 Ok ( if intents_results. is_empty ( ) {
7676 IntentClassifierResult {
7777 intent_name : None ,
78- probability : 1.0 ,
78+ confidence_score : 1.0 ,
7979 }
8080 } else {
8181 intents_results. into_iter ( ) . next ( ) . unwrap ( )
@@ -96,7 +96,7 @@ impl LogRegIntentClassifier {
9696 if self . intent_list . len ( ) <= 1 {
9797 return Ok ( vec ! [ IntentClassifierResult {
9898 intent_name: self . intent_list. first( ) . cloned( ) . unwrap_or( None ) ,
99- probability : 1.0 ,
99+ confidence_score : 1.0 ,
100100 } ] ) ;
101101 }
102102
@@ -106,9 +106,10 @@ impl LogRegIntentClassifier {
106106 . iter ( )
107107 . map ( |intent_name| IntentClassifierResult {
108108 intent_name : intent_name. clone ( ) ,
109- probability : if intent_name. is_none ( ) { 1.0 } else { 0.0 } ,
109+ confidence_score : if intent_name. is_none ( ) { 1.0 } else { 0.0 } ,
110110 } )
111- . sorted_by ( |a, b| b. probability . partial_cmp ( & a. probability ) . unwrap ( ) ) ) ;
111+ . sorted_by ( |a, b| b. confidence_score . partial_cmp ( & a. confidence_score ) . unwrap ( ) )
112+ . collect ( ) ) ;
112113 }
113114
114115 let opt_intents_set: Option < HashSet < & str > > =
@@ -120,15 +121,15 @@ impl LogRegIntentClassifier {
120121 let features = featurizer. transform ( input) ?;
121122 let filtered_out_indexes =
122123 get_filtered_out_intents_indexes ( & self . intent_list , opt_intents_set. as_ref ( ) ) ;
123- let probabilities = logreg. run ( & features. view ( ) , filtered_out_indexes) ?;
124+ let scores = logreg. run ( & features. view ( ) , filtered_out_indexes) ?;
124125
125126 Ok ( self
126127 . intent_list
127128 . iter ( )
128- . zip ( probabilities . into_iter ( ) )
129- . map ( |( intent_name, probability ) | IntentClassifierResult {
129+ . zip ( scores . into_iter ( ) )
130+ . map ( |( intent_name, score ) | IntentClassifierResult {
130131 intent_name : intent_name. clone ( ) ,
131- probability : * probability ,
132+ confidence_score : * score ,
132133 } )
133134 . filter ( |res| {
134135 if let Some ( intent) = res. intent_name . as_ref ( ) {
@@ -140,7 +141,8 @@ impl LogRegIntentClassifier {
140141 true
141142 }
142143 } )
143- . sorted_by ( |a, b| b. probability . partial_cmp ( & a. probability ) . unwrap ( ) ) )
144+ . sorted_by ( |a, b| b. confidence_score . partial_cmp ( & a. confidence_score ) . unwrap ( ) )
145+ . collect ( ) )
144146 }
145147}
146148
@@ -372,7 +374,7 @@ mod tests {
372374 let actual_result = classification_result. unwrap ( ) ;
373375 let expected_result = IntentClassifierResult {
374376 intent_name : Some ( "MakeTea" . to_string ( ) ) ,
375- probability : 0.9088109819597295 ,
377+ confidence_score : 0.9088109819597295 ,
376378 } ;
377379
378380 // Then
0 commit comments