hyb
2025-12-23 10f3a1daddfbc7fa3dd2069197d83e8b6ef19176
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
Ë
Wñúh¾lãóԗdZddlZddlZddlmZddlmZmZmZm    Z    ddl
Z ddl Z ddlmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZGd„de«ZGd    „d
«ZGd „d e«Z y) zªHeatWave ML model utilities for MySQL Connector/Python.
 
Provides classes to manage training, prediction, scoring, and explanations
via MySQL HeatWave stored procedures.
éN)ÚEnum)ÚAnyÚDictÚOptionalÚUnion) ÚVAR_NAME_SPACEÚatomic_transactionÚ convert_to_dfÚ execute_sqlÚformat_value_sqlÚget_random_nameÚ source_schemaÚsql_response_to_dfÚsql_table_from_dfÚsql_table_to_dfÚ table_existsÚtemporary_sql_tablesÚ validate_name)ÚMySQLConnectionAbstractcóP—eZdZdZdZdZdZdZdZdZ    dZ
e d    e e dfd
e fd „«Zy ) ÚML_TASKz/Enumeration of supported ML tasks for HeatWave.ÚclassificationÚ
regressionÚ forecastingÚanomaly_detectionÚlog_anomaly_detectionÚrecommendationÚtopic_modelingÚtaskÚreturncó>—t|t«r|S|jS)a'
        Return the string representation of a machine learning task.
 
        Args:
            task (Union[str, ML_TASK]): The task to convert.
                Accepts either a task enum member (ML_TASK) or a string.
 
        Returns:
            str: The string value of the ML task.
        )Ú
isinstanceÚstrÚvalue)rs úDH:\Change_password\venv_build\Lib\site-packages\mysql/ai/ml/model.pyÚget_task_stringzML_TASK.get_task_stringGs€ô dœCÔ  ØˆKàz‰zÐóN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__ÚCLASSIFICATIONÚ
REGRESSIONÚ FORECASTINGÚANOMALY_DETECTIONÚLOG_ANOMALY_DETECTIONÚRECOMMENDATIONÚTOPIC_MODELINGÚ staticmethodrr#r&©r'r%rr<sS„Ù9à%€NØ€JØ€KØ+ÐØ3ÐØ%€NØ%€Nàð˜e C¨ NÑ3ð¸òóñr'rc
óH—eZdZdZej
dfdedeeefde    efd„Z
de fd„Z dede    e fd    „Zde    e fd
„Zdede fd „Zdd „Zdefd „Zde fd„Zdede    ede    e ddfd„Zdedede    e ddfd„Zdededede    e def
d„Zdedede    e dej2fd„Zy)Ú_MyModelCommona8
    Common utilities and workflow for MySQL HeatWave ML models.
 
    This class handles model lifecycle steps such as loading, fitting, scoring,
    making predictions, and explaining models or predictions. Not intended for
    direct instantiation, but as a superclass for heatwave model wrappers.
 
    Attributes:
        db_connection: MySQL connector database connection.
        task: ML task, e.g., "classification" or "regression".
        model_name: Identifier of model in MySQL.
        schema_name: Database schema used for operations and temp tables.
    NÚ db_connectionrÚ
model_namecóú—||_tj|«|_t    |«|_t |j«5}t|d«ddd«|€t|j«}t›d|›|_ |j›d|_ ||_ t|«t |j«5}t|d|j›d|f¬«ddd«y#1swYŒ’xYw#1swYyxYw)a»
        Instantiate _MyMLModelCommon.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-train.html
                A full list of supported tasks can be found under "Common ML_TRAIN Options"
 
        Args:
            db_connection: MySQL database connection.
            task: ML task type (default: "classification").
            model_name: Name to register the model within MySQL (default: None).
 
        Raises:
            ValueError: If the schema name is not valid
            DatabaseError:
                If a database connection issue occurs.
                If an operational error occurs during execution.
 
        Returns:
            None
        z(CALL sys.ML_CREATE_OR_UPGRADE_CATALOG();Nú.z.scorezSET @z = %s;©Úparams)r7rr&rrÚ schema_namer    r r Ú_is_model_name_availablerÚ    model_varÚmodel_var_scorer8r)Úselfr7rr8Úcursors     r%Ú__init__z_MyModelCommon.__init__isø€ð6+ˆÔÜ×+Ñ+¨DÓ1ˆŒ    Ü(¨Ó7ˆÔä  × 2Ñ 2Ó 3ð    L°vÜ ˜РJÔ K÷    Lð Ð Ü(¨×)FÑ)FÓGˆJä*Ð+¨1¨Z¨LÐ9ˆŒØ"&§.¡.Ð!1°Ð8ˆÔà$ˆŒÜjÔ!ä  × 2Ñ 2Ó 3ð    V°vÜ ˜ %¨¯©Ð'7°vР>È
