CoolFace
Apppublic

Devina707/Building-Energy-Demand-Prediction

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
m2_prediction.cpython-310.pyc41 linesDownload Raw Back to __pycache__
1o

2�u�i��@sbddlZddlZddlZddlZddlZejdd��Z	e	�Z3dd�Zdd�Ze
dkr/e�dSdS)	�NcCst�d�}|S)Nz ./src/pipelines_inference_st.pkl)�joblib�load)�pipelines_inference_st�r�ED:\Workspace\Phase1\M2-Energy-Demand-Predictor\./src\m2_prediction.py�4load_models5rcCs�|��}t�|d�|d<|djj|d<dd�}|djj�|�|d<dd�}|d�|�|d	<d6d�}|j|dd
�|d<|S)z@7    To apply the same feature engineering as training data8    �9Time Stamp�TimecSs8d|krdkrdSd|krdkrdSdSdS)N��zMorning/Day�zAfternoon/EveningZNightr)�hourrrr�categorize_times��z2preprocess_inference_data.<locals>.categorize_timez
Time CategorycSs|dkrdS|dkrdSdS)Ni�z!Pre-Energy Code Era (before 1981)i�z!Post-Energy Code Era (after 1980)r)�yearrrr�categorize_era*s10�z1preprocess_inference_data.<locals>.categorize_era�11Year BuiltzEra CategorycSs$|ddkrdS|ddkrdSdS)N�12Meter TyperZElectricity�z	Hot Waterr)�rowrrr�categorize_meter3s13�z3preprocess_inference_data.<locals>.categorize_meter�)�axiszMeter Type Category)�copy�pd�to_datetime�dt�timer
�apply)�data�dfrrrrrr�preprocess_inference_datasr c	Cs$tjdd���t�d�tjddddd�}tjddddd�}tjd	dddd�}t�d14�t�d�t�dd
�}tjdddddd�}tjddtj��jddd�}tjdddddd�}tjdddd�}t�d15�t�d�t�	d�\}}	|�
t�16d �}17Wd�n1s�wY|	�tjd!t�dd�d"�}Wd�n1s�wYtj�
|18|�}tjd#d$d%d&d'd�}
tjd(dd)ddd�}tjd*d+d,dd'd�}tjd-dd.dd'd�}tjd/d0d1d2d'd�}tjd3dd4d5dd�}tjd6dd%d7d'd�}t�d19�t�d8�}Wd�n	1�swY|�r�t�d9��pid|�d|�d	|�d|�d|�d|�d|�d|�d:|�d#|
�d(|�d*|�d-|�d;|�d3|�d6|�}t�|g�}t|�}t�d<�t�d20�t�|�t�|�}t�d=�t�d>�t�t|d�d?�d@��Wd�dS1�s�wYdSdS)ANZform_energy_predictor)�keyz### ID Information�IDri@B)�	min_value�	max_value�stepzBuilding IDzSite IDz---z### Building InformationzBuilding Use)Z	EducationZOfficezPublic serviceszLodging/residentialzEntertainment/public assemblyzBuilding Area (sqft)gg _�Bg��@g$@)r#r$�valuer%rili�zFloor Countri�r)rrz0=Electricity; 3= Hot Water)�helpz### Weather Information��Dater	)r&uAir Temperature (°C)gY�gY@g9@g�������?zCloud Coverage (oktas)�uDew Temperature (°C)gI�gN@zPrecipitation Depth (mm/hr)g�r@zSea Level Pressure (mbar/hPa)g0�@g33333�@g��@zWind Direction (degree)ih�zWind Speed (m/s)g@ZPredictzPredicting... please waitrzSea Level Pressure (mbar)z### Input DatazPrediction complete!z## Predicted Meter Reading:z,.2fz kWh)�st�form�markdown�number_input�	selectbox�datetime�date�todayr�columns�21date_input�22time_inputr�combine�form_submit_button�spinnerr�	DataFramer �	dataframer�predict�success�write�float)�idZbuilding_idZsite_idZbuilding_useZ
building_areaZ23year_builtZfloor_countZ24meter_type�col1�col2r2r�25time_stampZair_tempZcloud_coverZdew_tempZprecip_depthZ26sealv_presZwind_dirZwind_spdZ	submittedZdata_infZy_predrrr�run>s�2728293031��32�$��������	�33���
����343536373839$��rD�__main__)�	streamlitr,�pandasr�numpy�npr1r�cache_resourcerrr rD�__name__rrrr�<module>s40,N41