|
1248 | 1248 | ")" |
1249 | 1249 | ] |
1250 | 1250 | }, |
| 1251 | + { |
| 1252 | + "cell_type": "markdown", |
| 1253 | + "metadata": {}, |
| 1254 | + "source": [ |
| 1255 | + "### `deploy_model_text()`\n\n", |
| 1256 | + "Deploys a model learned on textual data\n It is a call to `~.api.deploy_model` with its mandatory parameters, plus\n text-specific parameters.\n\n In this example, a Selective Naive Bayes (SNB) model is deployed by applying its\n associated dictionary to the input database. The model predictions are written to\n the output database.\n \n" |
| 1257 | + ] |
| 1258 | + }, |
| 1259 | + { |
| 1260 | + "cell_type": "code", |
| 1261 | + "execution_count": null, |
| 1262 | + "metadata": {}, |
| 1263 | + "outputs": [], |
| 1264 | + "source": [ |
| 1265 | + "# Imports\n", |
| 1266 | + "import os\n", |
| 1267 | + "from khiops import core as kh\n", |
| 1268 | + "\n", |
| 1269 | + "# Set the file paths\n", |
| 1270 | + "dictionary_file_path = os.path.join(\n", |
| 1271 | + " kh.get_samples_dir(), \"NegativeAirlineTweets\", \"NegativeAirlineTweets.kdic\"\n", |
| 1272 | + ")\n", |
| 1273 | + "data_table_path = os.path.join(\n", |
| 1274 | + " kh.get_samples_dir(), \"NegativeAirlineTweets\", \"NegativeAirlineTweets.txt\"\n", |
| 1275 | + ")\n", |
| 1276 | + "output_dir = os.path.join(\"kh_samples\", \"deploy_model\")\n", |
| 1277 | + "report_file_path = os.path.join(output_dir, \"AnalysisResults.khj\")\n", |
| 1278 | + "output_data_table_path = os.path.join(output_dir, \"ScoresNegativeAirlineTweets.txt\")\n", |
| 1279 | + "\n", |
| 1280 | + "# Train the predictor\n", |
| 1281 | + "_, model_dictionary_file_path = kh.train_predictor(\n", |
| 1282 | + " dictionary_file_path,\n", |
| 1283 | + " \"FlightNegativeTweets\",\n", |
| 1284 | + " data_table_path,\n", |
| 1285 | + " \"negativereason\",\n", |
| 1286 | + " report_file_path,\n", |
| 1287 | + " max_trees=5,\n", |
| 1288 | + " max_text_features=1000,\n", |
| 1289 | + " text_features=\"words\",\n", |
| 1290 | + ")\n", |
| 1291 | + "\n", |
| 1292 | + "# Deploy the model on the database\n", |
| 1293 | + "# It will score it according to the trained predictor\n", |
| 1294 | + "kh.deploy_model(\n", |
| 1295 | + " model_dictionary_file_path,\n", |
| 1296 | + " \"SNB_FlightNegativeTweets\",\n", |
| 1297 | + " data_table_path,\n", |
| 1298 | + " output_data_table_path,\n", |
| 1299 | + ")" |
| 1300 | + ] |
| 1301 | + }, |
1251 | 1302 | { |
1252 | 1303 | "cell_type": "markdown", |
1253 | 1304 | "metadata": {}, |
|
0 commit comments