À}Õ U÷    Vð    V÷    Lð    Lú÷    Vð    VúsÁ C%Â>C1Ã%C.Ã1C:r cóޗ|j«}d|›d}d|›d|j›}t|j«5}t    ||«|j
dkDcddd«S#1swYyxYw)a%
        Deletes the model from the model catalog if present
 
        Raises:
            DatabaseError:
                If a database connection issue occurs.
                If an operational error occurs during execution.
 
        Returns:
            Whether the model was deleted
        Ú
ML_SCHEMA_ú.MODEL_CATALOGz DELETE FROM ú WHERE model_handle = @rN)Ú    _get_userr?r    r7r Úrowcount)rAÚ current_userÚqualified_model_catalogÚ delete_modelrBs     r%Ú _delete_modelz_MyModelCommon._delete_model—s~€ð—~‘~Ó'ˆ à$.¨|¨n¸NÐ"KÐàÐ2Ð3ð4%Ø%)§^¡^Ð$4ð 6ð    ô
  × 2Ñ 2Ó 3ð    '°vÜ ˜  Ô -Ø—?‘? QÑ&÷    '÷    'ò    'ús ¾A#Á#A,c    ó¸—dtdtfd„}|j«}d|›d}d|›d}t|j«5}t    |||f¬«t |«}|j rd    }nS|jd
¬ «}    tj|    «d }
|
j«D  cic]\} } | || «“Œ}} } |cd    d    d    «Scc} } w#1swYy    xYw) a
        Retrieves the model info from the model_catalog
 
        Args:
            model_var: The model alias to retrieve
 
        Returns:
            The model info from the model_catalog (None if the model is not present in the catalog)
 
        Raises:
            DatabaseError:
                If a database connection issue occurs.
                If an operational error occurs during execution.
        Úelemr cóŠ—t|t«r    tj|«}|S|S#tj$rY|SwxYw©N)r"r#ÚjsonÚloadsÚJSONDecodeError)rOs r%Ú process_colz3_MyModelCommon._get_model_info.<locals>.process_col¿sI€Ü˜$¤Ô$ðÜŸ:™: dÓ+DðˆK4ˆKøô×+Ñ+òØØˆKðús’+«AÁArErFúSELECT * FROM z WHERE model_handle = %sr;NÚrecords)Úorientr) rrHr    r7r rÚemptyÚto_jsonrRrSÚitems) rAr8rUrJrKÚ model_existsrBÚ model_info_dfÚresultÚunprocessed_resultÚunprocessed_result_jsonÚkeyrOs              r%Ú_get_model_infoz_MyModelCommon._get_model_info¯s€ð     œcð    ¤có    ð—~‘~Ó'ˆ à$.¨|¨n¸NÐ"KÐàÐ4Ð5Ð5MÐ Nð    ô  × 2Ñ 2Ó 3ð    °vÜ ˜  °j°]Õ CÜ.¨vÓ6ˆMà×"Ò"Ø‘à%2×%:Ñ%:À)Ð%:Ó%LÐ"Ü*.¯*©*Ð5GÓ*HÈÑ*KÐ'ð&=×%BÑ%BÓ%D÷á!˜˜Tð™ TÓ*Ñ*ðñð
