diff --git a/mastering-carol/batch-data-app/main.py b/mastering-carol/batch-data-app/main.py index fba25db..692f844 100644 --- a/mastering-carol/batch-data-app/main.py +++ b/mastering-carol/batch-data-app/main.py @@ -5,14 +5,16 @@ from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error + import matplotlib.pyplot as plt +import numpy as np import logging from google.cloud import bigquery from dotenv import load_dotenv from pycarol.apps import Apps -from pycarol import Carol +from pycarol import Carol, Staging load_dotenv(".env") @@ -96,4 +98,22 @@ plt.xlabel('Actual Values') plt.ylabel('Predicted Values') plt.title('Actual vs Predicted Values') -plt.show() +# plt.show() + +columns = [ + 'dt_invoice_weekday', + 'businesspartner_id_fa426a07b9b70daaedbd7c85fd53901c', + 'businesspartner_id_fd2b7dbe63b9cfc558eca54f494db2c2', + 'predictValue' +] + +df = pd.DataFrame(X_test, columns=columns[:-1]) # Exclude the last column from data_array +df[columns[-1]] = y_pred +df['executionDate'] = pd.Timestamp('now') +df['rowNumber'] = np.arange(df.shape[0]) + +print(df) + +staging = Staging(Carol()) +staging.send_data(staging_name = 'execution_history', data = df, step_size = 2, + connector_id='f673daea3af94179b06b1db79b979430', print_stats = True) diff --git a/mastering-carol/batch-data-app/manifest.json b/mastering-carol/batch-data-app/manifest.json new file mode 100644 index 0000000..b506019 --- /dev/null +++ b/mastering-carol/batch-data-app/manifest.json @@ -0,0 +1,34 @@ +{ + "batch": { + "processes": [ + { + "algorithmDescription": { + "en-US": "Linear Regression Model" + }, + "algorithmName": "batch_data", + "algorithmTitle": { + "en-US": "Linear Regression Model" + }, + "instanceProperties": { + "profile": "", + "properties": { + "instanceType": "c1.small", + "dockerImage": "customerdataappp/batch-data-app", + "preemptible": true + } + }, + "name": "batch_data" + } + ] + }, + "docker": [ + { + "dockerName": "batch-data-app", + "dockerTag": "0.1.0", + "gitBranch": "master", + "gitPath": "/mastering-carol/batch-data-app", + "gitDockerfileName": "Dockerfile", + "gitRepoUrl": "https://github.com/totvslabs/carolapp-samples" + } + ] +} diff --git a/mastering-carol/online-data-app/manifest.json b/mastering-carol/online-data-app/manifest.json index cdf5a80..57e608b 100644 --- a/mastering-carol/online-data-app/manifest.json +++ b/mastering-carol/online-data-app/manifest.json @@ -13,7 +13,7 @@ "profile": "", "properties": { "instanceType": "c1.small", - "dockerImage": "online-data-app", + "dockerImage": "customerdataappp/online-data-app", "autoscale": { "enabled": false, "minReplicas": 1,