@@ -1022,6 +1022,52 @@ def train_recoder_mt_flatten():
10221022 )
10231023
10241024
1025+ def deploy_model_text ():
1026+ """Deploys a model learned on textual data
1027+ It is a call to `~.api.deploy_model` with its mandatory parameters, plus
1028+ text-specific parameters.
1029+
1030+ In this example, a Selective Naive Bayes (SNB) model is deployed by applying its
1031+ associated dictionary to the input database. The model predictions are written to
1032+ the output database.
1033+ """
1034+ # Imports
1035+ import os
1036+ from khiops import core as kh
1037+
1038+ # Set the file paths
1039+ dictionary_file_path = os .path .join (
1040+ kh .get_samples_dir (), "NegativeAirlineTweets" , "NegativeAirlineTweets.kdic"
1041+ )
1042+ data_table_path = os .path .join (
1043+ kh .get_samples_dir (), "NegativeAirlineTweets" , "NegativeAirlineTweets.txt"
1044+ )
1045+ output_dir = os .path .join ("kh_samples" , "deploy_model" )
1046+ report_file_path = os .path .join (output_dir , "AnalysisResults.khj" )
1047+ output_data_table_path = os .path .join (output_dir , "ScoresNegativeAirlineTweets.txt" )
1048+
1049+ # Train the predictor
1050+ _ , model_dictionary_file_path = kh .train_predictor (
1051+ dictionary_file_path ,
1052+ "FlightNegativeTweets" ,
1053+ data_table_path ,
1054+ "negativereason" ,
1055+ report_file_path ,
1056+ max_trees = 5 ,
1057+ max_text_features = 1000 ,
1058+ text_features = "words" ,
1059+ )
1060+
1061+ # Deploy the model on the database
1062+ # It will score it according to the trained predictor
1063+ kh .deploy_model (
1064+ model_dictionary_file_path ,
1065+ "SNB_FlightNegativeTweets" ,
1066+ data_table_path ,
1067+ output_data_table_path ,
1068+ )
1069+
1070+
10251071def deploy_model ():
10261072 """Deploys a model in the simplest way possible
10271073
@@ -1829,6 +1875,7 @@ def build_deployed_dictionary():
18291875 train_recoder_with_multiple_parameters ,
18301876 train_recoder_mt_flatten ,
18311877 deploy_model ,
1878+ deploy_model_text ,
18321879 deploy_model_mt ,
18331880 deploy_model_mt_with_interpretation ,
18341881 deploy_model_mt_snowflake ,
0 commit comments