÷    ñ    ùó÷    ð    úsÁA'CÂ)C
Â<CÃ
CÃCcó8—|j|j«S)aˆ
        Checks if the model name is available.
        Model info is present in the catalog only if the model was previously fitted.
 
        Returns:
            True if the model name is not part of the model catalog
 
        Raises:
            DatabaseError:
                If a database connection issue occurs.
                If an operational error occurs during execution.
        )rbr8)rAs r%Úget_model_infoz_MyModelCommon.get_model_infoÞs€ð×#Ñ# D§O¡OÓ4Ð4r'có(—|j|«duS)a1
        Checks if the model name is available
 
        Returns:
            True if the model name is not part of the model catalog
 
        Raises:
            DatabaseError:
                If a database connection issue occurs.
                If an operational error occurs during execution.
        N)rb)rAr8s  r%r>z'_MyModelCommon._is_model_name_availableís€ð×#Ñ# JÓ/°4Ð7Ð7r'có—t|j«5}d|j›d}t||«ddd«y#1swYyxYw)a
        Loads the model specified by `self.model_name` into MySQL.
        After loading, the model is ready to handle ML operations.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-model-load.html
 
        Raises:
            DatabaseError:
                If the model is not initialized, i.e., fit or import has not been called
                If a database connection issue occurs.
                If an operational error occurs during execution.
 
        Returns:
            None
        zCALL sys.ML_MODEL_LOAD(@z, NULL);N)r    r7r?r )rArBÚload_model_querys   r%Ú _load_modelz_MyModelCommon._load_modelûsH€ô"  × 2Ñ 2Ó 3ð    2°vØ!9¸$¿.¹.Ð9IÈÐRÐ Ü ˜Р0Ô 1÷    2÷    2ñ    2ús    –<¼Acóڗt|j«5}|jd«|j«dj    d«d}t |«cddd«S#1swYyxYw)a€
        Fetch the current database user (without host).
 
        Returns:
            The username string associated with the connection.
 
        Raises:
            DatabaseError:
                If a database connection issue occurs.
                If an operational error occurs during execution.
            ValueError: If the user name includes unsupported characters
        zSELECT CURRENT_USER()rú@N)r    r7ÚexecuteÚfetchoneÚsplitr)rArBrJs   r%rHz_MyModelCommon._get_users_€ô  × 2Ñ 2Ó 3ð    /°vØ N‰NÐ2Ô 3Ø!Ÿ?™?Ó,¨QÑ/×5Ñ5°cÓ:¸1Ñ=ˆLä  Ó.÷        /÷    /ò    /ús –AA!Á!A*có—|j«t|j«5}|j«}d|›d}d|›d|j›}t ||«t |«}|jdcddd«S#1swYyxYw)a°
        Get model explanations, such as detailed feature importances.
 
        Returns:
            dict: Feature importances and model explainability data.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-model-explanations.html
 
        Raises:
            DatabaseError:
                If the model is not initialized, i.e., fit or import has not been called
                If a database connection issue occurs.
                If an operational error occurs during execution.
            ValueError:
                If the model does not exist in the model catalog.
                Should only occur if model was not fitted or was deleted.
        rErFzSELECT model_explanation FROM rG©rrN)rhr    r7rHr?r rÚiloc)rArBrJrKÚ explain_queryÚdfs      r%Ú explain_modelz_MyModelCommon.explain_model#s”€ð&     ×ÑÔÜ  × 2Ñ 2Ó 3ð     !°vØŸ>™>Ó+ˆLà(2°<°.ÀÐ&OÐ #à0Ð1HÐ0IðJ)Ø)-¯©Ð(8ð:ð ô
˜  Ô .Ü# FÓ+ˆBà—7‘7˜4‘=÷     !÷     !ò     !ús ¦AA>Á>BÚ
table_nameÚtarget_column_nameÚoptionscóŠ—t|«|t|«d|›d}nd}|€i}tj|«}|j|d<|j    «t |j «5}t|«\}}t|d|j›d|›d|›d|›d    |j›d
 |¬ «ddd«y#1swYyxYw) a2
        Fit an ML model using a referenced SQL table and target column.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-train.html
                A full list of supported options can be found under "Common ML_TRAIN Options"
 
        Args:
            table_name: Name of the training data table.
            target_column_name: Name of the target/label column.
            options: Additional fit/config options (may override defaults).
 
        Raises:
            DatabaseError:
                If provided options are invalid or unsupported.
                If a database connection issue occurs.
                If an operational error occurs during execution.
            ValueError: If the table or target_column name is not valid
 
        Returns:
            None
        Nú'ÚNULLrzCALL sys.ML_TRAIN('r:ú', ú, z, @ú)r;) rÚcopyÚdeepcopyrrMr    r7r r r=r?)rArtrurvÚtarget_col_stringrBÚ placeholdersÚ
