Files
airflow/dags/train/office/rent/predict.py
T
2025-01-17 18:40:44 +08:00

27 lines
909 B
Python

import numpy as np
from tensorflow import keras
# Load the model
model = keras.models.load_model('office_rent_model')
# Example input data (replace this with your actual data)
# Assuming your model expects 15 features as per your previous setup
input_data = np.array([[1, 0, 1, 0, 24, 1, 0, 1, 0, 6, 0, 0.7, 6, 7, 323.3]]) # One sample, 15 features
# Make predictions
predictions = model.predict(input_data)
# Print the prediction
print(f"Predicted rent price: {predictions[0][0]}")
# If you have multiple samples to predict
# input_data_multiple = np.array([
# [100.19, 0, 1, 0, 24, 1, 0, 1, 0, 6, 0, 0.7, 6, 7, 323.3],
# [52.79, 0, 1, 1, 9, 1, 0, 0, 1, 19, 1, 0.41, 26, 3, 392.3],
# # Add more samples here...
# ])
# predictions_multiple = model.predict(input_data_multiple)
# for i, pred in enumerate(predictions_multiple):
# print(f"Sample {i + 1} predicted rent price: {pred[0]}")