
    OKh4                         S SK r S SKrS SKJr  S SKrS SKJr  \" S5      r\" S5      r	Sq
S rS\S\R                  4S	 jrg)
    N)Path)get_prediction_inputzmodels/fpl_model.pklzdata/predictions/2526c                      [         c4   [        R                  " [        5      q [	        S[         S35        [         $ [         $ ! [
         a    [	        S[         S35        Sq  [         $ f = f)z5
Load the pre-trained model from the specified path.
NzModel loaded successfully from .zModel file not found at z9. Please ensure the model is trained and saved correctly.)modeljoblibload
MODEL_PATHprintFileNotFoundError     7G:\Projects\Python Projects\fpl_model\app\core\model.py
load_modelr      sg    
 }	KK
+E3J<qAB
 L5L	 ! 	,ZL8qrsEL		s   -A A)(A)gwreturnc                    [         c  [        S5      e[        U 5      nUS   nUR                  / SQSS9n[         R                  n[        U5      [        UR                  5      -
  n[        U5        [         R                  U5      n[        R                  " UUS.5      R                  SS9nUS   R                  S	5      R                  [        5      US'   US   R                  [        5      US'   UR                  [         S
U  S3-  SS9  U$ )z
Predict the target variable using the pre-trained model.

:param features: DataFrame containing the features for prediction.
:return: Series of predictions.
zEModel is not loaded. Please load the model before making predictions.id)r   teamnameignore)columnserrors)r   
prediction)byr   r   r   z_predictions.csvF)index)r   
ValueErrorr   dropfeature_names_in_setr   r   predictpd	DataFramesort_valuesroundastypeintto_csvPREDICTIONS_PATH)r   
input_dataidsmodel_feature_namesmissing_featuresr   results          r   r!   r!      s    }`aa &b)J
T
C)?xPJ11./#j6H6H2II	
z*J\\   {d{  #<066q9@@EFL4L'',FDM
MM"r"-=%>>eMLMr   )r   ospathlibr   pandasr"   scripts.get_prediction_inputr   r
   r)   r   r   r'   r#   r!   r   r   r   <module>r3      sN     	   = ()
/0 s r|| r   