parameterss        r%Ú_fitz_MyModelCommon._fitEsä€ô8    jÔ!Ø Ð )Ü Ð,Ô -Ø"#Ð$6Ð#7°qР9Ñ à &Ð à ˆ?؈GÜ—-‘- Ó(ˆØŸ)™)ˆ‰à ×ÑÔä  × 2Ñ 2Ó 3ð     °vÜ'7¸Ó'@Ñ $ˆL˜*Ü ØðØ×(Ñ(Ð)¨¨:¨,°cØ(Ð)¨Ø#nð%ØŸ™Ð'Øð ð"õ ÷     ÷     ñ     ús Á/AB9Â9CÚoutput_table_namecó>—t|«t|«|j«t|j«5}t    |«\}}t |d|j ›d|›d|j›d|j ›d|›d|›d |¬«ddd«y#1swYyxYw)    aª
        Predict on a given data table and write results to an output table.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-predict-table.html
                A full list of supported options can be found under "ML_PREDICT_TABLE Options"
 
        Args:
            table_name: Name of the SQL table with input data.
            output_table_name: Name for the SQL output table to contain predictions.
            options: Optional prediction options.
 
        Returns:
            None
 
        Raises:
            DatabaseError:
                If provided options are invalid or unsupported,
                or if the model is not initialized, i.e., fit or import has not
                been called
                If a database connection issue occurs.
                If an operational error occurs during execution.
            ValueError: If the table or output_table name is not valid
        zCALL sys.ML_PREDICT_TABLE('r:ú', @ú, 'rzr|r;N)rrhr    r7r r r=r?)rArtrƒrvrBr€rs       r%Ú_predictz_MyModelCommon._predict~s³€ô6    jÔ!ÜÐ'Ô(à ×ÑÔÜ  × 2Ñ 2Ó 3ð     °vÜ'7¸Ó'@Ñ $ˆL˜*Ü ØðØ×(Ñ(Ð)¨¨:¨,ð7ØŸ™Ð'ð(Ø×(Ñ(Ð)¨Ð+<Ð*=¸SØ#nØð ð"õ ÷     ÷     ñ     ús ¼ABÂBÚmetriccóÀ—t|«t|«t|«|j«t|j«5}t    |«\}}t |d|j ›d|›d|›d|j›d|j›d|›d |g|¢¬«t |d    |j›«t|«}|jd
cd d d «S#1swYy xYw) aI
        Evaluate model performance with a scoring metric.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-score.html
                A full list of supported options can be found under
                "Options for Recommendation Models" and
                "Options for Anomaly Detection Models"
 
        Args:
            table_name: Table with features and ground truth.
            target_column_name: Column of true target labels.
            metric: String name of the metric to compute.
            options: Optional dictionary of further scoring options.
 
        Returns:
            float: Computed score from the ML system.
 
        Raises:
            DatabaseError:
                If provided options are invalid or unsupported,
                or if the model is not initialized, i.e., fit or import has not
                been called
                If a database connection issue occurs.
                If an operational error occurs during execution.
            ValueError: If the table or target_column name or metric is not valid
        zCALL sys.ML_SCORE('r:z', 'r…z, %s, @r{r|r;zSELECT @roN) rrhr    r7r r r=r?r@rrp)    rArtrurˆrvrBr€rrrs             r%Ú_scorez_MyModelCommon._score¬sö€ôD    jÔ!ÜÐ(Ô)ܐfÔà ×ÑÔÜ  × 2Ñ 2Ó 3ð    !°vÜ'7¸Ó'@Ñ $ˆL˜*Ü ØðØ×(Ñ(Ð)¨¨:¨,ð7Ø*Ð+ð,ØŸ™Ð'ð(à×,Ñ,Ð-¨RØ#nØððÐ, Ð,õ ô ˜ (¨4×+?Ñ+?Ð*@РAÔ BÜ# FÓ+ˆBà—7‘7˜4‘=÷'    !÷    !ò    !ús ÁBCÃCcóœ—t|«t|«|€ddi}|j«t|j«5}t    |«\}}t |d|j ›d|›d|j›d|j ›d|›d|›d     |¬
«t |d |j ›d|›«t|«}|cddd«S#1swYyxYw) a
        Produce explanations for model predictions on provided data.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-explain-table.html
                A full list of supported options can be found under "ML_EXPLAIN_TABLE Options"
 
        Args:
            table_name: Name of the SQL table with input data.
            output_table_name: Name for the SQL table to store explanations.
            options: Optional dictionary (default:
                {"prediction_explainer": "permutation_importance"}).
 
        Returns:
            DataFrame: Prediction explanations from the output SQL table.
 
        Raises:
            DatabaseError:
                If provided options are invalid or unsupported,
                or if the model is not initialized, i.e., fit or import has not
                been called
                If a database connection issue occurs.
                If an operational error occurs during execution.
            ValueError: If the table or output_table name is not valid
        NÚprediction_explainerÚpermutation_importancezCALL sys.ML_EXPLAIN_TABLE('r:r…r†rzr|r;rV)    rrhr    r7r r r=r?r)rArtrƒrvrBr€rrrs        r%Ú_explain_predictionsz#_MyModelCommon._explain_predictionsèsò€ô8    jÔ!ÜÐ'Ô(à ˆ?Ø-Ð/GÐHˆGà ×ÑÔä  × 2Ñ 2Ó 3ð    °vÜ'7¸Ó'@Ñ $ˆL˜*Ü ØðØ×(Ñ(Ð)¨¨:¨,ð7ØŸ™Ð'ð(Ø×(Ñ(Ð)¨Ð+<Ð*=¸SØ#nØð ð"õ ô ˜ .°×1AÑ1AÐ0BÀ!ÐDUÐCVРWÔ XÜ# FÓ+ˆBà÷#    ÷    ò    ús ÁA6CÃC )r N)r(r)r*r+rr,rrr#rrCÚboolrMÚdictrbrdr>rhrHrsr‚r‡ÚfloatrŠÚpdÚ    DataFramerŽr4r'r%r6r6Zsr„ñ ð"%,×$:Ñ$:Ø$(ñ    ,Và.ð,VðC˜LÑ!ð,Vð˜S‘Mó    ,Vð\'˜tó'ð0-¨#ð-°(¸4±.ó-ð^ 5 ¨¡ó 5ð 8°3ð 8¸4ó 8ó2ð*/˜3ó/ð& !˜tó !ðD7àð7ð% S™Mð7ð˜$‘ð    7ð
 
ó 7ðr,Øð,Ø25ð,Ø@HÈÁð,à     ó,ð\:!àð:!ð ð:!ðð    :!ð
˜$‘ð :!ð
ó :!ðx5Øð5Ø25ð5Ø@HÈÁð5à     ‰ô5r'r6c óè—eZdZdZ    d deej ejfde    eej ejfde    e
ddfd„Z     d deej ejfde    e
dej fd„Z     d deej ejfdeej ejfd    e de    e
def
d
„Z    d deej ejfdedej fd „Zy) ÚMyModelzó
    Convenience class for managing the ML workflow using pandas DataFrames.
 
    Methods convert in-memory DataFrames into temp SQL tables before delegating to the
    _MyMLModelCommon routines, and automatically clean up temp resources.
    NÚXÚyrvr cóV‡—t‰«t|«cŠ}t|j«5}t|j«5}|mt    |t
j «r|jd}ntˆfd„«}|‰jvrtd|›d«‚‰j«}|||<|}nd}‰}t||j|«\}    }
|j|j|
f«|j|
||«ddd«ddd«y#1swYŒxYw#1swYyxYw)a´
        Fit a model using DataFrame inputs.
 
        If an 'id' column is defined in either dataframe, it will be used as the primary key.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-train.html
                A full list of supported options can be found under "Common ML_TRAIN Options"
 
        Args:
            X: Features DataFrame.
            y: (Optional) Target labels DataFrame or Series. If None, only X is used.
            options: Additional options to pass to training.
 
        Returns:
            None
 
        Raises:
            DatabaseError:
                If provided options are invalid or unsupported.
                If a database connection issue occurs.
                If an operational error occurs during execution.
 
        Notes:
            Combines X and y as necessary. Creates a temporary table in the schema for training,
            and deletes it afterward.
        Nrcó •—|‰jvSrQ©Úcolumns©Únamer–s €r%ú<lambda>zMyModel.fit.<locals>.<lambda>Usø€ T°·±Ð%:€r'zTarget column y with name z' already present in feature dataframe X)r
