/var/opt/nydus/ops/mysql/ai/ml/__pycache__
NameSizeModeActions
base.cpython-312.pyc47860644editdlrm
classifier.cpython-312.pyc75470644editdlrm
model.cpython-312.pyc305340644editdlrm
outlier.cpython-312.pyc80480644editdlrm
regressor.cpython-312.pyc54700644editdlrm
transformer.cpython-312.pyc61060644editdlrm
__init__.cpython-312.pyc7640644editdlrm
Edit: /var/opt/nydus/ops/mysql/ai/ml/__pycache__/classifier.cpython-312.pyc (7547B)
N j|dZddlmZmZddlZddlZddlm Z ddl m Z ddl m Z ddlmZddlmZGd d e e Zy) zwClassifier utilities for MySQL Connector/Python. Provides a scikit-learn compatible classifier backed by HeatWave ML. )OptionalUnionN)ClassifierMixin) MyBaseMLModel)ML_TASK) copy_dict)MySQLConnectionAbstractc PeZdZdZ ddedeedeedeedeef dZd e e je jfd e jfd Zd e e je jfd e jfd Zd e e je jfd e jfd Zy) MyClassifiera MySQL HeatWave scikit-learn compatible classifier estimator. Provides prediction and probability output from a model deployed in MySQL, and manages fit, explain, and prediction options as per HeatWave ML interface. Attributes: predict_extra_options (dict): Dictionary of optional parameters passed through to the MySQL backend for prediction and probability inference. _model (MyModel): Underlying interface for database model operations. fit_extra_options (dict): See MyBaseMLModel. Args: db_connection (MySQLConnectionAbstract): Active MySQL connector DB connection. model_name (str, optional): Custom name for the model. fit_extra_options (dict, optional): Extra options for fitting. explain_extra_options (dict, optional): Extra options for explanations. predict_extra_options (dict, optional): Extra options for predict/predict_proba. Methods: predict(X): Predict class labels. predict_proba(X): Predict class probabilities. N db_connection model_namefit_extra_optionsexplain_extra_optionspredict_extra_optionsctj||tj||t ||_t ||_y)a Initialize a MyClassifier. Args: db_connection: Active MySQL connector database connection. model_name: Optional, custom model name. fit_extra_options: Optional fit options. explain_extra_options: Optional explain options. predict_extra_options: Optional predict/predict_proba options. Raises: DatabaseError: If a database connection issue occurs. If an operational error occurs during execution. )r rN)r__init__rCLASSIFICATIONrrr)selfr r rrrs G/opt/nydus/tmp/pip-target-a90h98xg/lib/python/mysql/ai/ml/classifier.pyrzMyClassifier.__init__GsE.     " "!/  &//D%E"%./D%E"Xreturncv|jj||j}|djS)a Predict class labels for the input features using the MySQL model. 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: Input samples as a numpy array or pandas DataFrame. Returns: ndarray: Array of predicted class labels, shape (n_samples,). 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. options Prediction)_modelpredictrto_numpy)rrresults rrzMyClassifier.predicths70$$Q0J0J$Kl#,,..rc|jj||j}t|djddj t j|djfdS)a* Predict class probabilities for the input features using the MySQL model. 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: Input samples as a numpy array or pandas DataFrame. Returns: ndarray: Array of shape (n_samples, n_classes) with class probabilities. 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. r ml_resultsr probabilitiesc:Dcgc] }|d| c}Scc}w)Nr#) ml_result class_nameclassess rz,MyClassifier.predict_proba..s)MT#MTzIo.z:W##s) rrrsortedilockeysnpstackmap)rrr r(s @r predict_probazMyClassifier.predict_probasu0$$Q0J0J$K -2215oFKKMNxx < $ $   rcR|jj||jy)ai Explain model predictions using 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: X: DataFrame for which predictions should be explained. 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. rN)rexplain_predictionsr)rrs rr2z MyClassifier.explain_predictionss!6 ''43M3M'Nr)NNNN)__name__ __module__ __qualname____doc__r rstrdictrrpd DataFramer-ndarrayrr0r2r%rrr r .s6%),00404 F.FSMF$D> F (~ F (~ FB/r||RZZ/0/ /6" r||RZZ/0" " HOr||RZZ/0O Orr )r6typingrrnumpyr-pandasr9 sklearn.basermysql.ai.ml.basermysql.ai.ml.modelrmysql.ai.utilsrmysql.connector.abstractsr r r%rrrDs6:#(*%$=TO=/TOr