14 lines (14 with data), 1.5 kB
o
mªìf] ã @ sþ d dl mZmZ d dlZd dlmZmZ d dlZd dl Z
d dlZe
dd
Ze e¡ZW d n1 s5w Y e
dd
Ze e¡ZW d n1 sOw Y e
dd
Ze e¡ZW d n1 siw Y e Ze d¡d efd
dZdS )é )Ú
PreprocessÚMissingValueN)ÚFastAPIÚRequestzmodel/columns.pklÚrbzmodel/scaler.pklzmodel/model.pklz /predict/Úrequestc
à sî z]| ¡ I d H }tj|dd}t|dddd}| |¡}t|}| ¡ }|t }t |¡}d}t
|¡}| ¡ d j
} | ¡ d j
}
tj|tjd}| |
g| |i¡}|d }d| ¡ iW S tyv } zdt|iW Y d }~S d }~ww ) NÚrecords)Zorientr )Z dataframeZmissing_value_perZvariance_thresholdZmin_null_perz(model/optimized_random_forest_model.onnx)ZdtypeZpredictionsÚerror)ÚjsonÚpdZ read_jsonr Ú_mappingr Zfill_dataframeÚcolsÚscZ transformÚortZInferenceSessionZ
get_inputsÚnameZget_outputsÚnpZarrayZfloat32ÚrunÚtolistÚ ExceptionÚstr)
r ÚdataZdfZpreprocessorÚtestÚmZx_testZoptimized_model_pathÚsessionZ
input_nameZoutput_nameZy_predÚe© r ú)C:\Users\mohammad\Desktop\q3 (2)\.\app.pyÚpredict s6 ü
ÿr )Úutilsr r ÚpickleZfastapir r Zpandasr Znumpyr Zonnxruntimer ÚopenÚfÚloadr
r ÚmodelÚappZpostr r r r r Ú<module> s$ ÿÿÿ