r    r7rr"r’r“r›r Ú
ValueErrorr}rr=Úappendr‚) rAr–r—rvrBÚtemporary_tablesruÚ df_combinedÚfinal_dfÚ_rts  `         r%Úfitz MyModel.fit(s1ø€ôB˜QÓ¤¨qÓ!1ˆˆˆ1ô ˜t×1Ñ1Ó 2ð    ?Ø6<Ü   ×!3Ñ!3Ó 4ð    ?à8Hàˆ}ܘa¤§¡Ô.à)*¯©°1©Ñ&ä)8Û:ó*Ð&ð&¨¯©Ñ2Ü$Ø4Ð5GÐ4HðI1ð1óðð
 Ÿf™f›h Ø23 Ð.Ñ/Ø&‘à%)Ð"ؐä-¨f°d×6FÑ6FÈÓQ‰MˆAˆzØ × #Ñ # T×%5Ñ%5°zÐ$BÔ Cà I‰IjÐ"4°gÔ >÷;    ?÷    ?÷    ?ñ    ?ú÷    ?ð    ?ús$®DÁB>DÄDÄD    ÄDÄD(cóB‡‡—t|«}t‰j«5Št‰j«5}t    ‰‰j
|«\}}|j ‰j
|f«tˆˆfd„«}|j ‰j
|f«‰j|||«t‰‰j
|«}|djtj«|d<|cddd«cddd«S#1swYnxYwddd«y#1swYyxYw)aõ
        Generate model predictions using DataFrame input.
 
        If an 'id' column is defined in either dataframe, it will be used as the primary key.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-predict-table.html
                A full list of supported options can be found under "ML_PREDICT_TABLE Options"
 
        Args:
            X: DataFrame containing prediction features (no labels).
            options: Additional prediction settings.
 
        Returns:
            DataFrame with prediction results as returned by HeatWave.
 
        Raises:
            DatabaseError:
                If provided options are invalid or unsupported,
                or if the model is not initialized, i.e., fit or import has not
                been called
                If a database connection issue occurs.
                If an operational error occurs during execution.
 
        Notes:
            Temporary SQL tables are created and deleted for input/output.
        có4•—t‰‰j|« SrQ©rr=©rtrBrAs €€r%ržz!MyModel.predict.<locals>.<lambda>”󸀤|ؘD×,Ñ,¨jó(ð$€r'Ú
ml_resultsN) r
r    r7rrr=r r r‡rÚmaprRrS)    rAr–rvr¡r¤rtrƒÚ predictionsrBs    `       @r%ÚpredictzMyModel.predictjs    ù€ô@ ˜!Ó ˆô ˜t×1Ñ1Ó 2ð    Ø6<Ü   ×!3Ñ!3Ó 4ð    à8Hä-¨f°d×6FÑ6FÈÓJ‰MˆAˆzØ × #Ñ # T×%5Ñ%5°zÐ$BÔ Cä /ôó!Ð ð
× #Ñ # T×%5Ñ%5Ð7HÐ$IÔ Jà M‰M˜*Ð&7¸Ô AÜ)¨&°$×2BÑ2BÐDUÓVˆKð)4°LÑ(A×(EÑ(EÄdÇjÁjÓ(QˆK˜ Ñ %à÷)    ÷    ÷    ó    ú÷    ÷    ñ    ús#£D¹B4DÃ-    DÄD        ÄDÄDrˆcóÔ‡—t‰«t|«cŠ}t|j«5}t|j«5}t    ˆfd„«}‰j «}|||<|}    t ||j|    «\}
} |j|j| f«|j| |||«} | cddd«cddd«S#1swYnxYwddd«y#1swYyxYw)a
        Score the model using X/y data and a selected metric.
 
        If an 'id' column is defined in either dataframe, it will be used as the primary key.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-score.html
                A full list of supported options can be found under
                "Options for Recommendation Models" and
                "Options for Anomaly Detection Models"
 
        Args:
            X: DataFrame of features.
            y: DataFrame or Series of labels.
            metric: Metric name (e.g., "balanced_accuracy").
            options: Optional ml scoring options.
 
        Raises:
            DatabaseError:
                If provided options are invalid or unsupported,
                or if the model is not initialized, i.e., fit or import has not
                been called
                If a database connection issue occurs.
                If an operational error occurs during execution.
 
        Returns:
            float: Computed score.
        có •—|‰jvSrQršrœs €r%ržzMyModel.score.<locals>.<lambda>Ësø€¸dÈ!Ï)É)Ð>S€r'N)
