Files
hpos-data/cloud-functions/python/functions/sample_classification.py

23 lines
995 B
Python
Raw Normal View History

2023-11-13 07:37:20 +05:30
def sample_classification(event, context):
"""Triggered by a change to a Firestore document.
Args:
event (dict): Event payload.
context (google.cloud.functions.Context): Metadata for the event.
"""
resource_string = context.resource
# print out the resource string that triggered the function
print(f"Function triggered by change to: {resource_string}.")
# now print out the entire event object
print(str(event))
2023-12-08 21:44:55 +05:30
with open('label_encoder.pkl', 'rb') as label_encoder_file:
loaded_label_encoder = pickle.load(label_encoder_file)
with open('gaussian_naive_bayes_model.pkl', 'rb') as model_file:
loaded_model = pickle.load(model_file)
input_data = pd.DataFrame({'calculatedRatio': 0.231057205, 'deviceRatio': 0.231057205,'led1Buffer': 23776.33, 'led2Buffer': 26401.67,
'led1Sample': 16286, 'led2Sample': 6952.67}, index=[0])
predicted_result = loaded_model.predict(new_data)
print(predicted_result.item())