From 8e1093de4733d999cdf0823d7917c6f64d20605a Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Fri, 8 Dec 2023 21:44:55 +0530 Subject: [PATCH] sample classifier function --- .../python/functions/sample_classification.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cloud-functions/python/functions/sample_classification.py b/cloud-functions/python/functions/sample_classification.py index 84aed14..bf662b1 100644 --- a/cloud-functions/python/functions/sample_classification.py +++ b/cloud-functions/python/functions/sample_classification.py @@ -9,3 +9,15 @@ def sample_classification(event, context): print(f"Function triggered by change to: {resource_string}.") # now print out the entire event object print(str(event)) + + 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()) \ No newline at end of file