r
r    r7rr r}rr=r rŠ) rAr–r—rˆrvrBr¡rur¢r£r¤rtÚscores  `           r%r±z MyModel.score¢sÞø€ôF˜QÓ¤¨qÓ!1ˆˆˆ1ô ˜t×1Ñ1Ó 2ð    Ø6<Ü   ×!3Ñ!3Ó 4ð    à8Hä!0Ó1SÓ!TÐ ØŸ&™&›(ˆKØ./ˆKÐ*Ñ +Ø"ˆHä-¨f°d×6FÑ6FÈÓQ‰MˆAˆzØ × #Ñ # T×%5Ñ%5°zÐ$BÔ Cà—K‘K 
Ð,>ÀÈÓPˆEà÷    ÷    ÷    ó    ú÷    ÷    ñ    ús$®CÁA2C    Â6    Cà   C    ÃCÃC'cóʇ‡—t|«}t‰j«5Št‰j«5}t    ‰‰j
|«\}}|j ‰j
|f«tˆˆfd„«}|j ‰j
|f«‰j|||«}|cddd«cddd«S#1swYnxYwddd«y#1swYyxYw)a 
        Explain model predictions using provided data.
 
        If an 'id' column is defined in either dataframe, it will be used as the primary key.
 
        References:
            https://dev.mysql.com/doc/heatwave/en/mys-hwaml-ml-explain-table.html
                A full list of supported options can be found under
                "ML_EXPLAIN_TABLE Options"
 
        Args:
            X: DataFrame for which predictions should be explained.
            options: Optional dictionary of explainability options.
 
        Returns:
            DataFrame containing explanation details (feature attributions, etc.)
 
        Raises:
            DatabaseError:
                If provided options are invalid or unsupported, or if the model is not initialized,
                i.e., fit or import has not been called
                If a database connection issue occurs.
                If an operational error occurs during execution.
 
        Notes:
            Temporary input/output tables are cleaned up after explanation.
        có4•—t‰‰j|« SrQr¨r©s €€r%ržz-MyModel.explain_predictions.<locals>.<lambda>rªr'N)    r
r    r7rrr=r r rŽ)    rAr–rvr¡r¤rtrƒÚ explanationsrBs    `       @r%Úexplain_predictionszMyModel.explain_predictions×sßù€ô@ ˜!Ó ˆô ˜t×1Ñ1Ó 2ð     Ø6<Ü   ×!3Ñ!3Ó 4ð     à8Hô.¨f°d×6FÑ6FÈÓJ‰MˆAˆzØ × #Ñ # T×%5Ñ%5°zÐ$BÔ Cä /ôó!Ð ð
× #Ñ # T×%5Ñ%5Ð7HÐ$IÔ Jà×4Ñ4ØÐ-¨wóˆLð ÷'     ÷     ÷     ó     ú÷     ÷     ñ     ús#£C¹A8CÂ1    CÃC     Ã    CÃC"rQ)r(r)r*r+rr’r“ÚnpÚndarrayrrr¥r®r#r‘r±rrµr4r'r%r•r• sJ„ñð#'ñ    @?à —‘˜rŸz™zÐ)Ñ *ð@?ð E˜"Ÿ,™,¨¯
©
Ð2Ñ3Ñ 4ð@?ð˜$‘ð    @?ð
 
ó @?ðJ#'ñ6à —‘˜rŸz™zÐ)Ñ *ð6ð˜$‘ð6ð
‰ó    6ðz#'ñ 3à —‘˜rŸz™zÐ)Ñ *ð3𠐗‘˜rŸz™zÐ)Ñ *ð3ðð    3ð
˜$‘ð 3ð
ó 3ðpñ5 à —‘˜rŸz™zÐ)Ñ *ð5 ðð5 ð
‰ô    5 r'r•)!r+r}rRÚenumrÚtypingrrrrÚnumpyr¶Úpandasr’Úmysql.ai.utilsrr    r
r r r rrrrrrrÚmysql.connector.abstractsrrr6r•r4r'r%ú<module>r¾saðñ8ó
 Û åß-Ó-ãÛ÷÷÷õõ>ôˆdô÷<CñCôLl ˆnõl r'