├── .gitignore
├── 24.1
├── QuickStart Autolog.ipynb
├── QuickStart.ipynb
├── samples
│ ├── CDT-Notebook.ipynb
│ ├── Validation library
│ │ └── ValidationLibrary.ipynb
│ ├── autolog
│ │ ├── CDT_example_autolog.ipynb
│ │ └── Kaggle_notebook.ipynb
│ └── mlflow_sample.ipynb
└── tutorial
│ ├── Business Review.ipynb
│ ├── Data Preparation.ipynb
│ ├── Data Understanding.ipynb
│ ├── Model Deployment.ipynb
│ ├── Model Retraining.ipynb
│ ├── Model Staging.ipynb
│ ├── Modeling.ipynb
│ └── README.md
├── 24.2.11
├── QuickStart Autolog.ipynb
├── QuickStart.ipynb
└── tutorial
│ ├── Business Review.ipynb
│ ├── Data Preparation.ipynb
│ ├── Data Understanding.ipynb
│ ├── Model Deployment.ipynb
│ ├── Model Retraining.ipynb
│ ├── Model Staging.ipynb
│ ├── Modeling.ipynb
│ └── README.md
├── 24.2
├── QuickStart Autolog.ipynb
├── QuickStart.ipynb
├── samples
│ ├── CDT-Notebook.ipynb
│ ├── Validation library
│ │ └── ValidationLibrary.ipynb
│ ├── autolog
│ │ ├── CDT-Notebook_Monitoring.ipynb
│ │ ├── CDT_example_autolog.ipynb
│ │ └── Kaggle_notebook.ipynb
│ └── mlflow_sample.ipynb
└── tutorial
│ ├── Business Review.ipynb
│ ├── Data Preparation.ipynb
│ ├── Data Understanding.ipynb
│ ├── Model Deployment.ipynb
│ ├── Model Retraining.ipynb
│ ├── Model Staging.ipynb
│ ├── Modeling.ipynb
│ └── README.md
├── 24.3.9
├── QuickStart Autolog.ipynb
└── tutorial
│ ├── Business Review.ipynb
│ ├── Data Preparation.ipynb
│ ├── Data Understanding.ipynb
│ ├── Model Deployment.ipynb
│ ├── Model Retraining.ipynb
│ ├── Model Staging.ipynb
│ ├── Modeling.ipynb
│ └── README.md
├── 24.3
├── QuickStart Autolog.ipynb
├── QuickStart.ipynb
├── samples
│ ├── CDT-Notebook.ipynb
│ ├── Validation library
│ │ └── ValidationLibrary.ipynb
│ ├── autolog
│ │ ├── CDT-Notebook_Monitoring.ipynb
│ │ ├── CDT_example_autolog.ipynb
│ │ └── Kaggle_notebook.ipynb
│ └── mlflow_sample.ipynb
└── tutorial
│ ├── Business Review.ipynb
│ ├── Data Preparation.ipynb
│ ├── Data Understanding.ipynb
│ ├── Model Deployment.ipynb
│ ├── Model Retraining.ipynb
│ ├── Model Staging.ipynb
│ ├── Modeling.ipynb
│ └── README.md
├── LICENSE
├── QuickStart Autolog.ipynb
├── README.md
├── Tutorial data
├── MAE by month.csv
├── Predictions and Actuals.csv
├── ProductSales Cleaned.csv
├── README.md
└── SampleSuperstore.csv
└── tutorial
├── Business Review.ipynb
├── Data Preparation.ipynb
├── Data Understanding.ipynb
├── Model Deployment.ipynb
├── Model Retraining.ipynb
├── Model Staging.ipynb
├── Modeling.ipynb
├── README.md
└── Tutorial_Probability_of_Default.ipynb
/.gitignore:
--------------------------------------------------------------------------------
1 | Notebooks/Corpo_fav_cleaned.csv
2 | Notebooks/Data_Preparation_old.ipynb
3 | Notebooks/Eric_Modeling_LR.ipynb
4 | Notebooks/holidays_events.csv
5 | Notebooks/items.csv
6 | Notebooks/oil.csv
7 | Notebooks/r4modeling.csv
8 | Notebooks/r4modeling.csv.zip
9 | Notebooks/stores.csv
10 | Notebooks/test_lr.csv
11 | Notebooks/train_clean.csv
12 | Notebooks/train_lr.csv
13 | Notebooks/train_reduced.csv
14 | Notebooks/train_trimmed.csv
15 | Notebooks/transactions.csv
16 | Notebooks/Tutorial_API_token.json
17 | 22.4/
18 | *.DS_Store
19 | *.png
20 | *.csv
21 | *.jpg
22 | *.json
23 | *.csv.*
--------------------------------------------------------------------------------
/24.1/QuickStart Autolog.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "
\n",
9 | ""
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {
15 | "id": "twIzT22mtqhs"
16 | },
17 | "source": [
18 | "# Before you start with this Quickstart Notebook"
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "metadata": {
24 | "id": "iUp4X8V5tqhv"
25 | },
26 | "source": [
27 | "You will need:\n",
28 | "* An account in Vectice\n",
29 | "* An API key to connect to Vectice\n",
30 | "* The Phase Id of the project where you want to log your work\n",
31 | "\n",
32 | "### Important Resources\n",
33 | "* Vectice autolog documentation: https://api-docs.vectice.com/24.1/reference/vectice/autolog/\n"
34 | ]
35 | },
36 | {
37 | "cell_type": "markdown",
38 | "metadata": {
39 | "id": "jER4KBN0JbSw"
40 | },
41 | "source": [
42 | "
\n",
43 | "Automated code lineage: The code lineage functionalities are not covered as part of this QuickStart as they require first setting up a Git repository.\n",
44 | "
\n",
45 | "\n",
46 | "\n",
47 | "\n",
48 | "---\n",
49 | "\n"
50 | ]
51 | },
52 | {
53 | "cell_type": "markdown",
54 | "metadata": {
55 | "id": "7LArs6J5fyIz"
56 | },
57 | "source": [
58 | "## What to expect\n",
59 | "\n",
60 | "In this notebook, we will re-use the classical Iris modeling example to demonstrate how you can automatically document in Vectice your assets, such as datasets, models, graphs, and notes, using a few lines of code."
61 | ]
62 | },
63 | {
64 | "cell_type": "markdown",
65 | "metadata": {
66 | "id": "BWxVwtAdgSbj"
67 | },
68 | "source": [
69 | "## Install the latest Vectice Python client library"
70 | ]
71 | },
72 | {
73 | "cell_type": "code",
74 | "execution_count": null,
75 | "metadata": {
76 | "id": "bin0M8rKdfBU"
77 | },
78 | "outputs": [],
79 | "source": [
80 | "%pip install -q seaborn\n",
81 | "%pip install -q scikit-learn\n",
82 | "%pip install -q vectice -U\n",
83 | "%pip install \"vectice[autolog]\" -q"
84 | ]
85 | },
86 | {
87 | "cell_type": "markdown",
88 | "metadata": {
89 | "id": "1bwpySvqf5Ce"
90 | },
91 | "source": [
92 | "## Get started configuring the Vectice autolog"
93 | ]
94 | },
95 | {
96 | "cell_type": "markdown",
97 | "metadata": {
98 | "id": "jx5xlQFJxxQZ"
99 | },
100 | "source": [
101 | "**First, you need to configure the autolog. You will need your API key and Phase ID inside your Quickstart project to specify where to document your work. Before proceeding:**\n",
102 | "\n",
103 | "- Click on the key icon in the upper right corner of the Vectice app to create an API key, then copy and paste it into the code below.\n",
104 | "\n",
105 | "- In your Quickstart project, go to [Phase 2] Autolog phase and copy its Phase ID to paste in the code below."
106 | ]
107 | },
108 | {
109 | "cell_type": "code",
110 | "execution_count": null,
111 | "metadata": {
112 | "id": "frnhI_W9aOoZ"
113 | },
114 | "outputs": [],
115 | "source": [
116 | "import vectice\n",
117 | "from vectice import autolog\n",
118 | "\n",
119 | "autolog.config(api_token=\"your-api-key\", phase=\"your-phase-id\") #Paste your API key and Phase Id"
120 | ]
121 | },
122 | {
123 | "cell_type": "markdown",
124 | "metadata": {},
125 | "source": [
126 | "\n",
127 | " Important information:\n",
128 | "
Vectice Autolog is continuously evolving and we are actively enhancing supported libraries, environments, and functionalities to provide an improved user experience. \n",
129 | " Be sure to configure autolog at the beginning of your notebook. A late setup may require rerunning previous cells.\n",
130 | " Your feedback is highly valued. Please send any feedback to support@vectice.com.\n",
131 | "
\n",
132 | "\n",
133 | "For detailed information, supported libraries and environments, please consult our [Autolog documentation](https://api-docs.vectice.com/24.1/reference/vectice/autolog/).\n",
134 | ""
135 | ]
136 | },
137 | {
138 | "cell_type": "markdown",
139 | "metadata": {
140 | "id": "FYeCGcgLlsOL"
141 | },
142 | "source": [
143 | "# Auto-Document your work in Vectice\n",
144 | "We will prepare an example dataset based on the well-known iris dataset. We will then train a linear regression model using scikit-learn.\n",
145 | "After we complete this work and create those assets, we will log them to Vectice in a single line of code.\n",
146 | "This enables you to document your work as you go, and to never forget the data that was used, the models, the code and other artifacts."
147 | ]
148 | },
149 | {
150 | "cell_type": "markdown",
151 | "metadata": {
152 | "id": "6VvbrEsKl5bH"
153 | },
154 | "source": [
155 | "Use the following code block to create a dataset, generate a graph and build a model:"
156 | ]
157 | },
158 | {
159 | "cell_type": "code",
160 | "execution_count": null,
161 | "metadata": {
162 | "id": "jMC05CI6epHw"
163 | },
164 | "outputs": [],
165 | "source": [
166 | "import pandas as pd\n",
167 | "from sklearn import datasets\n",
168 | "\n",
169 | "iris = datasets.load_iris()\n",
170 | "\n",
171 | "df_iris = pd.DataFrame(data=iris.data, columns=iris.feature_names)\n",
172 | "df_iris['species'] = iris.target_names[iris.target]\n"
173 | ]
174 | },
175 | {
176 | "cell_type": "code",
177 | "execution_count": null,
178 | "metadata": {
179 | "id": "OMaIknlOtqh3"
180 | },
181 | "outputs": [],
182 | "source": [
183 | "import seaborn as sns\n",
184 | "import matplotlib.pyplot as plt\n",
185 | "\n",
186 | "sns.scatterplot(data=df_iris, x='sepal length (cm)',\n",
187 | " y='petal width (cm)', hue='species')\n",
188 | "plt.plot()\n",
189 | "\n",
190 | "#Save your graph to local file to be automatically captured by Vectice \n",
191 | "plt.savefig('Scatter_plot_iris.png') "
192 | ]
193 | },
194 | {
195 | "cell_type": "markdown",
196 | "metadata": {},
197 | "source": [
198 | "**Note**: Save graphs you want to log into a local file to be automatically captured by the autolog.
"
199 | ]
200 | },
201 | {
202 | "cell_type": "code",
203 | "execution_count": null,
204 | "metadata": {
205 | "id": "N0wsppAltqh5"
206 | },
207 | "outputs": [],
208 | "source": [
209 | "from sklearn.neighbors import KNeighborsClassifier\n",
210 | "from sklearn.model_selection import train_test_split\n",
211 | "from sklearn.metrics import accuracy_score\n",
212 | "\n",
213 | "train_df, test_df = train_test_split(df_iris, test_size=0.2, random_state=42)\n",
214 | "\n",
215 | "knn = KNeighborsClassifier()\n",
216 | "knn.fit(train_df[iris.feature_names],train_df[\"species\"])\n",
217 | "\n",
218 | "# Make predictions on the test set\n",
219 | "y_pred_test = knn.predict(test_df[iris.feature_names])\n",
220 | "y_pred_train = knn.predict(train_df[iris.feature_names])\n",
221 | "\n",
222 | "# Calculate the accuracy score\n",
223 | "accuracy_test= accuracy_score(test_df[\"species\"], y_pred_test)\n",
224 | "accuracy_train = accuracy_score(train_df[\"species\"], y_pred_train)"
225 | ]
226 | },
227 | {
228 | "cell_type": "markdown",
229 | "metadata": {},
230 | "source": [
231 | "**Note**: To link models and metrics using Vectice autolog, ensure each model and its metrics are in the same notebook cell (scikit metrics are currently supported)."
232 | ]
233 | },
234 | {
235 | "cell_type": "markdown",
236 | "metadata": {},
237 | "source": [
238 | "## Autolog your entire notebook's assets (model, datasets, graphs and note) with a single line of code"
239 | ]
240 | },
241 | {
242 | "cell_type": "code",
243 | "execution_count": null,
244 | "metadata": {
245 | "id": "g5FOnLfHnY14"
246 | },
247 | "outputs": [],
248 | "source": [
249 | "autolog.notebook(note=\"My first iteration to Vectice to document iris dataset\", capture_schema_only=False) #You can add a note to comment what you just logged into Vectice"
250 | ]
251 | },
252 | {
253 | "cell_type": "markdown",
254 | "metadata": {},
255 | "source": [
256 | "#### You have logged your assets to Vectice with a single line of code. You can click on the iteration link above to see your assets inside Vectice.\n",
257 | "**Note**: Autolog also allows you to log only the content of one cell, please check out our [documentation](https://api-docs.vectice.com/24.1/reference/vectice/autolog/) to learn more about the autolog functions and capabilities.
"
258 | ]
259 | },
260 | {
261 | "cell_type": "markdown",
262 | "metadata": {
263 | "id": "YnmFUplTpMoW"
264 | },
265 | "source": [
266 | "## 🥇 Congrats! You have learned how to successfully use Vectice to auto-document your assets in one line of code.
Easy right?
\n",
267 | "#### You can proceed back to the Vectice app continue documenting your work.\n"
268 | ]
269 | }
270 | ],
271 | "metadata": {
272 | "colab": {
273 | "provenance": []
274 | },
275 | "kernelspec": {
276 | "display_name": "Python 3",
277 | "name": "python3"
278 | },
279 | "language_info": {
280 | "codemirror_mode": {
281 | "name": "ipython",
282 | "version": 3
283 | },
284 | "file_extension": ".py",
285 | "mimetype": "text/x-python",
286 | "name": "python",
287 | "nbconvert_exporter": "python",
288 | "pygments_lexer": "ipython3",
289 | "version": "3.9.6"
290 | }
291 | },
292 | "nbformat": 4,
293 | "nbformat_minor": 0
294 | }
295 |
--------------------------------------------------------------------------------
/24.1/tutorial/Data Understanding.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "eabedfd0-bda4-4a9f-9ef2-6514a91dbb98",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Data Understanding Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Data Understanding\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.1/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.1/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.1/"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": null,
30 | "id": "6e6350fb-5aec-448e-9e86-4715055033ee",
31 | "metadata": {},
32 | "outputs": [],
33 | "source": [
34 | "import warnings\n",
35 | "warnings.filterwarnings(\"ignore\", category=DeprecationWarning)"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": null,
41 | "id": "dc1525e3-eb5c-4e5b-855f-47dc2229afbf",
42 | "metadata": {},
43 | "outputs": [],
44 | "source": [
45 | "import pandas as pd\n",
46 | "import numpy as np\n",
47 | "import seaborn as sns\n",
48 | "import matplotlib.pyplot as plt"
49 | ]
50 | },
51 | {
52 | "attachments": {},
53 | "cell_type": "markdown",
54 | "id": "6da9fd84-09a0-4d30-bc00-c91dea5cd98f",
55 | "metadata": {},
56 | "source": [
57 | "## Install the latest Vectice Python client library"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": null,
63 | "id": "43c38240-69a2-41fb-bda7-46b7c40b963f",
64 | "metadata": {},
65 | "outputs": [],
66 | "source": [
67 | "%pip install --q vectice -U"
68 | ]
69 | },
70 | {
71 | "attachments": {},
72 | "cell_type": "markdown",
73 | "id": "10195b2a-a959-4a7b-a20b-e45c292930ef",
74 | "metadata": {},
75 | "source": [
76 | "## Get started by connecting to Vectice"
77 | ]
78 | },
79 | {
80 | "cell_type": "code",
81 | "execution_count": null,
82 | "id": "d34bced5-491f-400b-ac5d-e4665f6f6ae8",
83 | "metadata": {},
84 | "outputs": [],
85 | "source": [
86 | "import vectice\n",
87 | "\n",
88 | "connect = vectice.connect(api_token=\"your-api-key\") #Paste your API key"
89 | ]
90 | },
91 | {
92 | "attachments": {},
93 | "cell_type": "markdown",
94 | "id": "90a36ebc-023d-4f18-8382-8d92044492e3",
95 | "metadata": {},
96 | "source": [
97 | "## Specify which project phase you want to document\n",
98 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Data Understanding phase and copy paste your Phase Id below."
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": null,
104 | "id": "9d57e0e9-fc47-4b91-81b0-2f79907c901a",
105 | "metadata": {},
106 | "outputs": [],
107 | "source": [
108 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Data Understanding Phase ID"
109 | ]
110 | },
111 | {
112 | "attachments": {},
113 | "cell_type": "markdown",
114 | "id": "9a7957b4-c5dc-49ff-9612-f58ee9e63146",
115 | "metadata": {},
116 | "source": [
117 | "## Next we are going to create an iteration\n",
118 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
119 | ]
120 | },
121 | {
122 | "cell_type": "code",
123 | "execution_count": null,
124 | "id": "b315169a-d68f-4a17-9b39-56694b8be697",
125 | "metadata": {},
126 | "outputs": [],
127 | "source": [
128 | "iteration = phase.create_or_get_current_iteration()"
129 | ]
130 | },
131 | {
132 | "cell_type": "code",
133 | "execution_count": null,
134 | "id": "6c59effc-5b3f-4b75-aae4-f3d46be1218f",
135 | "metadata": {},
136 | "outputs": [],
137 | "source": [
138 | "df = pd.read_csv(\"https://raw.githubusercontent.com/vectice/GettingStarted/main/23.3/tutorial/SampleSuperstore.csv\", converters = {'Postal Code': str})\n",
139 | "df.to_csv(\"SampleSuperstore.csv\", index=False)"
140 | ]
141 | },
142 | {
143 | "attachments": {},
144 | "cell_type": "markdown",
145 | "id": "ef495b02-b785-41d5-8741-0796c3cf8da2",
146 | "metadata": {},
147 | "source": [
148 | "## Log a dataset\n",
149 | "Use the following code block to create a local dataset and generate a graph:"
150 | ]
151 | },
152 | {
153 | "cell_type": "code",
154 | "execution_count": null,
155 | "id": "4722446c-389d-4543-9280-9558e0a07bb7",
156 | "metadata": {},
157 | "outputs": [],
158 | "source": [
159 | "origin_ds = vectice.FileResource(paths=\"SampleSuperstore.csv\", dataframes=df)\n",
160 | "\n",
161 | "\n",
162 | "origin_dataset = vectice.Dataset.origin(\n",
163 | " name=\"ProductSales Origin\",\n",
164 | " resource=origin_ds, \n",
165 | ")"
166 | ]
167 | },
168 | {
169 | "cell_type": "code",
170 | "execution_count": null,
171 | "id": "53bdadfd-c9d3-4c6e-acb4-930751df7a54",
172 | "metadata": {},
173 | "outputs": [],
174 | "source": [
175 | "iteration.log(origin_dataset, section = \"collect initial data\")"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": null,
181 | "id": "140a4667-ba4c-492b-820b-cfa676dfe184",
182 | "metadata": {},
183 | "outputs": [],
184 | "source": [
185 | "iteration.log(str(df.columns.values), section = \"describe data\")"
186 | ]
187 | },
188 | {
189 | "cell_type": "code",
190 | "execution_count": null,
191 | "id": "473c3d35-7050-4a06-b867-b2861755ee3d",
192 | "metadata": {},
193 | "outputs": [],
194 | "source": [
195 | "## Checking for Multicollinearity\n",
196 | "corr_matrix=df.select_dtypes(\"number\").drop(\"Sales\",axis=1).corr()\n",
197 | "sns.heatmap(corr_matrix);\n",
198 | "plt.savefig(\"corr_matrix.png\")"
199 | ]
200 | },
201 | {
202 | "attachments": {},
203 | "cell_type": "markdown",
204 | "id": "437759e3",
205 | "metadata": {},
206 | "source": [
207 | "## Log graphs"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "45b5eb6d",
214 | "metadata": {},
215 | "source": [
216 | "You can log multiple items to a single iteration by using the `iterarion.log()` method."
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": null,
222 | "id": "e95ed5c6-fb4b-47be-bd7c-00747f8a4f3e",
223 | "metadata": {},
224 | "outputs": [],
225 | "source": [
226 | "iteration.log(\"corr_matrix.png\", section = \"explore data\")"
227 | ]
228 | },
229 | {
230 | "cell_type": "code",
231 | "execution_count": null,
232 | "id": "9e200853-9172-4e9a-a2e0-476beaabcd91",
233 | "metadata": {},
234 | "outputs": [],
235 | "source": [
236 | "#Checking for outliers\n",
237 | "sns.displot(df[\"Quantity\"])\n",
238 | "plt.savefig(\"Quantity.png\")"
239 | ]
240 | },
241 | {
242 | "cell_type": "code",
243 | "execution_count": null,
244 | "id": "07eff006-fef5-476c-859a-c01947c84c4e",
245 | "metadata": {},
246 | "outputs": [],
247 | "source": [
248 | "iteration.log(\"Quantity.png\", section = \"explore data\")"
249 | ]
250 | },
251 | {
252 | "cell_type": "code",
253 | "execution_count": null,
254 | "id": "4ec7ecfc",
255 | "metadata": {},
256 | "outputs": [],
257 | "source": [
258 | "iteration.complete()"
259 | ]
260 | },
261 | {
262 | "attachments": {},
263 | "cell_type": "markdown",
264 | "id": "421b65ad",
265 | "metadata": {},
266 | "source": [
267 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Data Understanding phase of the Tutorial Project.
\n",
268 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.1/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
269 | ]
270 | }
271 | ],
272 | "metadata": {
273 | "kernelspec": {
274 | "display_name": "Python 3",
275 | "language": "python",
276 | "name": "python3"
277 | },
278 | "language_info": {
279 | "codemirror_mode": {
280 | "name": "ipython",
281 | "version": 3
282 | },
283 | "file_extension": ".py",
284 | "mimetype": "text/x-python",
285 | "name": "python",
286 | "nbconvert_exporter": "python",
287 | "pygments_lexer": "ipython3",
288 | "version": "3.9.6"
289 | }
290 | },
291 | "nbformat": 4,
292 | "nbformat_minor": 5
293 | }
294 |
--------------------------------------------------------------------------------
/24.1/tutorial/Model Deployment.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "ce429bd4-5bcc-47f6-9a7a-19b039cc87c1",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Deployment Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Deployment\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.1/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.1/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.1/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "3f34332a-2546-4d1f-86a5-cd263dd98f0d",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "3d9a66a7-e62d-459d-ab53-579644517548",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "ccd2d28a-abbc-4b5c-abf4-d9d6337bc28e",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "cd4f068f-60c6-436b-99b5-55575ecdbcb6",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\") #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "202bb8e0-4466-4383-b98e-ac735655a0af",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Deployment phase and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "3e19c58a-c203-4c84-8e1d-cd5ecbfa2d35",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") # Paste your Model Deployment phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "c9d27a6f-19e4-4f25-a50e-73e8fe0cc9d7",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "ef0de711-6ae8-484c-9831-f73d404f3e59",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "1ccf931b-9676-4f1b-868c-79c7f15eb0bf",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve A Previously Created Model\n",
114 | "We assume the model you stage in the previous Staging phase was approuved for deployment. For simplicity reasons, we will just fetch this model from Vectice retrieve its properties and add a fake endpoint "
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "81554fb3-316c-47ee-b04c-83c3f433285f",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "vect_model = connect.browse(\"MDV-xxxx\") #Pass your model ID Ridge Staging created on the Staging phase"
125 | ]
126 | },
127 | {
128 | "attachments": {},
129 | "cell_type": "markdown",
130 | "id": "38b747d7-e400-48a3-95ca-ceb61fb0d85c",
131 | "metadata": {},
132 | "source": [
133 | "## Log a Model\n",
134 | "Use the following code block to create a local Model"
135 | ]
136 | },
137 | {
138 | "cell_type": "code",
139 | "execution_count": null,
140 | "id": "0f73bd6f-b828-4603-ad8f-05cdb68f888b",
141 | "metadata": {},
142 | "outputs": [],
143 | "source": [
144 | "iteration.log(vect_model, section = \"deploy model\")"
145 | ]
146 | },
147 | {
148 | "attachments": {},
149 | "cell_type": "markdown",
150 | "id": "8ae90c1d-b385-422f-975e-9d7af6cadd0e",
151 | "metadata": {},
152 | "source": [
153 | "## Add a note\n",
154 | "Log the information for the deployment endpoint and model packaging as a note."
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": null,
160 | "id": "c7f7b1ec-19b2-4799-99f6-a4088e3fbc8c",
161 | "metadata": {},
162 | "outputs": [],
163 | "source": [
164 | "details = \"\"\"{\n",
165 | " \"Container image\": \"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest\",\n",
166 | " \"Model artifact location\": \"gs://dataproc-staging-us-west2-599225543291-rt9b6nzx/models/\",\n",
167 | " \"Prediction endpoint\": \"https://retail_prediction_service.com/predict\"\n",
168 | " }\"\"\"\n",
169 | "iteration.log(details, section = \"deploy model\")"
170 | ]
171 | },
172 | {
173 | "cell_type": "code",
174 | "execution_count": null,
175 | "id": "66ccf63e",
176 | "metadata": {},
177 | "outputs": [],
178 | "source": [
179 | "iteration.complete()"
180 | ]
181 | },
182 | {
183 | "attachments": {},
184 | "cell_type": "markdown",
185 | "id": "64ccc91e",
186 | "metadata": {},
187 | "source": [
188 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Deployment phase of the Tutorial Project.
\n",
189 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.1/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
190 | ]
191 | }
192 | ],
193 | "metadata": {
194 | "kernelspec": {
195 | "display_name": "Python 3",
196 | "language": "python",
197 | "name": "python3"
198 | },
199 | "language_info": {
200 | "codemirror_mode": {
201 | "name": "ipython",
202 | "version": 3
203 | },
204 | "file_extension": ".py",
205 | "mimetype": "text/x-python",
206 | "name": "python",
207 | "nbconvert_exporter": "python",
208 | "pygments_lexer": "ipython3",
209 | "version": "3.9.6"
210 | }
211 | },
212 | "nbformat": 4,
213 | "nbformat_minor": 5
214 | }
215 |
--------------------------------------------------------------------------------
/24.1/tutorial/Model Staging.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "43ca7ce4-3223-401e-a4af-cc7603f196a0",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Staging Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Staging\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.1/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.1/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.1/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "156659ab-68d8-42bf-a296-b81419b77f59",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "13672b5c-e784-4c7c-a47b-1215a47a593a",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "00d29059-b8b9-422e-bc6f-5c66fce6596c",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "1645ed95-ef27-444a-b991-b35b7c9cad88",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\") #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "be757d4c-5049-43f6-b932-84b49c7038a0",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Staging and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "cfc1ff71-4a3b-4a70-adcd-7bbf690c5134",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Model Staging Phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "361081b0-0995-4c05-924f-8feaab8fdde1",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "94afc70e-37c1-475d-bc62-1bb8bdb887cd",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "8667308a-bf28-4b8d-8553-9d05a8158e03",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve previously created Datasets\n",
114 | "You can retrieve a variety of Vectice Objects with the browse('VECTICE-ID') method. Namely, Phases, Iterations, Datasets, Models..."
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "d934877d-cbba-4bc2-93d5-d723fa37b654",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "origin_ds = connect.browse(\"DTV-xxxx\") #Paste your Origin Dataset ID (i.e ProductSales Origin) created on Data Understanding phase\n",
125 | "cleaned_ds = connect.browse(\"DTV-xxxx\") #Paste your Cleaned Dataset ID (i.e ProductSales Cleaned) created on Data Preparation phase\n",
126 | "modeling_dataset = connect.browse(\"DTV-xxxx\") #Paste your Model Dataset ID (i.e ProductSales Modeling) created on Data Modeling phase"
127 | ]
128 | },
129 | {
130 | "attachments": {},
131 | "cell_type": "markdown",
132 | "id": "5562fc69-f3fd-41f2-a09b-21c0322f4a6a",
133 | "metadata": {},
134 | "source": [
135 | "## Log a Staging Model\n",
136 | "\n",
137 | "Imaging you created this model through an automated training pipeline and you log it at the end of the process.
For the purpose of the tutorial we will simply create an empty model."
138 | ]
139 | },
140 | {
141 | "cell_type": "code",
142 | "execution_count": null,
143 | "id": "94d501da-41e2-46f6-890c-21a36e188b42",
144 | "metadata": {},
145 | "outputs": [],
146 | "source": [
147 | "vect_model = vectice.Model(name=\"scikit-learn Ridge Regression Stage model\",library=\"scikit-learn\", technique=\"Ridge Regression\", metrics={\"mae_test\": 63.02}, properties={\"quarter\": \"Q1\"}, derived_from=modeling_dataset)"
148 | ]
149 | },
150 | {
151 | "cell_type": "code",
152 | "execution_count": null,
153 | "id": "dc49e9c6-93f6-473a-84ff-13e5f72052bb",
154 | "metadata": {},
155 | "outputs": [],
156 | "source": [
157 | "iteration.log(origin_ds, section = \"ingest data\")"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "id": "703aa51a-8476-4356-9326-58e0582e7b3c",
164 | "metadata": {},
165 | "outputs": [],
166 | "source": [
167 | "iteration.log(cleaned_ds, section = \"preprocess data\")"
168 | ]
169 | },
170 | {
171 | "cell_type": "code",
172 | "execution_count": null,
173 | "id": "145e04ed-09e3-4d33-bff5-c8ab51425594",
174 | "metadata": {},
175 | "outputs": [],
176 | "source": [
177 | "iteration.log(vect_model, section = \"train model\")"
178 | ]
179 | },
180 | {
181 | "attachments": {},
182 | "cell_type": "markdown",
183 | "id": "42e6cd6b-f39e-4b2d-a69f-22e9a5ab7bbd",
184 | "metadata": {},
185 | "source": [
186 | "## Add a note\n",
187 | "Use the following code block to save key performance metrics as a note that will be use for approving deployment to production"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": null,
193 | "id": "e33d20d7-e6ca-49bf-b4e5-fbe72795edfd",
194 | "metadata": {},
195 | "outputs": [],
196 | "source": [
197 | "iteration.log(\"\"\"Evaluation:\\nMAE vs Threshold: 63.02 vs 98 from Baseline \\nModel passed acceptance critera.\"\"\", section = \"evaluate model\")"
198 | ]
199 | },
200 | {
201 | "cell_type": "code",
202 | "execution_count": null,
203 | "id": "e2b804da",
204 | "metadata": {},
205 | "outputs": [],
206 | "source": [
207 | "iteration.complete()\n"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "e091dc76",
214 | "metadata": {},
215 | "source": [
216 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Staging phase of the Tutorial Project.
\n",
217 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.1/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
218 | ]
219 | }
220 | ],
221 | "metadata": {
222 | "kernelspec": {
223 | "display_name": "Python 3",
224 | "language": "python",
225 | "name": "python3"
226 | },
227 | "language_info": {
228 | "codemirror_mode": {
229 | "name": "ipython",
230 | "version": 3
231 | },
232 | "file_extension": ".py",
233 | "mimetype": "text/x-python",
234 | "name": "python",
235 | "nbconvert_exporter": "python",
236 | "pygments_lexer": "ipython3",
237 | "version": "3.9.6"
238 | }
239 | },
240 | "nbformat": 4,
241 | "nbformat_minor": 5
242 | }
243 |
--------------------------------------------------------------------------------
/24.1/tutorial/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/24.2.11/QuickStart Autolog.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "
\n",
9 | ""
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {
15 | "id": "twIzT22mtqhs"
16 | },
17 | "source": [
18 | "# Before you start with this Quickstart Notebook"
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "metadata": {
24 | "id": "iUp4X8V5tqhv"
25 | },
26 | "source": [
27 | "You will need:\n",
28 | "* An account in Vectice\n",
29 | "* An API key to connect to Vectice\n",
30 | "* The Phase Id of the project where you want to log your work\n",
31 | "\n",
32 | "### Important Resources\n",
33 | "* Vectice autolog documentation https://api-docs.vectice.com/24.2.11/reference/vectice/autolog/\n",
34 | "\n"
35 | ]
36 | },
37 | {
38 | "cell_type": "markdown",
39 | "metadata": {
40 | "id": "jER4KBN0JbSw"
41 | },
42 | "source": [
43 | "\n",
44 | "Automated code lineage: The code lineage functionalities are not covered as part of this QuickStart as they require first setting up a Git repository.\n",
45 | "
\n",
46 | "\n",
47 | "\n",
48 | "\n",
49 | "---\n",
50 | "\n"
51 | ]
52 | },
53 | {
54 | "cell_type": "markdown",
55 | "metadata": {
56 | "id": "7LArs6J5fyIz"
57 | },
58 | "source": [
59 | "## What to expect\n",
60 | "\n",
61 | "In this notebook, we will re-use the classical Iris modeling example to demonstrate how you can automatically document in Vectice your assets, such as datasets, models, graphs, and notes, using a few lines of code."
62 | ]
63 | },
64 | {
65 | "cell_type": "markdown",
66 | "metadata": {
67 | "id": "BWxVwtAdgSbj"
68 | },
69 | "source": [
70 | "## Install the latest Vectice Python client library"
71 | ]
72 | },
73 | {
74 | "cell_type": "code",
75 | "execution_count": null,
76 | "metadata": {
77 | "id": "bin0M8rKdfBU"
78 | },
79 | "outputs": [],
80 | "source": [
81 | "%pip install -q seaborn\n",
82 | "%pip install -q scikit-learn\n",
83 | "%pip install -q vectice -U"
84 | ]
85 | },
86 | {
87 | "cell_type": "markdown",
88 | "metadata": {
89 | "id": "1bwpySvqf5Ce"
90 | },
91 | "source": [
92 | "## Get started configuring the Vectice autolog"
93 | ]
94 | },
95 | {
96 | "cell_type": "markdown",
97 | "metadata": {
98 | "id": "jx5xlQFJxxQZ"
99 | },
100 | "source": [
101 | "**First, you need to configure the autolog. You will need your API key and Phase ID inside your Quickstart project to specify where to document your work. Before proceeding:**\n",
102 | "\n",
103 | "- Click on the key icon in the upper right corner of the Vectice app to create an API key, then copy and paste it into the code below.\n",
104 | "\n",
105 | "- In your Quickstart project, go to [Phase 2] Autolog phase and copy its Phase ID to paste in the code below."
106 | ]
107 | },
108 | {
109 | "cell_type": "code",
110 | "execution_count": null,
111 | "metadata": {
112 | "id": "frnhI_W9aOoZ"
113 | },
114 | "outputs": [],
115 | "source": [
116 | "import vectice\n",
117 | "from vectice import autolog\n",
118 | "\n",
119 | "autolog.config(api_token=\"your-api-key\", #Paste your API key\n",
120 | " host = 'your-host-info', #Paste your host information\n",
121 | " phase = 'your-phase-id') #Paste your Phase Id"
122 | ]
123 | },
124 | {
125 | "cell_type": "markdown",
126 | "metadata": {},
127 | "source": [
128 | "\n",
129 | " Important information:\n",
130 | "
Vectice Autolog is continuously evolving and we are actively enhancing supported libraries, environments, and functionalities to provide an improved user experience. \n",
131 | " Be sure to configure autolog at the beginning of your notebook. A late setup may require rerunning previous cells.\n",
132 | " Your feedback is highly valued. Please send any feedback to support@vectice.com.\n",
133 | "
\n",
134 | "\n",
135 | "For detailed information, supported libraries and environments, please consult our [Autolog documentation](https://api-docs.vectice.com/24.2.11/reference/vectice/autolog/).\n",
136 | ""
137 | ]
138 | },
139 | {
140 | "cell_type": "markdown",
141 | "metadata": {
142 | "id": "FYeCGcgLlsOL"
143 | },
144 | "source": [
145 | "# Auto-Document your work in Vectice\n",
146 | "We will prepare an example dataset based on the well-known iris dataset. We will then train a linear regression model using scikit-learn.\n",
147 | "After we complete this work and create those assets, we will log them to Vectice in a single line of code.\n",
148 | "This enables you to document your work as you go, and to never forget the data that was used, the models, the code and other artifacts."
149 | ]
150 | },
151 | {
152 | "cell_type": "markdown",
153 | "metadata": {
154 | "id": "6VvbrEsKl5bH"
155 | },
156 | "source": [
157 | "Use the following code block to create a dataset, generate a graph and build a model:"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "metadata": {
164 | "id": "jMC05CI6epHw"
165 | },
166 | "outputs": [],
167 | "source": [
168 | "import pandas as pd\n",
169 | "from sklearn import datasets\n",
170 | "\n",
171 | "iris = datasets.load_iris()\n",
172 | "\n",
173 | "df_iris = pd.DataFrame(data=iris.data, columns=iris.feature_names)\n",
174 | "df_iris['species'] = iris.target_names[iris.target]\n"
175 | ]
176 | },
177 | {
178 | "cell_type": "code",
179 | "execution_count": null,
180 | "metadata": {
181 | "id": "OMaIknlOtqh3"
182 | },
183 | "outputs": [],
184 | "source": [
185 | "import seaborn as sns\n",
186 | "import matplotlib.pyplot as plt\n",
187 | "\n",
188 | "sns.scatterplot(data=df_iris, x='sepal length (cm)',\n",
189 | " y='petal width (cm)', hue='species')\n",
190 | "plt.plot()\n",
191 | "\n",
192 | "#Save your graph to local file to be automatically captured by Vectice \n",
193 | "plt.savefig('Scatter_plot_iris.png') "
194 | ]
195 | },
196 | {
197 | "cell_type": "markdown",
198 | "metadata": {},
199 | "source": [
200 | "**Note**: Save graphs you want to log into a local file to be automatically captured by the autolog.
"
201 | ]
202 | },
203 | {
204 | "cell_type": "code",
205 | "execution_count": null,
206 | "metadata": {
207 | "id": "N0wsppAltqh5"
208 | },
209 | "outputs": [],
210 | "source": [
211 | "from sklearn.neighbors import KNeighborsClassifier\n",
212 | "from sklearn.model_selection import train_test_split\n",
213 | "from sklearn.metrics import accuracy_score\n",
214 | "\n",
215 | "train_df, test_df = train_test_split(df_iris, test_size=0.2, random_state=42)\n",
216 | "\n",
217 | "knn = KNeighborsClassifier()\n",
218 | "knn.fit(train_df[iris.feature_names],train_df[\"species\"])\n",
219 | "\n",
220 | "# Make predictions on the test set\n",
221 | "y_pred_test = knn.predict(test_df[iris.feature_names])\n",
222 | "y_pred_train = knn.predict(train_df[iris.feature_names])\n",
223 | "\n",
224 | "# Calculate the accuracy score\n",
225 | "accuracy_test= accuracy_score(test_df[\"species\"], y_pred_test)\n",
226 | "accuracy_train = accuracy_score(train_df[\"species\"], y_pred_train)"
227 | ]
228 | },
229 | {
230 | "cell_type": "markdown",
231 | "metadata": {},
232 | "source": [
233 | "**Note**: To link models and metrics using Vectice autolog, ensure each model and its metrics are in the same notebook cell (scikit metrics are currently supported)."
234 | ]
235 | },
236 | {
237 | "cell_type": "markdown",
238 | "metadata": {},
239 | "source": [
240 | "## Autolog your entire notebook's assets (model, datasets, graphs and note) with a single line of code"
241 | ]
242 | },
243 | {
244 | "cell_type": "code",
245 | "execution_count": null,
246 | "metadata": {
247 | "id": "g5FOnLfHnY14"
248 | },
249 | "outputs": [],
250 | "source": [
251 | "autolog.notebook(note=\"My first iteration to Vectice to document iris dataset\", capture_schema_only=False) #You can add a note to comment what you just logged into Vectice"
252 | ]
253 | },
254 | {
255 | "cell_type": "markdown",
256 | "metadata": {},
257 | "source": [
258 | "#### You have logged your assets to Vectice with a single line of code. You can click on the iteration link above to see your assets inside Vectice.\n",
259 | "**Note**: Autolog also allows you to log only the content of one cell, please check out our [documentation](https://api-docs.vectice.com/24.2.11/reference/vectice/autolog/) to learn more about the autolog functions and capabilities.
"
260 | ]
261 | },
262 | {
263 | "cell_type": "markdown",
264 | "metadata": {
265 | "id": "YnmFUplTpMoW"
266 | },
267 | "source": [
268 | "## 🥇 Congrats! You have learned how to successfully use Vectice to auto-document your assets in one line of code.
Easy right?
\n",
269 | "#### You can proceed back to the Vectice app continue documenting your work.\n"
270 | ]
271 | }
272 | ],
273 | "metadata": {
274 | "colab": {
275 | "provenance": []
276 | },
277 | "kernelspec": {
278 | "display_name": "Python 3",
279 | "name": "python3"
280 | },
281 | "language_info": {
282 | "codemirror_mode": {
283 | "name": "ipython",
284 | "version": 3
285 | },
286 | "file_extension": ".py",
287 | "mimetype": "text/x-python",
288 | "name": "python",
289 | "nbconvert_exporter": "python",
290 | "pygments_lexer": "ipython3",
291 | "version": "3.9.6"
292 | }
293 | },
294 | "nbformat": 4,
295 | "nbformat_minor": 0
296 | }
297 |
--------------------------------------------------------------------------------
/24.2.11/tutorial/Data Understanding.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "eabedfd0-bda4-4a9f-9ef2-6514a91dbb98",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Data Understanding Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Data Understanding\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.2.11/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.2.11/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.2.11/"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": null,
30 | "id": "6e6350fb-5aec-448e-9e86-4715055033ee",
31 | "metadata": {},
32 | "outputs": [],
33 | "source": [
34 | "import warnings\n",
35 | "warnings.filterwarnings(\"ignore\", category=DeprecationWarning)"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": null,
41 | "id": "dc1525e3-eb5c-4e5b-855f-47dc2229afbf",
42 | "metadata": {},
43 | "outputs": [],
44 | "source": [
45 | "import pandas as pd\n",
46 | "import numpy as np\n",
47 | "import seaborn as sns\n",
48 | "import matplotlib.pyplot as plt"
49 | ]
50 | },
51 | {
52 | "attachments": {},
53 | "cell_type": "markdown",
54 | "id": "6da9fd84-09a0-4d30-bc00-c91dea5cd98f",
55 | "metadata": {},
56 | "source": [
57 | "## Install the latest Vectice Python client library"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": null,
63 | "id": "43c38240-69a2-41fb-bda7-46b7c40b963f",
64 | "metadata": {},
65 | "outputs": [],
66 | "source": [
67 | "%pip install --q vectice -U"
68 | ]
69 | },
70 | {
71 | "attachments": {},
72 | "cell_type": "markdown",
73 | "id": "10195b2a-a959-4a7b-a20b-e45c292930ef",
74 | "metadata": {},
75 | "source": [
76 | "## Get started by connecting to Vectice"
77 | ]
78 | },
79 | {
80 | "cell_type": "code",
81 | "execution_count": null,
82 | "id": "d34bced5-491f-400b-ac5d-e4665f6f6ae8",
83 | "metadata": {},
84 | "outputs": [],
85 | "source": [
86 | "import vectice\n",
87 | "\n",
88 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
89 | ]
90 | },
91 | {
92 | "attachments": {},
93 | "cell_type": "markdown",
94 | "id": "90a36ebc-023d-4f18-8382-8d92044492e3",
95 | "metadata": {},
96 | "source": [
97 | "## Specify which project phase you want to document\n",
98 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Data Understanding phase and copy paste your Phase Id below."
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": null,
104 | "id": "9d57e0e9-fc47-4b91-81b0-2f79907c901a",
105 | "metadata": {},
106 | "outputs": [],
107 | "source": [
108 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Data Understanding Phase ID"
109 | ]
110 | },
111 | {
112 | "attachments": {},
113 | "cell_type": "markdown",
114 | "id": "9a7957b4-c5dc-49ff-9612-f58ee9e63146",
115 | "metadata": {},
116 | "source": [
117 | "## Next we are going to create an iteration\n",
118 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
119 | ]
120 | },
121 | {
122 | "cell_type": "code",
123 | "execution_count": null,
124 | "id": "b315169a-d68f-4a17-9b39-56694b8be697",
125 | "metadata": {},
126 | "outputs": [],
127 | "source": [
128 | "iteration = phase.create_or_get_current_iteration()"
129 | ]
130 | },
131 | {
132 | "cell_type": "code",
133 | "execution_count": null,
134 | "id": "6c59effc-5b3f-4b75-aae4-f3d46be1218f",
135 | "metadata": {},
136 | "outputs": [],
137 | "source": [
138 | "df = pd.read_csv(\"https://raw.githubusercontent.com/vectice/GettingStarted/main/Tutorial%20data/SampleSuperstore.csv\", converters = {'Postal Code': str})\n",
139 | "df.to_csv(\"SampleSuperstore.csv\", index=False)"
140 | ]
141 | },
142 | {
143 | "attachments": {},
144 | "cell_type": "markdown",
145 | "id": "ef495b02-b785-41d5-8741-0796c3cf8da2",
146 | "metadata": {},
147 | "source": [
148 | "## Log a dataset\n",
149 | "Use the following code block to create a local dataset and generate a graph:"
150 | ]
151 | },
152 | {
153 | "cell_type": "code",
154 | "execution_count": null,
155 | "id": "4722446c-389d-4543-9280-9558e0a07bb7",
156 | "metadata": {},
157 | "outputs": [],
158 | "source": [
159 | "origin_ds = vectice.FileResource(paths=\"SampleSuperstore.csv\", dataframes=df)\n",
160 | "\n",
161 | "\n",
162 | "origin_dataset = vectice.Dataset.origin(\n",
163 | " name=\"ProductSales Origin\",\n",
164 | " resource=origin_ds, \n",
165 | ")"
166 | ]
167 | },
168 | {
169 | "cell_type": "code",
170 | "execution_count": null,
171 | "id": "53bdadfd-c9d3-4c6e-acb4-930751df7a54",
172 | "metadata": {},
173 | "outputs": [],
174 | "source": [
175 | "iteration.log(origin_dataset, section = \"collect initial data\")"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": null,
181 | "id": "140a4667-ba4c-492b-820b-cfa676dfe184",
182 | "metadata": {},
183 | "outputs": [],
184 | "source": [
185 | "iteration.log(str(df.columns.values), section = \"describe data\")"
186 | ]
187 | },
188 | {
189 | "cell_type": "code",
190 | "execution_count": null,
191 | "id": "473c3d35-7050-4a06-b867-b2861755ee3d",
192 | "metadata": {},
193 | "outputs": [],
194 | "source": [
195 | "## Checking for Multicollinearity\n",
196 | "corr_matrix=df.select_dtypes(\"number\").drop(\"Sales\",axis=1).corr()\n",
197 | "sns.heatmap(corr_matrix);\n",
198 | "plt.savefig(\"corr_matrix.png\")"
199 | ]
200 | },
201 | {
202 | "attachments": {},
203 | "cell_type": "markdown",
204 | "id": "437759e3",
205 | "metadata": {},
206 | "source": [
207 | "## Log graphs"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "45b5eb6d",
214 | "metadata": {},
215 | "source": [
216 | "You can log multiple items to a single iteration by using the `iterarion.log()` method."
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": null,
222 | "id": "e95ed5c6-fb4b-47be-bd7c-00747f8a4f3e",
223 | "metadata": {},
224 | "outputs": [],
225 | "source": [
226 | "iteration.log(\"corr_matrix.png\", section = \"explore data\")"
227 | ]
228 | },
229 | {
230 | "cell_type": "code",
231 | "execution_count": null,
232 | "id": "9e200853-9172-4e9a-a2e0-476beaabcd91",
233 | "metadata": {},
234 | "outputs": [],
235 | "source": [
236 | "#Checking for outliers\n",
237 | "sns.displot(df[\"Quantity\"])\n",
238 | "plt.savefig(\"Quantity.png\")"
239 | ]
240 | },
241 | {
242 | "cell_type": "code",
243 | "execution_count": null,
244 | "id": "07eff006-fef5-476c-859a-c01947c84c4e",
245 | "metadata": {},
246 | "outputs": [],
247 | "source": [
248 | "iteration.log(\"Quantity.png\", section = \"explore data\")"
249 | ]
250 | },
251 | {
252 | "cell_type": "code",
253 | "execution_count": null,
254 | "id": "4ec7ecfc",
255 | "metadata": {},
256 | "outputs": [],
257 | "source": [
258 | "iteration.complete()"
259 | ]
260 | },
261 | {
262 | "attachments": {},
263 | "cell_type": "markdown",
264 | "id": "421b65ad",
265 | "metadata": {},
266 | "source": [
267 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Data Understanding phase of the Tutorial Project.
\n",
268 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.2.11/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
269 | ]
270 | }
271 | ],
272 | "metadata": {
273 | "kernelspec": {
274 | "display_name": "Python 3",
275 | "language": "python",
276 | "name": "python3"
277 | },
278 | "language_info": {
279 | "codemirror_mode": {
280 | "name": "ipython",
281 | "version": 3
282 | },
283 | "file_extension": ".py",
284 | "mimetype": "text/x-python",
285 | "name": "python",
286 | "nbconvert_exporter": "python",
287 | "pygments_lexer": "ipython3",
288 | "version": "3.9.6"
289 | }
290 | },
291 | "nbformat": 4,
292 | "nbformat_minor": 5
293 | }
294 |
--------------------------------------------------------------------------------
/24.2.11/tutorial/Model Deployment.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "ce429bd4-5bcc-47f6-9a7a-19b039cc87c1",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Deployment Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Deployment\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.2.11/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.2.11/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.2.11/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "3f34332a-2546-4d1f-86a5-cd263dd98f0d",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "3d9a66a7-e62d-459d-ab53-579644517548",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "ccd2d28a-abbc-4b5c-abf4-d9d6337bc28e",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "cd4f068f-60c6-436b-99b5-55575ecdbcb6",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "202bb8e0-4466-4383-b98e-ac735655a0af",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Deployment phase and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "3e19c58a-c203-4c84-8e1d-cd5ecbfa2d35",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") # Paste your Model Deployment phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "c9d27a6f-19e4-4f25-a50e-73e8fe0cc9d7",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "ef0de711-6ae8-484c-9831-f73d404f3e59",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "1ccf931b-9676-4f1b-868c-79c7f15eb0bf",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve A Previously Created Model\n",
114 | "We assume the model you stage in the previous Staging phase was approuved for deployment. For simplicity reasons, we will just fetch this model from Vectice retrieve its properties and add a fake endpoint "
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "81554fb3-316c-47ee-b04c-83c3f433285f",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "vect_model = connect.browse(\"MDV-xxxx\") #Pass your model ID Ridge Staging created on the Staging phase"
125 | ]
126 | },
127 | {
128 | "attachments": {},
129 | "cell_type": "markdown",
130 | "id": "38b747d7-e400-48a3-95ca-ceb61fb0d85c",
131 | "metadata": {},
132 | "source": [
133 | "## Log a Model\n",
134 | "Use the following code block to create a local Model"
135 | ]
136 | },
137 | {
138 | "cell_type": "code",
139 | "execution_count": null,
140 | "id": "0f73bd6f-b828-4603-ad8f-05cdb68f888b",
141 | "metadata": {},
142 | "outputs": [],
143 | "source": [
144 | "iteration.log(vect_model, section = \"deploy model\")"
145 | ]
146 | },
147 | {
148 | "attachments": {},
149 | "cell_type": "markdown",
150 | "id": "8ae90c1d-b385-422f-975e-9d7af6cadd0e",
151 | "metadata": {},
152 | "source": [
153 | "## Add a note\n",
154 | "Log the information for the deployment endpoint and model packaging as a note."
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": null,
160 | "id": "c7f7b1ec-19b2-4799-99f6-a4088e3fbc8c",
161 | "metadata": {},
162 | "outputs": [],
163 | "source": [
164 | "details = \"\"\"{\n",
165 | " \"Container image\": \"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest\",\n",
166 | " \"Model artifact location\": \"gs://dataproc-staging-us-west2-599225543291-rt9b6nzx/models/\",\n",
167 | " \"Prediction endpoint\": \"https://retail_prediction_service.com/predict\"\n",
168 | " }\"\"\"\n",
169 | "iteration.log(details, section = \"deploy model\")"
170 | ]
171 | },
172 | {
173 | "cell_type": "code",
174 | "execution_count": null,
175 | "id": "66ccf63e",
176 | "metadata": {},
177 | "outputs": [],
178 | "source": [
179 | "iteration.complete()"
180 | ]
181 | },
182 | {
183 | "attachments": {},
184 | "cell_type": "markdown",
185 | "id": "64ccc91e",
186 | "metadata": {},
187 | "source": [
188 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Deployment phase of the Tutorial Project.
\n",
189 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.2.11/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
190 | ]
191 | }
192 | ],
193 | "metadata": {
194 | "kernelspec": {
195 | "display_name": "Python 3",
196 | "language": "python",
197 | "name": "python3"
198 | },
199 | "language_info": {
200 | "codemirror_mode": {
201 | "name": "ipython",
202 | "version": 3
203 | },
204 | "file_extension": ".py",
205 | "mimetype": "text/x-python",
206 | "name": "python",
207 | "nbconvert_exporter": "python",
208 | "pygments_lexer": "ipython3",
209 | "version": "3.9.6"
210 | }
211 | },
212 | "nbformat": 4,
213 | "nbformat_minor": 5
214 | }
215 |
--------------------------------------------------------------------------------
/24.2.11/tutorial/Model Staging.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "43ca7ce4-3223-401e-a4af-cc7603f196a0",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Staging Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Staging\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.2.11/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.2.11/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.2.11/\n"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "156659ab-68d8-42bf-a296-b81419b77f59",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "13672b5c-e784-4c7c-a47b-1215a47a593a",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "00d29059-b8b9-422e-bc6f-5c66fce6596c",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "1645ed95-ef27-444a-b991-b35b7c9cad88",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "be757d4c-5049-43f6-b932-84b49c7038a0",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Staging and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "cfc1ff71-4a3b-4a70-adcd-7bbf690c5134",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Model Staging Phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "361081b0-0995-4c05-924f-8feaab8fdde1",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "94afc70e-37c1-475d-bc62-1bb8bdb887cd",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "8667308a-bf28-4b8d-8553-9d05a8158e03",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve previously created Datasets\n",
114 | "You can retrieve a variety of Vectice Objects with the browse('VECTICE-ID') method. Namely, Phases, Iterations, Datasets, Models..."
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "d934877d-cbba-4bc2-93d5-d723fa37b654",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "origin_ds = connect.browse(\"DTV-xxxx\") #Paste your Origin Dataset ID (i.e ProductSales Origin) created on Data Understanding phase\n",
125 | "cleaned_ds = connect.browse(\"DTV-xxxx\") #Paste your Cleaned Dataset ID (i.e ProductSales Cleaned) created on Data Preparation phase\n",
126 | "modeling_dataset = connect.browse(\"DTV-xxxx\") #Paste your Model Dataset ID (i.e ProductSales Modeling) created on Data Modeling phase"
127 | ]
128 | },
129 | {
130 | "attachments": {},
131 | "cell_type": "markdown",
132 | "id": "5562fc69-f3fd-41f2-a09b-21c0322f4a6a",
133 | "metadata": {},
134 | "source": [
135 | "## Log a Staging Model\n",
136 | "\n",
137 | "Imaging you created this model through an automated training pipeline and you log it at the end of the process.
For the purpose of the tutorial we will simply create an empty model."
138 | ]
139 | },
140 | {
141 | "cell_type": "code",
142 | "execution_count": null,
143 | "id": "94d501da-41e2-46f6-890c-21a36e188b42",
144 | "metadata": {},
145 | "outputs": [],
146 | "source": [
147 | "vect_model = vectice.Model(name=\"scikit-learn Ridge Regression Stage model\",library=\"scikit-learn\", technique=\"Ridge Regression\", metrics={\"mae_test\": 63.02}, properties={\"quarter\": \"Q1\"}, derived_from=modeling_dataset)"
148 | ]
149 | },
150 | {
151 | "cell_type": "code",
152 | "execution_count": null,
153 | "id": "dc49e9c6-93f6-473a-84ff-13e5f72052bb",
154 | "metadata": {},
155 | "outputs": [],
156 | "source": [
157 | "iteration.log(origin_ds, section = \"ingest data\")"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "id": "703aa51a-8476-4356-9326-58e0582e7b3c",
164 | "metadata": {},
165 | "outputs": [],
166 | "source": [
167 | "iteration.log(cleaned_ds, section = \"preprocess data\")"
168 | ]
169 | },
170 | {
171 | "cell_type": "code",
172 | "execution_count": null,
173 | "id": "145e04ed-09e3-4d33-bff5-c8ab51425594",
174 | "metadata": {},
175 | "outputs": [],
176 | "source": [
177 | "iteration.log(vect_model, section = \"train model\")"
178 | ]
179 | },
180 | {
181 | "attachments": {},
182 | "cell_type": "markdown",
183 | "id": "42e6cd6b-f39e-4b2d-a69f-22e9a5ab7bbd",
184 | "metadata": {},
185 | "source": [
186 | "## Add a note\n",
187 | "Use the following code block to save key performance metrics as a note that will be use for approving deployment to production"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": null,
193 | "id": "e33d20d7-e6ca-49bf-b4e5-fbe72795edfd",
194 | "metadata": {},
195 | "outputs": [],
196 | "source": [
197 | "iteration.log(\"\"\"Evaluation:\\nMAE vs Threshold: 63.02 vs 98 from Baseline \\nModel passed acceptance critera.\"\"\", section = \"evaluate model\")"
198 | ]
199 | },
200 | {
201 | "cell_type": "code",
202 | "execution_count": null,
203 | "id": "e2b804da",
204 | "metadata": {},
205 | "outputs": [],
206 | "source": [
207 | "iteration.complete()\n"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "e091dc76",
214 | "metadata": {},
215 | "source": [
216 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Staging phase of the Tutorial Project.
\n",
217 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.2.11/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
218 | ]
219 | }
220 | ],
221 | "metadata": {
222 | "kernelspec": {
223 | "display_name": "Python 3",
224 | "language": "python",
225 | "name": "python3"
226 | },
227 | "language_info": {
228 | "codemirror_mode": {
229 | "name": "ipython",
230 | "version": 3
231 | },
232 | "file_extension": ".py",
233 | "mimetype": "text/x-python",
234 | "name": "python",
235 | "nbconvert_exporter": "python",
236 | "pygments_lexer": "ipython3",
237 | "version": "3.9.6"
238 | }
239 | },
240 | "nbformat": 4,
241 | "nbformat_minor": 5
242 | }
243 |
--------------------------------------------------------------------------------
/24.2.11/tutorial/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/24.2/QuickStart Autolog.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "
\n",
9 | ""
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {
15 | "id": "twIzT22mtqhs"
16 | },
17 | "source": [
18 | "# Before you start with this Quickstart Notebook"
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "metadata": {
24 | "id": "iUp4X8V5tqhv"
25 | },
26 | "source": [
27 | "You will need:\n",
28 | "* An account in Vectice\n",
29 | "* An API key to connect to Vectice\n",
30 | "* The Phase Id of the project where you want to log your work\n",
31 | "\n",
32 | "### Important Resources\n",
33 | "* Vectice autolog documentation https://api-docs.vectice.com/24.2/reference/vectice/autolog/\n"
34 | ]
35 | },
36 | {
37 | "cell_type": "markdown",
38 | "metadata": {
39 | "id": "jER4KBN0JbSw"
40 | },
41 | "source": [
42 | "\n",
43 | "Automated code lineage: The code lineage functionalities are not covered as part of this QuickStart as they require first setting up a Git repository.\n",
44 | "
\n",
45 | "\n",
46 | "\n",
47 | "\n",
48 | "---\n",
49 | "\n"
50 | ]
51 | },
52 | {
53 | "cell_type": "markdown",
54 | "metadata": {
55 | "id": "7LArs6J5fyIz"
56 | },
57 | "source": [
58 | "## What to expect\n",
59 | "\n",
60 | "In this notebook, we will re-use the classical Iris modeling example to demonstrate how you can automatically document in Vectice your assets, such as datasets, models, graphs, and notes, using a few lines of code."
61 | ]
62 | },
63 | {
64 | "cell_type": "markdown",
65 | "metadata": {
66 | "id": "BWxVwtAdgSbj"
67 | },
68 | "source": [
69 | "## Install the latest Vectice Python client library"
70 | ]
71 | },
72 | {
73 | "cell_type": "code",
74 | "execution_count": null,
75 | "metadata": {
76 | "id": "bin0M8rKdfBU"
77 | },
78 | "outputs": [],
79 | "source": [
80 | "%pip install -q seaborn\n",
81 | "%pip install -q scikit-learn\n",
82 | "%pip install -q vectice -U"
83 | ]
84 | },
85 | {
86 | "cell_type": "markdown",
87 | "metadata": {
88 | "id": "1bwpySvqf5Ce"
89 | },
90 | "source": [
91 | "## Get started configuring the Vectice autolog"
92 | ]
93 | },
94 | {
95 | "cell_type": "markdown",
96 | "metadata": {
97 | "id": "jx5xlQFJxxQZ"
98 | },
99 | "source": [
100 | "**First, you need to configure the autolog. You will need your API key and Phase ID inside your Quickstart project to specify where to document your work. Before proceeding:**\n",
101 | "\n",
102 | "- Click on the key icon in the upper right corner of the Vectice app to create an API key, then copy and paste it into the code below.\n",
103 | "\n",
104 | "- In your Quickstart project, go to [Phase 2] Autolog phase and copy its Phase ID to paste in the code below."
105 | ]
106 | },
107 | {
108 | "cell_type": "code",
109 | "execution_count": null,
110 | "metadata": {
111 | "id": "frnhI_W9aOoZ"
112 | },
113 | "outputs": [],
114 | "source": [
115 | "import vectice\n",
116 | "from vectice import autolog\n",
117 | "\n",
118 | "autolog.config(api_token=\"your-api-key\", #Paste your API key\n",
119 | " host = 'your-host-info', #Paste your host information\n",
120 | " phase = 'your-phase-id') #Paste your Phase Id"
121 | ]
122 | },
123 | {
124 | "cell_type": "markdown",
125 | "metadata": {},
126 | "source": [
127 | "\n",
128 | " Important information:\n",
129 | "
Vectice Autolog is continuously evolving and we are actively enhancing supported libraries, environments, and functionalities to provide an improved user experience. \n",
130 | " Be sure to configure autolog at the beginning of your notebook. A late setup may require rerunning previous cells.\n",
131 | " Your feedback is highly valued. Please send any feedback to support@vectice.com.\n",
132 | "
\n",
133 | "\n",
134 | "For detailed information, supported libraries and environments, please consult our [Autolog documentation](https://api-docs.vectice.com/24.2/reference/vectice/autolog/).\n",
135 | ""
136 | ]
137 | },
138 | {
139 | "cell_type": "markdown",
140 | "metadata": {
141 | "id": "FYeCGcgLlsOL"
142 | },
143 | "source": [
144 | "# Auto-Document your work in Vectice\n",
145 | "We will prepare an example dataset based on the well-known iris dataset. We will then train a linear regression model using scikit-learn.\n",
146 | "After we complete this work and create those assets, we will log them to Vectice in a single line of code.\n",
147 | "This enables you to document your work as you go, and to never forget the data that was used, the models, the code and other artifacts."
148 | ]
149 | },
150 | {
151 | "cell_type": "markdown",
152 | "metadata": {
153 | "id": "6VvbrEsKl5bH"
154 | },
155 | "source": [
156 | "Use the following code block to create a dataset, generate a graph and build a model:"
157 | ]
158 | },
159 | {
160 | "cell_type": "code",
161 | "execution_count": null,
162 | "metadata": {
163 | "id": "jMC05CI6epHw"
164 | },
165 | "outputs": [],
166 | "source": [
167 | "import pandas as pd\n",
168 | "from sklearn import datasets\n",
169 | "\n",
170 | "iris = datasets.load_iris()\n",
171 | "\n",
172 | "df_iris = pd.DataFrame(data=iris.data, columns=iris.feature_names)\n",
173 | "df_iris['species'] = iris.target_names[iris.target]\n"
174 | ]
175 | },
176 | {
177 | "cell_type": "code",
178 | "execution_count": null,
179 | "metadata": {
180 | "id": "OMaIknlOtqh3"
181 | },
182 | "outputs": [],
183 | "source": [
184 | "import seaborn as sns\n",
185 | "import matplotlib.pyplot as plt\n",
186 | "\n",
187 | "sns.scatterplot(data=df_iris, x='sepal length (cm)',\n",
188 | " y='petal width (cm)', hue='species')\n",
189 | "plt.plot()\n",
190 | "\n",
191 | "#Save your graph to local file to be automatically captured by Vectice \n",
192 | "plt.savefig('Scatter_plot_iris.png') "
193 | ]
194 | },
195 | {
196 | "cell_type": "markdown",
197 | "metadata": {},
198 | "source": [
199 | "**Note**: Save graphs you want to log into a local file to be automatically captured by the autolog.
"
200 | ]
201 | },
202 | {
203 | "cell_type": "code",
204 | "execution_count": null,
205 | "metadata": {
206 | "id": "N0wsppAltqh5"
207 | },
208 | "outputs": [],
209 | "source": [
210 | "from sklearn.neighbors import KNeighborsClassifier\n",
211 | "from sklearn.model_selection import train_test_split\n",
212 | "from sklearn.metrics import accuracy_score\n",
213 | "\n",
214 | "train_df, test_df = train_test_split(df_iris, test_size=0.2, random_state=42)\n",
215 | "\n",
216 | "knn = KNeighborsClassifier()\n",
217 | "knn.fit(train_df[iris.feature_names],train_df[\"species\"])\n",
218 | "\n",
219 | "# Make predictions on the test set\n",
220 | "y_pred_test = knn.predict(test_df[iris.feature_names])\n",
221 | "y_pred_train = knn.predict(train_df[iris.feature_names])\n",
222 | "\n",
223 | "# Calculate the accuracy score\n",
224 | "accuracy_test= accuracy_score(test_df[\"species\"], y_pred_test)\n",
225 | "accuracy_train = accuracy_score(train_df[\"species\"], y_pred_train)"
226 | ]
227 | },
228 | {
229 | "cell_type": "markdown",
230 | "metadata": {},
231 | "source": [
232 | "**Note**: To link models and metrics using Vectice autolog, ensure each model and its metrics are in the same notebook cell (scikit metrics are currently supported)."
233 | ]
234 | },
235 | {
236 | "cell_type": "markdown",
237 | "metadata": {},
238 | "source": [
239 | "## Autolog your entire notebook's assets (model, datasets, graphs and note) with a single line of code"
240 | ]
241 | },
242 | {
243 | "cell_type": "code",
244 | "execution_count": null,
245 | "metadata": {
246 | "id": "g5FOnLfHnY14"
247 | },
248 | "outputs": [],
249 | "source": [
250 | "autolog.notebook(note=\"My first iteration to Vectice to document iris dataset\", capture_schema_only=False) #You can add a note to comment what you just logged into Vectice"
251 | ]
252 | },
253 | {
254 | "cell_type": "markdown",
255 | "metadata": {},
256 | "source": [
257 | "#### You have logged your assets to Vectice with a single line of code. You can click on the iteration link above to see your assets inside Vectice.\n",
258 | "**Note**: Autolog also allows you to log only the content of one cell, please check out our [documentation](https://api-docs.vectice.com/24.2/reference/vectice/autolog/) to learn more about the autolog functions and capabilities.
"
259 | ]
260 | },
261 | {
262 | "cell_type": "markdown",
263 | "metadata": {
264 | "id": "YnmFUplTpMoW"
265 | },
266 | "source": [
267 | "## 🥇 Congrats! You have learned how to successfully use Vectice to auto-document your assets in one line of code.
Easy right?
\n",
268 | "#### You can proceed back to the Vectice app continue documenting your work.\n"
269 | ]
270 | }
271 | ],
272 | "metadata": {
273 | "colab": {
274 | "provenance": []
275 | },
276 | "kernelspec": {
277 | "display_name": "Python 3",
278 | "name": "python3"
279 | },
280 | "language_info": {
281 | "codemirror_mode": {
282 | "name": "ipython",
283 | "version": 3
284 | },
285 | "file_extension": ".py",
286 | "mimetype": "text/x-python",
287 | "name": "python",
288 | "nbconvert_exporter": "python",
289 | "pygments_lexer": "ipython3",
290 | "version": "3.9.6"
291 | }
292 | },
293 | "nbformat": 4,
294 | "nbformat_minor": 0
295 | }
296 |
--------------------------------------------------------------------------------
/24.2/tutorial/Data Understanding.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "eabedfd0-bda4-4a9f-9ef2-6514a91dbb98",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Data Understanding Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Data Understanding\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.2/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.2 \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.2/"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": null,
30 | "id": "6e6350fb-5aec-448e-9e86-4715055033ee",
31 | "metadata": {},
32 | "outputs": [],
33 | "source": [
34 | "import warnings\n",
35 | "warnings.filterwarnings(\"ignore\", category=DeprecationWarning)"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": null,
41 | "id": "dc1525e3-eb5c-4e5b-855f-47dc2229afbf",
42 | "metadata": {},
43 | "outputs": [],
44 | "source": [
45 | "import pandas as pd\n",
46 | "import numpy as np\n",
47 | "import seaborn as sns\n",
48 | "import matplotlib.pyplot as plt"
49 | ]
50 | },
51 | {
52 | "attachments": {},
53 | "cell_type": "markdown",
54 | "id": "6da9fd84-09a0-4d30-bc00-c91dea5cd98f",
55 | "metadata": {},
56 | "source": [
57 | "## Install the latest Vectice Python client library"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": null,
63 | "id": "43c38240-69a2-41fb-bda7-46b7c40b963f",
64 | "metadata": {},
65 | "outputs": [],
66 | "source": [
67 | "%pip install --q vectice -U"
68 | ]
69 | },
70 | {
71 | "attachments": {},
72 | "cell_type": "markdown",
73 | "id": "10195b2a-a959-4a7b-a20b-e45c292930ef",
74 | "metadata": {},
75 | "source": [
76 | "## Get started by connecting to Vectice"
77 | ]
78 | },
79 | {
80 | "cell_type": "code",
81 | "execution_count": null,
82 | "id": "d34bced5-491f-400b-ac5d-e4665f6f6ae8",
83 | "metadata": {},
84 | "outputs": [],
85 | "source": [
86 | "import vectice\n",
87 | "\n",
88 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
89 | ]
90 | },
91 | {
92 | "attachments": {},
93 | "cell_type": "markdown",
94 | "id": "90a36ebc-023d-4f18-8382-8d92044492e3",
95 | "metadata": {},
96 | "source": [
97 | "## Specify which project phase you want to document\n",
98 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Data Understanding phase and copy paste your Phase Id below."
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": null,
104 | "id": "9d57e0e9-fc47-4b91-81b0-2f79907c901a",
105 | "metadata": {},
106 | "outputs": [],
107 | "source": [
108 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Data Understanding Phase ID"
109 | ]
110 | },
111 | {
112 | "attachments": {},
113 | "cell_type": "markdown",
114 | "id": "9a7957b4-c5dc-49ff-9612-f58ee9e63146",
115 | "metadata": {},
116 | "source": [
117 | "## Next we are going to create an iteration\n",
118 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
119 | ]
120 | },
121 | {
122 | "cell_type": "code",
123 | "execution_count": null,
124 | "id": "b315169a-d68f-4a17-9b39-56694b8be697",
125 | "metadata": {},
126 | "outputs": [],
127 | "source": [
128 | "iteration = phase.create_or_get_current_iteration()"
129 | ]
130 | },
131 | {
132 | "cell_type": "code",
133 | "execution_count": null,
134 | "id": "6c59effc-5b3f-4b75-aae4-f3d46be1218f",
135 | "metadata": {},
136 | "outputs": [],
137 | "source": [
138 | "df = pd.read_csv(\"https://raw.githubusercontent.com/vectice/GettingStarted/main/Tutorial%20data/SampleSuperstore.csv\", converters = {'Postal Code': str})\n",
139 | "df.to_csv(\"SampleSuperstore.csv\", index=False)"
140 | ]
141 | },
142 | {
143 | "attachments": {},
144 | "cell_type": "markdown",
145 | "id": "ef495b02-b785-41d5-8741-0796c3cf8da2",
146 | "metadata": {},
147 | "source": [
148 | "## Log a dataset\n",
149 | "Use the following code block to create a local dataset and generate a graph:"
150 | ]
151 | },
152 | {
153 | "cell_type": "code",
154 | "execution_count": null,
155 | "id": "4722446c-389d-4543-9280-9558e0a07bb7",
156 | "metadata": {},
157 | "outputs": [],
158 | "source": [
159 | "origin_ds = vectice.FileResource(paths=\"SampleSuperstore.csv\", dataframes=df)\n",
160 | "\n",
161 | "\n",
162 | "origin_dataset = vectice.Dataset.origin(\n",
163 | " name=\"ProductSales Origin\",\n",
164 | " resource=origin_ds, \n",
165 | ")"
166 | ]
167 | },
168 | {
169 | "cell_type": "code",
170 | "execution_count": null,
171 | "id": "53bdadfd-c9d3-4c6e-acb4-930751df7a54",
172 | "metadata": {},
173 | "outputs": [],
174 | "source": [
175 | "iteration.log(origin_dataset, section = \"collect initial data\")"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": null,
181 | "id": "140a4667-ba4c-492b-820b-cfa676dfe184",
182 | "metadata": {},
183 | "outputs": [],
184 | "source": [
185 | "iteration.log(str(df.columns.values), section = \"describe data\")"
186 | ]
187 | },
188 | {
189 | "cell_type": "code",
190 | "execution_count": null,
191 | "id": "473c3d35-7050-4a06-b867-b2861755ee3d",
192 | "metadata": {},
193 | "outputs": [],
194 | "source": [
195 | "## Checking for Multicollinearity\n",
196 | "corr_matrix=df.select_dtypes(\"number\").drop(\"Sales\",axis=1).corr()\n",
197 | "sns.heatmap(corr_matrix);\n",
198 | "plt.savefig(\"corr_matrix.png\")"
199 | ]
200 | },
201 | {
202 | "attachments": {},
203 | "cell_type": "markdown",
204 | "id": "437759e3",
205 | "metadata": {},
206 | "source": [
207 | "## Log graphs"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "45b5eb6d",
214 | "metadata": {},
215 | "source": [
216 | "You can log multiple items to a single iteration by using the `iterarion.log()` method."
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": null,
222 | "id": "e95ed5c6-fb4b-47be-bd7c-00747f8a4f3e",
223 | "metadata": {},
224 | "outputs": [],
225 | "source": [
226 | "iteration.log(\"corr_matrix.png\", section = \"explore data\")"
227 | ]
228 | },
229 | {
230 | "cell_type": "code",
231 | "execution_count": null,
232 | "id": "9e200853-9172-4e9a-a2e0-476beaabcd91",
233 | "metadata": {},
234 | "outputs": [],
235 | "source": [
236 | "#Checking for outliers\n",
237 | "sns.displot(df[\"Quantity\"])\n",
238 | "plt.savefig(\"Quantity.png\")"
239 | ]
240 | },
241 | {
242 | "cell_type": "code",
243 | "execution_count": null,
244 | "id": "07eff006-fef5-476c-859a-c01947c84c4e",
245 | "metadata": {},
246 | "outputs": [],
247 | "source": [
248 | "iteration.log(\"Quantity.png\", section = \"explore data\")"
249 | ]
250 | },
251 | {
252 | "cell_type": "code",
253 | "execution_count": null,
254 | "id": "4ec7ecfc",
255 | "metadata": {},
256 | "outputs": [],
257 | "source": [
258 | "iteration.complete()"
259 | ]
260 | },
261 | {
262 | "attachments": {},
263 | "cell_type": "markdown",
264 | "id": "421b65ad",
265 | "metadata": {},
266 | "source": [
267 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Data Understanding phase of the Tutorial Project.
\n",
268 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.2/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
269 | ]
270 | }
271 | ],
272 | "metadata": {
273 | "kernelspec": {
274 | "display_name": "Python 3",
275 | "language": "python",
276 | "name": "python3"
277 | },
278 | "language_info": {
279 | "codemirror_mode": {
280 | "name": "ipython",
281 | "version": 3
282 | },
283 | "file_extension": ".py",
284 | "mimetype": "text/x-python",
285 | "name": "python",
286 | "nbconvert_exporter": "python",
287 | "pygments_lexer": "ipython3",
288 | "version": "3.9.6"
289 | }
290 | },
291 | "nbformat": 4,
292 | "nbformat_minor": 5
293 | }
294 |
--------------------------------------------------------------------------------
/24.2/tutorial/Model Deployment.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "ce429bd4-5bcc-47f6-9a7a-19b039cc87c1",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Deployment Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Deployment\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.2/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.2 \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.2/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "3f34332a-2546-4d1f-86a5-cd263dd98f0d",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "3d9a66a7-e62d-459d-ab53-579644517548",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "ccd2d28a-abbc-4b5c-abf4-d9d6337bc28e",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "cd4f068f-60c6-436b-99b5-55575ecdbcb6",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "202bb8e0-4466-4383-b98e-ac735655a0af",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Deployment phase and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "3e19c58a-c203-4c84-8e1d-cd5ecbfa2d35",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") # Paste your Model Deployment phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "c9d27a6f-19e4-4f25-a50e-73e8fe0cc9d7",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "ef0de711-6ae8-484c-9831-f73d404f3e59",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "1ccf931b-9676-4f1b-868c-79c7f15eb0bf",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve A Previously Created Model\n",
114 | "We assume the model you stage in the previous Staging phase was approuved for deployment. For simplicity reasons, we will just fetch this model from Vectice retrieve its properties and add a fake endpoint "
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "81554fb3-316c-47ee-b04c-83c3f433285f",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "vect_model = connect.browse(\"MDV-xxxx\") #Pass your model ID Ridge Staging created on the Staging phase"
125 | ]
126 | },
127 | {
128 | "attachments": {},
129 | "cell_type": "markdown",
130 | "id": "38b747d7-e400-48a3-95ca-ceb61fb0d85c",
131 | "metadata": {},
132 | "source": [
133 | "## Log a Model\n",
134 | "Use the following code block to create a local Model"
135 | ]
136 | },
137 | {
138 | "cell_type": "code",
139 | "execution_count": null,
140 | "id": "0f73bd6f-b828-4603-ad8f-05cdb68f888b",
141 | "metadata": {},
142 | "outputs": [],
143 | "source": [
144 | "iteration.log(vect_model, section = \"deploy model\")"
145 | ]
146 | },
147 | {
148 | "attachments": {},
149 | "cell_type": "markdown",
150 | "id": "8ae90c1d-b385-422f-975e-9d7af6cadd0e",
151 | "metadata": {},
152 | "source": [
153 | "## Add a note\n",
154 | "Log the information for the deployment endpoint and model packaging as a note."
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": null,
160 | "id": "c7f7b1ec-19b2-4799-99f6-a4088e3fbc8c",
161 | "metadata": {},
162 | "outputs": [],
163 | "source": [
164 | "details = \"\"\"{\n",
165 | " \"Container image\": \"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest\",\n",
166 | " \"Model artifact location\": \"gs://dataproc-staging-us-west2-599225543291-rt9b6nzx/models/\",\n",
167 | " \"Prediction endpoint\": \"https://retail_prediction_service.com/predict\"\n",
168 | " }\"\"\"\n",
169 | "iteration.log(details, section = \"deploy model\")"
170 | ]
171 | },
172 | {
173 | "cell_type": "code",
174 | "execution_count": null,
175 | "id": "66ccf63e",
176 | "metadata": {},
177 | "outputs": [],
178 | "source": [
179 | "iteration.complete()"
180 | ]
181 | },
182 | {
183 | "attachments": {},
184 | "cell_type": "markdown",
185 | "id": "64ccc91e",
186 | "metadata": {},
187 | "source": [
188 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Deployment phase of the Tutorial Project.
\n",
189 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.2/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
190 | ]
191 | }
192 | ],
193 | "metadata": {
194 | "kernelspec": {
195 | "display_name": "Python 3",
196 | "language": "python",
197 | "name": "python3"
198 | },
199 | "language_info": {
200 | "codemirror_mode": {
201 | "name": "ipython",
202 | "version": 3
203 | },
204 | "file_extension": ".py",
205 | "mimetype": "text/x-python",
206 | "name": "python",
207 | "nbconvert_exporter": "python",
208 | "pygments_lexer": "ipython3",
209 | "version": "3.9.6"
210 | }
211 | },
212 | "nbformat": 4,
213 | "nbformat_minor": 5
214 | }
215 |
--------------------------------------------------------------------------------
/24.2/tutorial/Model Staging.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "43ca7ce4-3223-401e-a4af-cc7603f196a0",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Staging Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Staging\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.2/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.2 \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.2/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "156659ab-68d8-42bf-a296-b81419b77f59",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "13672b5c-e784-4c7c-a47b-1215a47a593a",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "00d29059-b8b9-422e-bc6f-5c66fce6596c",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "1645ed95-ef27-444a-b991-b35b7c9cad88",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "be757d4c-5049-43f6-b932-84b49c7038a0",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Staging and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "cfc1ff71-4a3b-4a70-adcd-7bbf690c5134",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Model Staging Phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "361081b0-0995-4c05-924f-8feaab8fdde1",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "94afc70e-37c1-475d-bc62-1bb8bdb887cd",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "8667308a-bf28-4b8d-8553-9d05a8158e03",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve previously created Datasets\n",
114 | "You can retrieve a variety of Vectice Objects with the browse('VECTICE-ID') method. Namely, Phases, Iterations, Datasets, Models..."
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "d934877d-cbba-4bc2-93d5-d723fa37b654",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "origin_ds = connect.browse(\"DTV-xxxx\") #Paste your Origin Dataset ID (i.e ProductSales Origin) created on Data Understanding phase\n",
125 | "cleaned_ds = connect.browse(\"DTV-xxxx\") #Paste your Cleaned Dataset ID (i.e ProductSales Cleaned) created on Data Preparation phase\n",
126 | "modeling_dataset = connect.browse(\"DTV-xxxx\") #Paste your Model Dataset ID (i.e ProductSales Modeling) created on Data Modeling phase"
127 | ]
128 | },
129 | {
130 | "attachments": {},
131 | "cell_type": "markdown",
132 | "id": "5562fc69-f3fd-41f2-a09b-21c0322f4a6a",
133 | "metadata": {},
134 | "source": [
135 | "## Log a Staging Model\n",
136 | "\n",
137 | "Imaging you created this model through an automated training pipeline and you log it at the end of the process.
For the purpose of the tutorial we will simply create an empty model."
138 | ]
139 | },
140 | {
141 | "cell_type": "code",
142 | "execution_count": null,
143 | "id": "94d501da-41e2-46f6-890c-21a36e188b42",
144 | "metadata": {},
145 | "outputs": [],
146 | "source": [
147 | "vect_model = vectice.Model(name=\"scikit-learn Ridge Regression Stage model\",library=\"scikit-learn\", technique=\"Ridge Regression\", metrics={\"mae_test\": 63.02}, properties={\"quarter\": \"Q1\"}, derived_from=modeling_dataset)"
148 | ]
149 | },
150 | {
151 | "cell_type": "code",
152 | "execution_count": null,
153 | "id": "dc49e9c6-93f6-473a-84ff-13e5f72052bb",
154 | "metadata": {},
155 | "outputs": [],
156 | "source": [
157 | "iteration.log(origin_ds, section = \"ingest data\")"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "id": "703aa51a-8476-4356-9326-58e0582e7b3c",
164 | "metadata": {},
165 | "outputs": [],
166 | "source": [
167 | "iteration.log(cleaned_ds, section = \"preprocess data\")"
168 | ]
169 | },
170 | {
171 | "cell_type": "code",
172 | "execution_count": null,
173 | "id": "145e04ed-09e3-4d33-bff5-c8ab51425594",
174 | "metadata": {},
175 | "outputs": [],
176 | "source": [
177 | "iteration.log(vect_model, section = \"train model\")"
178 | ]
179 | },
180 | {
181 | "attachments": {},
182 | "cell_type": "markdown",
183 | "id": "42e6cd6b-f39e-4b2d-a69f-22e9a5ab7bbd",
184 | "metadata": {},
185 | "source": [
186 | "## Add a note\n",
187 | "Use the following code block to save key performance metrics as a note that will be use for approving deployment to production"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": null,
193 | "id": "e33d20d7-e6ca-49bf-b4e5-fbe72795edfd",
194 | "metadata": {},
195 | "outputs": [],
196 | "source": [
197 | "iteration.log(\"\"\"Evaluation:\\nMAE vs Threshold: 63.02 vs 98 from Baseline \\nModel passed acceptance critera.\"\"\", section = \"evaluate model\")"
198 | ]
199 | },
200 | {
201 | "cell_type": "code",
202 | "execution_count": null,
203 | "id": "e2b804da",
204 | "metadata": {},
205 | "outputs": [],
206 | "source": [
207 | "iteration.complete()\n"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "e091dc76",
214 | "metadata": {},
215 | "source": [
216 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Staging phase of the Tutorial Project.
\n",
217 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.2/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
218 | ]
219 | }
220 | ],
221 | "metadata": {
222 | "kernelspec": {
223 | "display_name": "Python 3",
224 | "language": "python",
225 | "name": "python3"
226 | },
227 | "language_info": {
228 | "codemirror_mode": {
229 | "name": "ipython",
230 | "version": 3
231 | },
232 | "file_extension": ".py",
233 | "mimetype": "text/x-python",
234 | "name": "python",
235 | "nbconvert_exporter": "python",
236 | "pygments_lexer": "ipython3",
237 | "version": "3.9.6"
238 | }
239 | },
240 | "nbformat": 4,
241 | "nbformat_minor": 5
242 | }
243 |
--------------------------------------------------------------------------------
/24.2/tutorial/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/24.3.9/QuickStart Autolog.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "
\n",
9 | ""
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {
15 | "id": "twIzT22mtqhs"
16 | },
17 | "source": [
18 | "# Before you start with this Quickstart Notebook"
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "metadata": {
24 | "id": "iUp4X8V5tqhv"
25 | },
26 | "source": [
27 | "You will need:\n",
28 | "* An account in Vectice\n",
29 | "* An API key to connect to Vectice\n",
30 | "* The Phase Id of the project where you want to log your work\n",
31 | "\n",
32 | "### Important Resources\n",
33 | "* Vectice autolog documentation https://api-docs.vectice.com/24.3.9/reference/vectice/autolog/\n"
34 | ]
35 | },
36 | {
37 | "cell_type": "markdown",
38 | "metadata": {
39 | "id": "jER4KBN0JbSw"
40 | },
41 | "source": [
42 | "\n",
43 | "Automated code lineage: The code lineage functionalities are not covered as part of this QuickStart as they require first setting up a Git repository.\n",
44 | "
\n",
45 | "\n",
46 | "\n",
47 | "\n",
48 | "---\n",
49 | "\n"
50 | ]
51 | },
52 | {
53 | "cell_type": "markdown",
54 | "metadata": {
55 | "id": "7LArs6J5fyIz"
56 | },
57 | "source": [
58 | "## What to expect\n",
59 | "\n",
60 | "In this notebook, we will re-use the classical Iris modeling example to demonstrate how you can automatically document in Vectice your assets, such as datasets, models, graphs, and notes, using a few lines of code."
61 | ]
62 | },
63 | {
64 | "cell_type": "markdown",
65 | "metadata": {
66 | "id": "BWxVwtAdgSbj"
67 | },
68 | "source": [
69 | "## Install the latest Vectice Python client library"
70 | ]
71 | },
72 | {
73 | "cell_type": "code",
74 | "execution_count": null,
75 | "metadata": {
76 | "id": "bin0M8rKdfBU"
77 | },
78 | "outputs": [],
79 | "source": [
80 | "%pip install -q seaborn\n",
81 | "%pip install -q scikit-learn\n",
82 | "%pip install -q vectice -U"
83 | ]
84 | },
85 | {
86 | "cell_type": "markdown",
87 | "metadata": {
88 | "id": "1bwpySvqf5Ce"
89 | },
90 | "source": [
91 | "## Get started configuring the Vectice autolog"
92 | ]
93 | },
94 | {
95 | "cell_type": "markdown",
96 | "metadata": {
97 | "id": "jx5xlQFJxxQZ"
98 | },
99 | "source": [
100 | "**First, you need to configure the autolog. You will need your API key and Phase ID inside your Quickstart project to specify where to document your work. Before proceeding:**\n",
101 | "\n",
102 | "- Click on the key icon in the upper right corner of the Vectice app to create an API key, then copy and paste it into the code below.\n",
103 | "\n",
104 | "- In your Quickstart project, go to [Phase 2] Autolog phase and copy its Phase ID to paste in the code below."
105 | ]
106 | },
107 | {
108 | "cell_type": "code",
109 | "execution_count": null,
110 | "metadata": {
111 | "id": "frnhI_W9aOoZ"
112 | },
113 | "outputs": [],
114 | "source": [
115 | "import vectice\n",
116 | "from vectice import autolog\n",
117 | "\n",
118 | "autolog.config(api_token=\"your-api-key\", #Paste your API key\n",
119 | " host = 'your-host-info', #Paste your host information\n",
120 | " phase = 'your-phase-id') #Paste your Phase Id"
121 | ]
122 | },
123 | {
124 | "cell_type": "markdown",
125 | "metadata": {},
126 | "source": [
127 | "\n",
128 | " Important information:\n",
129 | "
Vectice Autolog is continuously evolving and we are actively enhancing supported libraries, environments, and functionalities to provide an improved user experience. \n",
130 | " Be sure to configure autolog at the beginning of your notebook. A late setup may require rerunning previous cells.\n",
131 | " Your feedback is highly valued. Please send any feedback to support@vectice.com.\n",
132 | "
\n",
133 | "\n",
134 | "For detailed information, supported libraries and environments, please consult our [Autolog documentation](https://api-docs.vectice.com/24.3.9/reference/vectice/autolog/).\n",
135 | ""
136 | ]
137 | },
138 | {
139 | "cell_type": "markdown",
140 | "metadata": {
141 | "id": "FYeCGcgLlsOL"
142 | },
143 | "source": [
144 | "# Auto-Document your work in Vectice\n",
145 | "We will prepare an example dataset based on the well-known iris dataset. We will then train a linear regression model using scikit-learn.\n",
146 | "After we complete this work and create those assets, we will log them to Vectice in a single line of code.\n",
147 | "This enables you to document your work as you go, and to never forget the data that was used, the models, the code and other artifacts."
148 | ]
149 | },
150 | {
151 | "cell_type": "markdown",
152 | "metadata": {
153 | "id": "6VvbrEsKl5bH"
154 | },
155 | "source": [
156 | "Use the following code block to create a dataset, generate a graph and build a model:"
157 | ]
158 | },
159 | {
160 | "cell_type": "code",
161 | "execution_count": null,
162 | "metadata": {
163 | "id": "jMC05CI6epHw"
164 | },
165 | "outputs": [],
166 | "source": [
167 | "import pandas as pd\n",
168 | "from sklearn import datasets\n",
169 | "\n",
170 | "iris = datasets.load_iris()\n",
171 | "\n",
172 | "df_iris = pd.DataFrame(data=iris.data, columns=iris.feature_names)\n",
173 | "df_iris['species'] = iris.target_names[iris.target]\n"
174 | ]
175 | },
176 | {
177 | "cell_type": "code",
178 | "execution_count": null,
179 | "metadata": {
180 | "id": "OMaIknlOtqh3"
181 | },
182 | "outputs": [],
183 | "source": [
184 | "import seaborn as sns\n",
185 | "import matplotlib.pyplot as plt\n",
186 | "\n",
187 | "sns.scatterplot(data=df_iris, x='sepal length (cm)',\n",
188 | " y='petal width (cm)', hue='species')\n",
189 | "plt.plot()\n",
190 | "\n",
191 | "#Save your graph to local file to be automatically captured by Vectice \n",
192 | "plt.savefig('Scatter_plot_iris.png') "
193 | ]
194 | },
195 | {
196 | "cell_type": "markdown",
197 | "metadata": {},
198 | "source": [
199 | "**Note**: Save graphs you want to log into a local file to be automatically captured by the autolog.
"
200 | ]
201 | },
202 | {
203 | "cell_type": "code",
204 | "execution_count": null,
205 | "metadata": {
206 | "id": "N0wsppAltqh5"
207 | },
208 | "outputs": [],
209 | "source": [
210 | "from sklearn.neighbors import KNeighborsClassifier\n",
211 | "from sklearn.model_selection import train_test_split\n",
212 | "from sklearn.metrics import accuracy_score\n",
213 | "\n",
214 | "train_df, test_df = train_test_split(df_iris, test_size=0.2, random_state=42)\n",
215 | "\n",
216 | "knn = KNeighborsClassifier()\n",
217 | "knn.fit(train_df[iris.feature_names],train_df[\"species\"])\n",
218 | "\n",
219 | "# Make predictions on the test set\n",
220 | "y_pred_test = knn.predict(test_df[iris.feature_names])\n",
221 | "y_pred_train = knn.predict(train_df[iris.feature_names])\n",
222 | "\n",
223 | "# Calculate the accuracy score\n",
224 | "accuracy_test= accuracy_score(test_df[\"species\"], y_pred_test)\n",
225 | "accuracy_train = accuracy_score(train_df[\"species\"], y_pred_train)"
226 | ]
227 | },
228 | {
229 | "cell_type": "markdown",
230 | "metadata": {},
231 | "source": [
232 | "**Note**: To link models and metrics using Vectice autolog, ensure each model and its metrics are in the same notebook cell (scikit metrics are currently supported)."
233 | ]
234 | },
235 | {
236 | "cell_type": "markdown",
237 | "metadata": {},
238 | "source": [
239 | "## Autolog your entire notebook's assets (model, datasets, graphs and note) with a single line of code"
240 | ]
241 | },
242 | {
243 | "cell_type": "code",
244 | "execution_count": null,
245 | "metadata": {
246 | "id": "g5FOnLfHnY14"
247 | },
248 | "outputs": [],
249 | "source": [
250 | "autolog.notebook(note=\"My first iteration to Vectice to document iris dataset\", capture_schema_only=False) #You can add a note to comment what you just logged into Vectice"
251 | ]
252 | },
253 | {
254 | "cell_type": "markdown",
255 | "metadata": {},
256 | "source": [
257 | "#### You have logged your assets to Vectice with a single line of code. You can click on the iteration link above to see your assets inside Vectice.\n",
258 | "**Note**: Autolog also allows you to log only the content of one cell, please check out our [documentation](https://api-docs.vectice.com/24.3.9/reference/vectice/autolog/) to learn more about the autolog functions and capabilities.
"
259 | ]
260 | },
261 | {
262 | "cell_type": "markdown",
263 | "metadata": {
264 | "id": "YnmFUplTpMoW"
265 | },
266 | "source": [
267 | "## 🥇 Congrats! You have learned how to successfully use Vectice to auto-document your assets in one line of code.
Easy right?
\n",
268 | "#### You can proceed back to the Vectice app continue documenting your work.\n"
269 | ]
270 | }
271 | ],
272 | "metadata": {
273 | "colab": {
274 | "provenance": []
275 | },
276 | "kernelspec": {
277 | "display_name": "Python 3",
278 | "name": "python3"
279 | },
280 | "language_info": {
281 | "codemirror_mode": {
282 | "name": "ipython",
283 | "version": 3
284 | },
285 | "file_extension": ".py",
286 | "mimetype": "text/x-python",
287 | "name": "python",
288 | "nbconvert_exporter": "python",
289 | "pygments_lexer": "ipython3",
290 | "version": "3.9.6"
291 | }
292 | },
293 | "nbformat": 4,
294 | "nbformat_minor": 0
295 | }
296 |
--------------------------------------------------------------------------------
/24.3.9/tutorial/Data Understanding.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "eabedfd0-bda4-4a9f-9ef2-6514a91dbb98",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Data Understanding Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Data Understanding\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.3.9/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.3.9/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.3.9/"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": null,
30 | "id": "6e6350fb-5aec-448e-9e86-4715055033ee",
31 | "metadata": {},
32 | "outputs": [],
33 | "source": [
34 | "import warnings\n",
35 | "warnings.filterwarnings(\"ignore\", category=DeprecationWarning)"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": null,
41 | "id": "dc1525e3-eb5c-4e5b-855f-47dc2229afbf",
42 | "metadata": {},
43 | "outputs": [],
44 | "source": [
45 | "import pandas as pd\n",
46 | "import numpy as np\n",
47 | "import seaborn as sns\n",
48 | "import matplotlib.pyplot as plt"
49 | ]
50 | },
51 | {
52 | "attachments": {},
53 | "cell_type": "markdown",
54 | "id": "6da9fd84-09a0-4d30-bc00-c91dea5cd98f",
55 | "metadata": {},
56 | "source": [
57 | "## Install the latest Vectice Python client library"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": null,
63 | "id": "43c38240-69a2-41fb-bda7-46b7c40b963f",
64 | "metadata": {},
65 | "outputs": [],
66 | "source": [
67 | "%pip install --q vectice -U"
68 | ]
69 | },
70 | {
71 | "attachments": {},
72 | "cell_type": "markdown",
73 | "id": "10195b2a-a959-4a7b-a20b-e45c292930ef",
74 | "metadata": {},
75 | "source": [
76 | "## Get started by connecting to Vectice"
77 | ]
78 | },
79 | {
80 | "cell_type": "code",
81 | "execution_count": null,
82 | "id": "d34bced5-491f-400b-ac5d-e4665f6f6ae8",
83 | "metadata": {},
84 | "outputs": [],
85 | "source": [
86 | "import vectice\n",
87 | "\n",
88 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
89 | ]
90 | },
91 | {
92 | "attachments": {},
93 | "cell_type": "markdown",
94 | "id": "90a36ebc-023d-4f18-8382-8d92044492e3",
95 | "metadata": {},
96 | "source": [
97 | "## Specify which project phase you want to document\n",
98 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Data Understanding phase and copy paste your Phase Id below."
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": null,
104 | "id": "9d57e0e9-fc47-4b91-81b0-2f79907c901a",
105 | "metadata": {},
106 | "outputs": [],
107 | "source": [
108 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Data Understanding Phase ID"
109 | ]
110 | },
111 | {
112 | "attachments": {},
113 | "cell_type": "markdown",
114 | "id": "9a7957b4-c5dc-49ff-9612-f58ee9e63146",
115 | "metadata": {},
116 | "source": [
117 | "## Next we are going to create an iteration\n",
118 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
119 | ]
120 | },
121 | {
122 | "cell_type": "code",
123 | "execution_count": null,
124 | "id": "b315169a-d68f-4a17-9b39-56694b8be697",
125 | "metadata": {},
126 | "outputs": [],
127 | "source": [
128 | "iteration = phase.create_or_get_current_iteration()"
129 | ]
130 | },
131 | {
132 | "cell_type": "code",
133 | "execution_count": null,
134 | "id": "6c59effc-5b3f-4b75-aae4-f3d46be1218f",
135 | "metadata": {},
136 | "outputs": [],
137 | "source": [
138 | "df = pd.read_csv(\"https://raw.githubusercontent.com/vectice/GettingStarted/main/Tutorial%20data/SampleSuperstore.csv\", converters = {'Postal Code': str})\n",
139 | "df.to_csv(\"SampleSuperstore.csv\", index=False)"
140 | ]
141 | },
142 | {
143 | "attachments": {},
144 | "cell_type": "markdown",
145 | "id": "ef495b02-b785-41d5-8741-0796c3cf8da2",
146 | "metadata": {},
147 | "source": [
148 | "## Log a dataset\n",
149 | "Use the following code block to create a local dataset and generate a graph:"
150 | ]
151 | },
152 | {
153 | "cell_type": "code",
154 | "execution_count": null,
155 | "id": "4722446c-389d-4543-9280-9558e0a07bb7",
156 | "metadata": {},
157 | "outputs": [],
158 | "source": [
159 | "origin_ds = vectice.FileResource(paths=\"SampleSuperstore.csv\", dataframes=df)\n",
160 | "\n",
161 | "\n",
162 | "origin_dataset = vectice.Dataset.origin(\n",
163 | " name=\"ProductSales Origin\",\n",
164 | " resource=origin_ds, \n",
165 | ")"
166 | ]
167 | },
168 | {
169 | "cell_type": "code",
170 | "execution_count": null,
171 | "id": "53bdadfd-c9d3-4c6e-acb4-930751df7a54",
172 | "metadata": {},
173 | "outputs": [],
174 | "source": [
175 | "iteration.log(origin_dataset, section = \"collect initial data\")"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": null,
181 | "id": "140a4667-ba4c-492b-820b-cfa676dfe184",
182 | "metadata": {},
183 | "outputs": [],
184 | "source": [
185 | "iteration.log(str(df.columns.values), section = \"describe data\")"
186 | ]
187 | },
188 | {
189 | "cell_type": "code",
190 | "execution_count": null,
191 | "id": "473c3d35-7050-4a06-b867-b2861755ee3d",
192 | "metadata": {},
193 | "outputs": [],
194 | "source": [
195 | "## Checking for Multicollinearity\n",
196 | "corr_matrix=df.select_dtypes(\"number\").drop(\"Sales\",axis=1).corr()\n",
197 | "sns.heatmap(corr_matrix);\n",
198 | "plt.savefig(\"corr_matrix.png\")"
199 | ]
200 | },
201 | {
202 | "attachments": {},
203 | "cell_type": "markdown",
204 | "id": "437759e3",
205 | "metadata": {},
206 | "source": [
207 | "## Log graphs"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "45b5eb6d",
214 | "metadata": {},
215 | "source": [
216 | "You can log multiple items to a single iteration by using the `iterarion.log()` method."
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": null,
222 | "id": "e95ed5c6-fb4b-47be-bd7c-00747f8a4f3e",
223 | "metadata": {},
224 | "outputs": [],
225 | "source": [
226 | "iteration.log(\"corr_matrix.png\", section = \"explore data\")"
227 | ]
228 | },
229 | {
230 | "cell_type": "code",
231 | "execution_count": null,
232 | "id": "9e200853-9172-4e9a-a2e0-476beaabcd91",
233 | "metadata": {},
234 | "outputs": [],
235 | "source": [
236 | "#Checking for outliers\n",
237 | "sns.displot(df[\"Quantity\"])\n",
238 | "plt.savefig(\"Quantity.png\")"
239 | ]
240 | },
241 | {
242 | "cell_type": "code",
243 | "execution_count": null,
244 | "id": "07eff006-fef5-476c-859a-c01947c84c4e",
245 | "metadata": {},
246 | "outputs": [],
247 | "source": [
248 | "iteration.log(\"Quantity.png\", section = \"explore data\")"
249 | ]
250 | },
251 | {
252 | "cell_type": "code",
253 | "execution_count": null,
254 | "id": "4ec7ecfc",
255 | "metadata": {},
256 | "outputs": [],
257 | "source": [
258 | "iteration.complete()"
259 | ]
260 | },
261 | {
262 | "attachments": {},
263 | "cell_type": "markdown",
264 | "id": "421b65ad",
265 | "metadata": {},
266 | "source": [
267 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Data Understanding phase of the Tutorial Project.
\n",
268 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.3.9/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
269 | ]
270 | }
271 | ],
272 | "metadata": {
273 | "kernelspec": {
274 | "display_name": "Python 3",
275 | "language": "python",
276 | "name": "python3"
277 | },
278 | "language_info": {
279 | "codemirror_mode": {
280 | "name": "ipython",
281 | "version": 3
282 | },
283 | "file_extension": ".py",
284 | "mimetype": "text/x-python",
285 | "name": "python",
286 | "nbconvert_exporter": "python",
287 | "pygments_lexer": "ipython3",
288 | "version": "3.9.6"
289 | }
290 | },
291 | "nbformat": 4,
292 | "nbformat_minor": 5
293 | }
294 |
--------------------------------------------------------------------------------
/24.3.9/tutorial/Model Deployment.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "ce429bd4-5bcc-47f6-9a7a-19b039cc87c1",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Deployment Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Deployment\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.3.9/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.3.9/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.3.9/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "3f34332a-2546-4d1f-86a5-cd263dd98f0d",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "3d9a66a7-e62d-459d-ab53-579644517548",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "ccd2d28a-abbc-4b5c-abf4-d9d6337bc28e",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "cd4f068f-60c6-436b-99b5-55575ecdbcb6",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "202bb8e0-4466-4383-b98e-ac735655a0af",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Deployment phase and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "3e19c58a-c203-4c84-8e1d-cd5ecbfa2d35",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") # Paste your Model Deployment phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "c9d27a6f-19e4-4f25-a50e-73e8fe0cc9d7",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "ef0de711-6ae8-484c-9831-f73d404f3e59",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "1ccf931b-9676-4f1b-868c-79c7f15eb0bf",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve A Previously Created Model\n",
114 | "We assume the model you stage in the previous Staging phase was approuved for deployment. For simplicity reasons, we will just fetch this model from Vectice retrieve its properties and add a fake endpoint "
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "81554fb3-316c-47ee-b04c-83c3f433285f",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "vect_model = connect.browse(\"MDV-xxxx\") #Pass your model ID Ridge Staging created on the Staging phase"
125 | ]
126 | },
127 | {
128 | "attachments": {},
129 | "cell_type": "markdown",
130 | "id": "38b747d7-e400-48a3-95ca-ceb61fb0d85c",
131 | "metadata": {},
132 | "source": [
133 | "## Log a Model\n",
134 | "Use the following code block to create a local Model"
135 | ]
136 | },
137 | {
138 | "cell_type": "code",
139 | "execution_count": null,
140 | "id": "0f73bd6f-b828-4603-ad8f-05cdb68f888b",
141 | "metadata": {},
142 | "outputs": [],
143 | "source": [
144 | "iteration.log(vect_model, section = \"deploy model\")"
145 | ]
146 | },
147 | {
148 | "attachments": {},
149 | "cell_type": "markdown",
150 | "id": "8ae90c1d-b385-422f-975e-9d7af6cadd0e",
151 | "metadata": {},
152 | "source": [
153 | "## Add a note\n",
154 | "Log the information for the deployment endpoint and model packaging as a note."
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": null,
160 | "id": "c7f7b1ec-19b2-4799-99f6-a4088e3fbc8c",
161 | "metadata": {},
162 | "outputs": [],
163 | "source": [
164 | "details = \"\"\"{\n",
165 | " \"Container image\": \"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest\",\n",
166 | " \"Model artifact location\": \"gs://dataproc-staging-us-west2-599225543291-rt9b6nzx/models/\",\n",
167 | " \"Prediction endpoint\": \"https://retail_prediction_service.com/predict\"\n",
168 | " }\"\"\"\n",
169 | "iteration.log(details, section = \"deploy model\")"
170 | ]
171 | },
172 | {
173 | "cell_type": "code",
174 | "execution_count": null,
175 | "id": "66ccf63e",
176 | "metadata": {},
177 | "outputs": [],
178 | "source": [
179 | "iteration.complete()"
180 | ]
181 | },
182 | {
183 | "attachments": {},
184 | "cell_type": "markdown",
185 | "id": "64ccc91e",
186 | "metadata": {},
187 | "source": [
188 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Deployment phase of the Tutorial Project.
\n",
189 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.3.9/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
190 | ]
191 | }
192 | ],
193 | "metadata": {
194 | "kernelspec": {
195 | "display_name": "Python 3",
196 | "language": "python",
197 | "name": "python3"
198 | },
199 | "language_info": {
200 | "codemirror_mode": {
201 | "name": "ipython",
202 | "version": 3
203 | },
204 | "file_extension": ".py",
205 | "mimetype": "text/x-python",
206 | "name": "python",
207 | "nbconvert_exporter": "python",
208 | "pygments_lexer": "ipython3",
209 | "version": "3.9.6"
210 | }
211 | },
212 | "nbformat": 4,
213 | "nbformat_minor": 5
214 | }
215 |
--------------------------------------------------------------------------------
/24.3.9/tutorial/Model Staging.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "43ca7ce4-3223-401e-a4af-cc7603f196a0",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Staging Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Staging\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/v/24.3.9/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/v/24.3.9/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/24.3.9/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "156659ab-68d8-42bf-a296-b81419b77f59",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "13672b5c-e784-4c7c-a47b-1215a47a593a",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "00d29059-b8b9-422e-bc6f-5c66fce6596c",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "1645ed95-ef27-444a-b991-b35b7c9cad88",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "be757d4c-5049-43f6-b932-84b49c7038a0",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Staging and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "cfc1ff71-4a3b-4a70-adcd-7bbf690c5134",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Model Staging Phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "361081b0-0995-4c05-924f-8feaab8fdde1",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "94afc70e-37c1-475d-bc62-1bb8bdb887cd",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "8667308a-bf28-4b8d-8553-9d05a8158e03",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve previously created Datasets\n",
114 | "You can retrieve a variety of Vectice Objects with the browse('VECTICE-ID') method. Namely, Phases, Iterations, Datasets, Models..."
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "d934877d-cbba-4bc2-93d5-d723fa37b654",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "origin_ds = connect.browse(\"DTV-xxxx\") #Paste your Origin Dataset ID (i.e ProductSales Origin) created on Data Understanding phase\n",
125 | "cleaned_ds = connect.browse(\"DTV-xxxx\") #Paste your Cleaned Dataset ID (i.e ProductSales Cleaned) created on Data Preparation phase\n",
126 | "modeling_dataset = connect.browse(\"DTV-xxxx\") #Paste your Model Dataset ID (i.e ProductSales Modeling) created on Data Modeling phase"
127 | ]
128 | },
129 | {
130 | "attachments": {},
131 | "cell_type": "markdown",
132 | "id": "5562fc69-f3fd-41f2-a09b-21c0322f4a6a",
133 | "metadata": {},
134 | "source": [
135 | "## Log a Staging Model\n",
136 | "\n",
137 | "Imaging you created this model through an automated training pipeline and you log it at the end of the process.
For the purpose of the tutorial we will simply create an empty model."
138 | ]
139 | },
140 | {
141 | "cell_type": "code",
142 | "execution_count": null,
143 | "id": "94d501da-41e2-46f6-890c-21a36e188b42",
144 | "metadata": {},
145 | "outputs": [],
146 | "source": [
147 | "vect_model = vectice.Model(name=\"scikit-learn Ridge Regression Stage model\",library=\"scikit-learn\", technique=\"Ridge Regression\", metrics={\"mae_test\": 63.02}, properties={\"quarter\": \"Q1\"}, derived_from=modeling_dataset)"
148 | ]
149 | },
150 | {
151 | "cell_type": "code",
152 | "execution_count": null,
153 | "id": "dc49e9c6-93f6-473a-84ff-13e5f72052bb",
154 | "metadata": {},
155 | "outputs": [],
156 | "source": [
157 | "iteration.log(origin_ds, section = \"ingest data\")"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "id": "703aa51a-8476-4356-9326-58e0582e7b3c",
164 | "metadata": {},
165 | "outputs": [],
166 | "source": [
167 | "iteration.log(cleaned_ds, section = \"preprocess data\")"
168 | ]
169 | },
170 | {
171 | "cell_type": "code",
172 | "execution_count": null,
173 | "id": "145e04ed-09e3-4d33-bff5-c8ab51425594",
174 | "metadata": {},
175 | "outputs": [],
176 | "source": [
177 | "iteration.log(vect_model, section = \"train model\")"
178 | ]
179 | },
180 | {
181 | "attachments": {},
182 | "cell_type": "markdown",
183 | "id": "42e6cd6b-f39e-4b2d-a69f-22e9a5ab7bbd",
184 | "metadata": {},
185 | "source": [
186 | "## Add a note\n",
187 | "Use the following code block to save key performance metrics as a note that will be use for approving deployment to production"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": null,
193 | "id": "e33d20d7-e6ca-49bf-b4e5-fbe72795edfd",
194 | "metadata": {},
195 | "outputs": [],
196 | "source": [
197 | "iteration.log(\"\"\"Evaluation:\\nMAE vs Threshold: 63.02 vs 98 from Baseline \\nModel passed acceptance critera.\"\"\", section = \"evaluate model\")"
198 | ]
199 | },
200 | {
201 | "cell_type": "code",
202 | "execution_count": null,
203 | "id": "e2b804da",
204 | "metadata": {},
205 | "outputs": [],
206 | "source": [
207 | "iteration.complete()\n"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "e091dc76",
214 | "metadata": {},
215 | "source": [
216 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Staging phase of the Tutorial Project.
\n",
217 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/v/24.3.9/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
218 | ]
219 | }
220 | ],
221 | "metadata": {
222 | "kernelspec": {
223 | "display_name": "Python 3",
224 | "language": "python",
225 | "name": "python3"
226 | },
227 | "language_info": {
228 | "codemirror_mode": {
229 | "name": "ipython",
230 | "version": 3
231 | },
232 | "file_extension": ".py",
233 | "mimetype": "text/x-python",
234 | "name": "python",
235 | "nbconvert_exporter": "python",
236 | "pygments_lexer": "ipython3",
237 | "version": "3.9.6"
238 | }
239 | },
240 | "nbformat": 4,
241 | "nbformat_minor": 5
242 | }
243 |
--------------------------------------------------------------------------------
/24.3.9/tutorial/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/24.3/QuickStart Autolog.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "
\n",
9 | ""
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {
15 | "id": "twIzT22mtqhs"
16 | },
17 | "source": [
18 | "# Before you start with this Quickstart Notebook"
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "metadata": {
24 | "id": "iUp4X8V5tqhv"
25 | },
26 | "source": [
27 | "You will need:\n",
28 | "* An account in Vectice\n",
29 | "* An API key to connect to Vectice\n",
30 | "* The Phase Id of the project where you want to log your work\n",
31 | "\n",
32 | "### Important Resources\n",
33 | "* Vectice autolog documentation https://api-docs.vectice.com/reference/vectice/autolog/\n"
34 | ]
35 | },
36 | {
37 | "cell_type": "markdown",
38 | "metadata": {
39 | "id": "jER4KBN0JbSw"
40 | },
41 | "source": [
42 | "\n",
43 | "Automated code lineage: The code lineage functionalities are not covered as part of this QuickStart as they require first setting up a Git repository.\n",
44 | "
\n",
45 | "\n",
46 | "\n",
47 | "\n",
48 | "---\n",
49 | "\n"
50 | ]
51 | },
52 | {
53 | "cell_type": "markdown",
54 | "metadata": {
55 | "id": "7LArs6J5fyIz"
56 | },
57 | "source": [
58 | "## What to expect\n",
59 | "\n",
60 | "In this notebook, we will re-use the classical Iris modeling example to demonstrate how you can automatically document in Vectice your assets, such as datasets, models, graphs, and notes, using a few lines of code."
61 | ]
62 | },
63 | {
64 | "cell_type": "markdown",
65 | "metadata": {
66 | "id": "BWxVwtAdgSbj"
67 | },
68 | "source": [
69 | "## Install the latest Vectice Python client library"
70 | ]
71 | },
72 | {
73 | "cell_type": "code",
74 | "execution_count": null,
75 | "metadata": {
76 | "id": "bin0M8rKdfBU"
77 | },
78 | "outputs": [],
79 | "source": [
80 | "%pip install -q seaborn\n",
81 | "%pip install -q scikit-learn\n",
82 | "%pip install -q vectice -U"
83 | ]
84 | },
85 | {
86 | "cell_type": "markdown",
87 | "metadata": {
88 | "id": "1bwpySvqf5Ce"
89 | },
90 | "source": [
91 | "## Get started configuring the Vectice autolog"
92 | ]
93 | },
94 | {
95 | "cell_type": "markdown",
96 | "metadata": {
97 | "id": "jx5xlQFJxxQZ"
98 | },
99 | "source": [
100 | "**First, you need to configure the autolog. You will need your API key and Phase ID inside your Quickstart project to specify where to document your work. Before proceeding:**\n",
101 | "\n",
102 | "- Click on the key icon in the upper right corner of the Vectice app to create an API key, then copy and paste it into the code below.\n",
103 | "\n",
104 | "- In your Quickstart project, go to [Phase 2] Autolog phase and copy its Phase ID to paste in the code below."
105 | ]
106 | },
107 | {
108 | "cell_type": "code",
109 | "execution_count": null,
110 | "metadata": {
111 | "id": "frnhI_W9aOoZ"
112 | },
113 | "outputs": [],
114 | "source": [
115 | "import vectice\n",
116 | "from vectice import autolog\n",
117 | "\n",
118 | "autolog.config(api_token=\"your-api-key\", #Paste your API key\n",
119 | " host = 'your-host-info', #Paste your host information\n",
120 | " phase = 'your-phase-id') #Paste your Phase Id"
121 | ]
122 | },
123 | {
124 | "cell_type": "markdown",
125 | "metadata": {},
126 | "source": [
127 | "\n",
128 | " Important information:\n",
129 | "
Vectice Autolog is continuously evolving and we are actively enhancing supported libraries, environments, and functionalities to provide an improved user experience. \n",
130 | " Be sure to configure autolog at the beginning of your notebook. A late setup may require rerunning previous cells.\n",
131 | " Your feedback is highly valued. Please send any feedback to support@vectice.com.\n",
132 | "
\n",
133 | "\n",
134 | "For detailed information, supported libraries and environments, please consult our [Autolog documentation](https://api-docs.vectice.com/reference/vectice/autolog/).\n",
135 | ""
136 | ]
137 | },
138 | {
139 | "cell_type": "markdown",
140 | "metadata": {
141 | "id": "FYeCGcgLlsOL"
142 | },
143 | "source": [
144 | "# Auto-Document your work in Vectice\n",
145 | "We will prepare an example dataset based on the well-known iris dataset. We will then train a linear regression model using scikit-learn.\n",
146 | "After we complete this work and create those assets, we will log them to Vectice in a single line of code.\n",
147 | "This enables you to document your work as you go, and to never forget the data that was used, the models, the code and other artifacts."
148 | ]
149 | },
150 | {
151 | "cell_type": "markdown",
152 | "metadata": {
153 | "id": "6VvbrEsKl5bH"
154 | },
155 | "source": [
156 | "Use the following code block to create a dataset, generate a graph and build a model:"
157 | ]
158 | },
159 | {
160 | "cell_type": "code",
161 | "execution_count": null,
162 | "metadata": {
163 | "id": "jMC05CI6epHw"
164 | },
165 | "outputs": [],
166 | "source": [
167 | "import pandas as pd\n",
168 | "from sklearn import datasets\n",
169 | "\n",
170 | "iris = datasets.load_iris()\n",
171 | "\n",
172 | "df_iris = pd.DataFrame(data=iris.data, columns=iris.feature_names)\n",
173 | "df_iris['species'] = iris.target_names[iris.target]\n"
174 | ]
175 | },
176 | {
177 | "cell_type": "code",
178 | "execution_count": null,
179 | "metadata": {
180 | "id": "OMaIknlOtqh3"
181 | },
182 | "outputs": [],
183 | "source": [
184 | "import seaborn as sns\n",
185 | "import matplotlib.pyplot as plt\n",
186 | "\n",
187 | "sns.scatterplot(data=df_iris, x='sepal length (cm)',\n",
188 | " y='petal width (cm)', hue='species')\n",
189 | "plt.plot()\n",
190 | "\n",
191 | "#Save your graph to local file to be automatically captured by Vectice \n",
192 | "plt.savefig('Scatter_plot_iris.png') "
193 | ]
194 | },
195 | {
196 | "cell_type": "markdown",
197 | "metadata": {},
198 | "source": [
199 | "**Note**: Save graphs you want to log into a local file to be automatically captured by the autolog.
"
200 | ]
201 | },
202 | {
203 | "cell_type": "code",
204 | "execution_count": null,
205 | "metadata": {
206 | "id": "N0wsppAltqh5"
207 | },
208 | "outputs": [],
209 | "source": [
210 | "from sklearn.neighbors import KNeighborsClassifier\n",
211 | "from sklearn.model_selection import train_test_split\n",
212 | "from sklearn.metrics import accuracy_score\n",
213 | "\n",
214 | "train_df, test_df = train_test_split(df_iris, test_size=0.2, random_state=42)\n",
215 | "\n",
216 | "knn = KNeighborsClassifier()\n",
217 | "knn.fit(train_df[iris.feature_names],train_df[\"species\"])\n",
218 | "\n",
219 | "# Make predictions on the test set\n",
220 | "y_pred_test = knn.predict(test_df[iris.feature_names])\n",
221 | "y_pred_train = knn.predict(train_df[iris.feature_names])\n",
222 | "\n",
223 | "# Calculate the accuracy score\n",
224 | "accuracy_test= accuracy_score(test_df[\"species\"], y_pred_test)\n",
225 | "accuracy_train = accuracy_score(train_df[\"species\"], y_pred_train)"
226 | ]
227 | },
228 | {
229 | "cell_type": "markdown",
230 | "metadata": {},
231 | "source": [
232 | "**Note**: To link models and metrics using Vectice autolog, ensure each model and its metrics are in the same notebook cell (scikit metrics are currently supported)."
233 | ]
234 | },
235 | {
236 | "cell_type": "markdown",
237 | "metadata": {},
238 | "source": [
239 | "## Autolog your entire notebook's assets (model, datasets, graphs and note) with a single line of code"
240 | ]
241 | },
242 | {
243 | "cell_type": "code",
244 | "execution_count": null,
245 | "metadata": {
246 | "id": "g5FOnLfHnY14"
247 | },
248 | "outputs": [],
249 | "source": [
250 | "autolog.notebook(note=\"My first iteration to Vectice to document iris dataset\", capture_schema_only=False) #You can add a note to comment what you just logged into Vectice"
251 | ]
252 | },
253 | {
254 | "cell_type": "markdown",
255 | "metadata": {},
256 | "source": [
257 | "#### You have logged your assets to Vectice with a single line of code. You can click on the iteration link above to see your assets inside Vectice.\n",
258 | "**Note**: Autolog also allows you to log only the content of one cell, please check out our [documentation](https://api-docs.vectice.com/reference/vectice/autolog/) to learn more about the autolog functions and capabilities.
"
259 | ]
260 | },
261 | {
262 | "cell_type": "markdown",
263 | "metadata": {
264 | "id": "YnmFUplTpMoW"
265 | },
266 | "source": [
267 | "## 🥇 Congrats! You have learned how to successfully use Vectice to auto-document your assets in one line of code.
Easy right?
\n",
268 | "#### You can proceed back to the Vectice app continue documenting your work.\n"
269 | ]
270 | }
271 | ],
272 | "metadata": {
273 | "colab": {
274 | "provenance": []
275 | },
276 | "kernelspec": {
277 | "display_name": "Python 3",
278 | "name": "python3"
279 | },
280 | "language_info": {
281 | "codemirror_mode": {
282 | "name": "ipython",
283 | "version": 3
284 | },
285 | "file_extension": ".py",
286 | "mimetype": "text/x-python",
287 | "name": "python",
288 | "nbconvert_exporter": "python",
289 | "pygments_lexer": "ipython3",
290 | "version": "3.9.6"
291 | }
292 | },
293 | "nbformat": 4,
294 | "nbformat_minor": 0
295 | }
296 |
--------------------------------------------------------------------------------
/24.3/tutorial/Data Understanding.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "eabedfd0-bda4-4a9f-9ef2-6514a91dbb98",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Data Understanding Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Data Understanding\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": null,
30 | "id": "6e6350fb-5aec-448e-9e86-4715055033ee",
31 | "metadata": {},
32 | "outputs": [],
33 | "source": [
34 | "import warnings\n",
35 | "warnings.filterwarnings(\"ignore\", category=DeprecationWarning)"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": null,
41 | "id": "dc1525e3-eb5c-4e5b-855f-47dc2229afbf",
42 | "metadata": {},
43 | "outputs": [],
44 | "source": [
45 | "import pandas as pd\n",
46 | "import numpy as np\n",
47 | "import seaborn as sns\n",
48 | "import matplotlib.pyplot as plt"
49 | ]
50 | },
51 | {
52 | "attachments": {},
53 | "cell_type": "markdown",
54 | "id": "6da9fd84-09a0-4d30-bc00-c91dea5cd98f",
55 | "metadata": {},
56 | "source": [
57 | "## Install the latest Vectice Python client library"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": null,
63 | "id": "43c38240-69a2-41fb-bda7-46b7c40b963f",
64 | "metadata": {},
65 | "outputs": [],
66 | "source": [
67 | "%pip install --q vectice -U"
68 | ]
69 | },
70 | {
71 | "attachments": {},
72 | "cell_type": "markdown",
73 | "id": "10195b2a-a959-4a7b-a20b-e45c292930ef",
74 | "metadata": {},
75 | "source": [
76 | "## Get started by connecting to Vectice"
77 | ]
78 | },
79 | {
80 | "cell_type": "code",
81 | "execution_count": null,
82 | "id": "d34bced5-491f-400b-ac5d-e4665f6f6ae8",
83 | "metadata": {},
84 | "outputs": [],
85 | "source": [
86 | "import vectice\n",
87 | "\n",
88 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
89 | ]
90 | },
91 | {
92 | "attachments": {},
93 | "cell_type": "markdown",
94 | "id": "90a36ebc-023d-4f18-8382-8d92044492e3",
95 | "metadata": {},
96 | "source": [
97 | "## Specify which project phase you want to document\n",
98 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Data Understanding phase and copy paste your Phase Id below."
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": null,
104 | "id": "9d57e0e9-fc47-4b91-81b0-2f79907c901a",
105 | "metadata": {},
106 | "outputs": [],
107 | "source": [
108 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Data Understanding Phase ID"
109 | ]
110 | },
111 | {
112 | "attachments": {},
113 | "cell_type": "markdown",
114 | "id": "9a7957b4-c5dc-49ff-9612-f58ee9e63146",
115 | "metadata": {},
116 | "source": [
117 | "## Next we are going to create an iteration\n",
118 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
119 | ]
120 | },
121 | {
122 | "cell_type": "code",
123 | "execution_count": null,
124 | "id": "b315169a-d68f-4a17-9b39-56694b8be697",
125 | "metadata": {},
126 | "outputs": [],
127 | "source": [
128 | "iteration = phase.create_or_get_current_iteration()"
129 | ]
130 | },
131 | {
132 | "cell_type": "code",
133 | "execution_count": null,
134 | "id": "6c59effc-5b3f-4b75-aae4-f3d46be1218f",
135 | "metadata": {},
136 | "outputs": [],
137 | "source": [
138 | "df = pd.read_csv(\"https://raw.githubusercontent.com/vectice/GettingStarted/main/Tutorial%20data/SampleSuperstore.csv\", converters = {'Postal Code': str})\n",
139 | "df.to_csv(\"SampleSuperstore.csv\", index=False)"
140 | ]
141 | },
142 | {
143 | "attachments": {},
144 | "cell_type": "markdown",
145 | "id": "ef495b02-b785-41d5-8741-0796c3cf8da2",
146 | "metadata": {},
147 | "source": [
148 | "## Log a dataset\n",
149 | "Use the following code block to create a local dataset and generate a graph:"
150 | ]
151 | },
152 | {
153 | "cell_type": "code",
154 | "execution_count": null,
155 | "id": "4722446c-389d-4543-9280-9558e0a07bb7",
156 | "metadata": {},
157 | "outputs": [],
158 | "source": [
159 | "origin_ds = vectice.FileResource(paths=\"SampleSuperstore.csv\", dataframes=df)\n",
160 | "\n",
161 | "\n",
162 | "origin_dataset = vectice.Dataset.origin(\n",
163 | " name=\"ProductSales Origin\",\n",
164 | " resource=origin_ds, \n",
165 | ")"
166 | ]
167 | },
168 | {
169 | "cell_type": "code",
170 | "execution_count": null,
171 | "id": "53bdadfd-c9d3-4c6e-acb4-930751df7a54",
172 | "metadata": {},
173 | "outputs": [],
174 | "source": [
175 | "iteration.log(origin_dataset, section = \"collect initial data\")"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": null,
181 | "id": "140a4667-ba4c-492b-820b-cfa676dfe184",
182 | "metadata": {},
183 | "outputs": [],
184 | "source": [
185 | "iteration.log(str(df.columns.values), section = \"describe data\")"
186 | ]
187 | },
188 | {
189 | "cell_type": "code",
190 | "execution_count": null,
191 | "id": "473c3d35-7050-4a06-b867-b2861755ee3d",
192 | "metadata": {},
193 | "outputs": [],
194 | "source": [
195 | "## Checking for Multicollinearity\n",
196 | "corr_matrix=df.select_dtypes(\"number\").drop(\"Sales\",axis=1).corr()\n",
197 | "sns.heatmap(corr_matrix);\n",
198 | "plt.savefig(\"corr_matrix.png\")"
199 | ]
200 | },
201 | {
202 | "attachments": {},
203 | "cell_type": "markdown",
204 | "id": "437759e3",
205 | "metadata": {},
206 | "source": [
207 | "## Log graphs"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "45b5eb6d",
214 | "metadata": {},
215 | "source": [
216 | "You can log multiple items to a single iteration by using the `iterarion.log()` method."
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": null,
222 | "id": "e95ed5c6-fb4b-47be-bd7c-00747f8a4f3e",
223 | "metadata": {},
224 | "outputs": [],
225 | "source": [
226 | "iteration.log(\"corr_matrix.png\", section = \"explore data\")"
227 | ]
228 | },
229 | {
230 | "cell_type": "code",
231 | "execution_count": null,
232 | "id": "9e200853-9172-4e9a-a2e0-476beaabcd91",
233 | "metadata": {},
234 | "outputs": [],
235 | "source": [
236 | "#Checking for outliers\n",
237 | "sns.displot(df[\"Quantity\"])\n",
238 | "plt.savefig(\"Quantity.png\")"
239 | ]
240 | },
241 | {
242 | "cell_type": "code",
243 | "execution_count": null,
244 | "id": "07eff006-fef5-476c-859a-c01947c84c4e",
245 | "metadata": {},
246 | "outputs": [],
247 | "source": [
248 | "iteration.log(\"Quantity.png\", section = \"explore data\")"
249 | ]
250 | },
251 | {
252 | "cell_type": "code",
253 | "execution_count": null,
254 | "id": "4ec7ecfc",
255 | "metadata": {},
256 | "outputs": [],
257 | "source": [
258 | "iteration.complete()"
259 | ]
260 | },
261 | {
262 | "attachments": {},
263 | "cell_type": "markdown",
264 | "id": "421b65ad",
265 | "metadata": {},
266 | "source": [
267 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Data Understanding phase of the Tutorial Project.
\n",
268 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
269 | ]
270 | }
271 | ],
272 | "metadata": {
273 | "kernelspec": {
274 | "display_name": "Python 3",
275 | "language": "python",
276 | "name": "python3"
277 | },
278 | "language_info": {
279 | "codemirror_mode": {
280 | "name": "ipython",
281 | "version": 3
282 | },
283 | "file_extension": ".py",
284 | "mimetype": "text/x-python",
285 | "name": "python",
286 | "nbconvert_exporter": "python",
287 | "pygments_lexer": "ipython3",
288 | "version": "3.9.6"
289 | }
290 | },
291 | "nbformat": 4,
292 | "nbformat_minor": 5
293 | }
294 |
--------------------------------------------------------------------------------
/24.3/tutorial/Model Deployment.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "ce429bd4-5bcc-47f6-9a7a-19b039cc87c1",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Deployment Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Deployment\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "3f34332a-2546-4d1f-86a5-cd263dd98f0d",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "3d9a66a7-e62d-459d-ab53-579644517548",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "ccd2d28a-abbc-4b5c-abf4-d9d6337bc28e",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "cd4f068f-60c6-436b-99b5-55575ecdbcb6",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "202bb8e0-4466-4383-b98e-ac735655a0af",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Deployment phase and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "3e19c58a-c203-4c84-8e1d-cd5ecbfa2d35",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") # Paste your Model Deployment phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "c9d27a6f-19e4-4f25-a50e-73e8fe0cc9d7",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "ef0de711-6ae8-484c-9831-f73d404f3e59",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "1ccf931b-9676-4f1b-868c-79c7f15eb0bf",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve A Previously Created Model\n",
114 | "We assume the model you stage in the previous Staging phase was approuved for deployment. For simplicity reasons, we will just fetch this model from Vectice retrieve its properties and add a fake endpoint "
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "81554fb3-316c-47ee-b04c-83c3f433285f",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "vect_model = connect.browse(\"MDV-xxxx\") #Pass your model ID Ridge Staging created on the Staging phase"
125 | ]
126 | },
127 | {
128 | "attachments": {},
129 | "cell_type": "markdown",
130 | "id": "38b747d7-e400-48a3-95ca-ceb61fb0d85c",
131 | "metadata": {},
132 | "source": [
133 | "## Log a Model\n",
134 | "Use the following code block to create a local Model"
135 | ]
136 | },
137 | {
138 | "cell_type": "code",
139 | "execution_count": null,
140 | "id": "0f73bd6f-b828-4603-ad8f-05cdb68f888b",
141 | "metadata": {},
142 | "outputs": [],
143 | "source": [
144 | "iteration.log(vect_model, section = \"deploy model\")"
145 | ]
146 | },
147 | {
148 | "attachments": {},
149 | "cell_type": "markdown",
150 | "id": "8ae90c1d-b385-422f-975e-9d7af6cadd0e",
151 | "metadata": {},
152 | "source": [
153 | "## Add a note\n",
154 | "Log the information for the deployment endpoint and model packaging as a note."
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": null,
160 | "id": "c7f7b1ec-19b2-4799-99f6-a4088e3fbc8c",
161 | "metadata": {},
162 | "outputs": [],
163 | "source": [
164 | "details = \"\"\"{\n",
165 | " \"Container image\": \"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest\",\n",
166 | " \"Model artifact location\": \"gs://dataproc-staging-us-west2-599225543291-rt9b6nzx/models/\",\n",
167 | " \"Prediction endpoint\": \"https://retail_prediction_service.com/predict\"\n",
168 | " }\"\"\"\n",
169 | "iteration.log(details, section = \"deploy model\")"
170 | ]
171 | },
172 | {
173 | "cell_type": "code",
174 | "execution_count": null,
175 | "id": "66ccf63e",
176 | "metadata": {},
177 | "outputs": [],
178 | "source": [
179 | "iteration.complete()"
180 | ]
181 | },
182 | {
183 | "attachments": {},
184 | "cell_type": "markdown",
185 | "id": "64ccc91e",
186 | "metadata": {},
187 | "source": [
188 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Deployment phase of the Tutorial Project.
\n",
189 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
190 | ]
191 | }
192 | ],
193 | "metadata": {
194 | "kernelspec": {
195 | "display_name": "Python 3",
196 | "language": "python",
197 | "name": "python3"
198 | },
199 | "language_info": {
200 | "codemirror_mode": {
201 | "name": "ipython",
202 | "version": 3
203 | },
204 | "file_extension": ".py",
205 | "mimetype": "text/x-python",
206 | "name": "python",
207 | "nbconvert_exporter": "python",
208 | "pygments_lexer": "ipython3",
209 | "version": "3.9.6"
210 | }
211 | },
212 | "nbformat": 4,
213 | "nbformat_minor": 5
214 | }
215 |
--------------------------------------------------------------------------------
/24.3/tutorial/Model Staging.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "43ca7ce4-3223-401e-a4af-cc7603f196a0",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Staging Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Staging\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "156659ab-68d8-42bf-a296-b81419b77f59",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "13672b5c-e784-4c7c-a47b-1215a47a593a",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "00d29059-b8b9-422e-bc6f-5c66fce6596c",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "1645ed95-ef27-444a-b991-b35b7c9cad88",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "be757d4c-5049-43f6-b932-84b49c7038a0",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Staging and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "cfc1ff71-4a3b-4a70-adcd-7bbf690c5134",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Model Staging Phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "361081b0-0995-4c05-924f-8feaab8fdde1",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "94afc70e-37c1-475d-bc62-1bb8bdb887cd",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "8667308a-bf28-4b8d-8553-9d05a8158e03",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve previously created Datasets\n",
114 | "You can retrieve a variety of Vectice Objects with the browse('VECTICE-ID') method. Namely, Phases, Iterations, Datasets, Models..."
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "d934877d-cbba-4bc2-93d5-d723fa37b654",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "origin_ds = connect.browse(\"DTV-xxxx\") #Paste your Origin Dataset ID (i.e ProductSales Origin) created on Data Understanding phase\n",
125 | "cleaned_ds = connect.browse(\"DTV-xxxx\") #Paste your Cleaned Dataset ID (i.e ProductSales Cleaned) created on Data Preparation phase\n",
126 | "modeling_dataset = connect.browse(\"DTV-xxxx\") #Paste your Model Dataset ID (i.e ProductSales Modeling) created on Data Modeling phase"
127 | ]
128 | },
129 | {
130 | "attachments": {},
131 | "cell_type": "markdown",
132 | "id": "5562fc69-f3fd-41f2-a09b-21c0322f4a6a",
133 | "metadata": {},
134 | "source": [
135 | "## Log a Staging Model\n",
136 | "\n",
137 | "Imaging you created this model through an automated training pipeline and you log it at the end of the process.
For the purpose of the tutorial we will simply create an empty model."
138 | ]
139 | },
140 | {
141 | "cell_type": "code",
142 | "execution_count": null,
143 | "id": "94d501da-41e2-46f6-890c-21a36e188b42",
144 | "metadata": {},
145 | "outputs": [],
146 | "source": [
147 | "vect_model = vectice.Model(name=\"scikit-learn Ridge Regression Stage model\",library=\"scikit-learn\", technique=\"Ridge Regression\", metrics={\"mae_test\": 63.02}, properties={\"quarter\": \"Q1\"}, derived_from=modeling_dataset)"
148 | ]
149 | },
150 | {
151 | "cell_type": "code",
152 | "execution_count": null,
153 | "id": "dc49e9c6-93f6-473a-84ff-13e5f72052bb",
154 | "metadata": {},
155 | "outputs": [],
156 | "source": [
157 | "iteration.log(origin_ds, section = \"ingest data\")"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "id": "703aa51a-8476-4356-9326-58e0582e7b3c",
164 | "metadata": {},
165 | "outputs": [],
166 | "source": [
167 | "iteration.log(cleaned_ds, section = \"preprocess data\")"
168 | ]
169 | },
170 | {
171 | "cell_type": "code",
172 | "execution_count": null,
173 | "id": "145e04ed-09e3-4d33-bff5-c8ab51425594",
174 | "metadata": {},
175 | "outputs": [],
176 | "source": [
177 | "iteration.log(vect_model, section = \"train model\")"
178 | ]
179 | },
180 | {
181 | "attachments": {},
182 | "cell_type": "markdown",
183 | "id": "42e6cd6b-f39e-4b2d-a69f-22e9a5ab7bbd",
184 | "metadata": {},
185 | "source": [
186 | "## Add a note\n",
187 | "Use the following code block to save key performance metrics as a note that will be use for approving deployment to production"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": null,
193 | "id": "e33d20d7-e6ca-49bf-b4e5-fbe72795edfd",
194 | "metadata": {},
195 | "outputs": [],
196 | "source": [
197 | "iteration.log(\"\"\"Evaluation:\\nMAE vs Threshold: 63.02 vs 98 from Baseline \\nModel passed acceptance critera.\"\"\", section = \"evaluate model\")"
198 | ]
199 | },
200 | {
201 | "cell_type": "code",
202 | "execution_count": null,
203 | "id": "e2b804da",
204 | "metadata": {},
205 | "outputs": [],
206 | "source": [
207 | "iteration.complete()\n"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "e091dc76",
214 | "metadata": {},
215 | "source": [
216 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Staging phase of the Tutorial Project.
\n",
217 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
218 | ]
219 | }
220 | ],
221 | "metadata": {
222 | "kernelspec": {
223 | "display_name": "Python 3",
224 | "language": "python",
225 | "name": "python3"
226 | },
227 | "language_info": {
228 | "codemirror_mode": {
229 | "name": "ipython",
230 | "version": 3
231 | },
232 | "file_extension": ".py",
233 | "mimetype": "text/x-python",
234 | "name": "python",
235 | "nbconvert_exporter": "python",
236 | "pygments_lexer": "ipython3",
237 | "version": "3.9.6"
238 | }
239 | },
240 | "nbformat": 4,
241 | "nbformat_minor": 5
242 | }
243 |
--------------------------------------------------------------------------------
/24.3/tutorial/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/QuickStart Autolog.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "
\n",
9 | ""
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {
15 | "id": "7LArs6J5fyIz"
16 | },
17 | "source": [
18 | "## What to expect\n",
19 | "\n",
20 | "In this notebook, we will re-use the classical Iris modeling example to demonstrate how you can automatically document in Vectice your assets, such as datasets, models, graphs, and notes, using a few lines of code."
21 | ]
22 | },
23 | {
24 | "cell_type": "markdown",
25 | "metadata": {
26 | "id": "iUp4X8V5tqhv"
27 | },
28 | "source": [
29 | "### Important Resources\n",
30 | "* Vectice autolog documentation https://api-docs.vectice.com/reference/vectice/autolog/\n"
31 | ]
32 | },
33 | {
34 | "cell_type": "markdown",
35 | "metadata": {
36 | "id": "jER4KBN0JbSw"
37 | },
38 | "source": [
39 | "\n",
40 | "Automated code lineage: The code lineage functionalities are not covered as part of this QuickStart as they require first setting up a Git repository.\n",
41 | "
\n",
42 | "\n",
43 | "\n",
44 | "\n",
45 | "---\n",
46 | "\n"
47 | ]
48 | },
49 | {
50 | "cell_type": "markdown",
51 | "metadata": {
52 | "id": "BWxVwtAdgSbj"
53 | },
54 | "source": [
55 | "## Install the latest Vectice Python client library"
56 | ]
57 | },
58 | {
59 | "cell_type": "code",
60 | "execution_count": null,
61 | "metadata": {
62 | "id": "bin0M8rKdfBU"
63 | },
64 | "outputs": [],
65 | "source": [
66 | "%pip install -q seaborn\n",
67 | "%pip install -q scikit-learn\n",
68 | "%pip install -q vectice -U"
69 | ]
70 | },
71 | {
72 | "cell_type": "markdown",
73 | "metadata": {
74 | "id": "1bwpySvqf5Ce"
75 | },
76 | "source": [
77 | "## Get started configuring the Vectice autolog"
78 | ]
79 | },
80 | {
81 | "cell_type": "markdown",
82 | "metadata": {
83 | "id": "jx5xlQFJxxQZ"
84 | },
85 | "source": [
86 | "**To begin using Vectice autolog, you’ll first need to configure it with the appropriate credentials. This requires an API Key and a Phase ID from your Quickstart project to determine where your work will be documented.**\n",
87 | "\n",
88 | "Before running the notebook: \n",
89 | "\n",
90 | "- Navigate to the Quickstart project.\n",
91 | "\n",
92 | "- Locate the Phase Step 1 – Autolog your assets metadata in the project.\n",
93 | "\n",
94 | "- Copy the provided API Key code snippet from that section.\n",
95 | "\n",
96 | "Next:\n",
97 | "\n",
98 | "- Paste the code snippet below to update the configuration and establish a connection to the Quickstart project in Vectice."
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": null,
104 | "metadata": {
105 | "id": "frnhI_W9aOoZ"
106 | },
107 | "outputs": [],
108 | "source": [
109 | "import vectice\n",
110 | "from vectice import autolog\n",
111 | "\n",
112 | "autolog.config(api_token=\"your-api-key\", #Paste your API key\n",
113 | " host = 'your-host-info', #Paste your host information\n",
114 | " phase = 'your-phase-id', #Paste your Phase Id\n",
115 | " prefix = \"QS\")\n"
116 | ]
117 | },
118 | {
119 | "cell_type": "markdown",
120 | "metadata": {},
121 | "source": [
122 | "\n",
123 | " Important information:\n",
124 | "
Vectice Autolog is continuously evolving and we are actively enhancing supported libraries, environments, and functionalities to provide an improved user experience. \n",
125 | " Be sure to configure autolog at the beginning of your notebook. A late setup may require rerunning previous cells.\n",
126 | "
\n",
127 | "\n",
128 | "For detailed information, supported libraries and environments, please consult our [Autolog documentation](https://api-docs.vectice.com/reference/vectice/autolog/).\n",
129 | ""
130 | ]
131 | },
132 | {
133 | "cell_type": "markdown",
134 | "metadata": {
135 | "id": "FYeCGcgLlsOL"
136 | },
137 | "source": [
138 | "# Auto-Document your work in Vectice\n",
139 | "We will prepare an example dataset based on the well-known iris dataset. We will then train a linear regression model using scikit-learn.\n",
140 | "After we complete this work and create those assets, we will log them to Vectice in a single line of code.\n",
141 | "This enables you to document your work as you go, and to never forget the data that was used, the models, the code and other artifacts."
142 | ]
143 | },
144 | {
145 | "cell_type": "markdown",
146 | "metadata": {
147 | "id": "6VvbrEsKl5bH"
148 | },
149 | "source": [
150 | "Use the following code block to create a dataset, generate a graph and build a model:"
151 | ]
152 | },
153 | {
154 | "cell_type": "code",
155 | "execution_count": 2,
156 | "metadata": {
157 | "id": "jMC05CI6epHw"
158 | },
159 | "outputs": [],
160 | "source": [
161 | "import pandas as pd\n",
162 | "from sklearn import datasets\n",
163 | "\n",
164 | "iris = datasets.load_iris()\n",
165 | "\n",
166 | "df_iris = pd.DataFrame(data=iris.data, columns=iris.feature_names)\n",
167 | "df_iris['species'] = iris.target_names[iris.target]\n"
168 | ]
169 | },
170 | {
171 | "cell_type": "code",
172 | "execution_count": null,
173 | "metadata": {
174 | "id": "OMaIknlOtqh3"
175 | },
176 | "outputs": [],
177 | "source": [
178 | "import seaborn as sns\n",
179 | "import matplotlib.pyplot as plt\n",
180 | "\n",
181 | "sns.scatterplot(data=df_iris, x='sepal length (cm)',\n",
182 | " y='petal width (cm)', hue='species')\n",
183 | "plt.plot()\n",
184 | "\n",
185 | "#Save your graph to local file to be automatically captured by Vectice \n",
186 | "plt.savefig('Scatter_plot_iris.png') "
187 | ]
188 | },
189 | {
190 | "cell_type": "markdown",
191 | "metadata": {},
192 | "source": [
193 | "**Note**: Save graphs you want to log into a local file to be automatically captured by the autolog.
"
194 | ]
195 | },
196 | {
197 | "cell_type": "code",
198 | "execution_count": 4,
199 | "metadata": {
200 | "id": "N0wsppAltqh5"
201 | },
202 | "outputs": [],
203 | "source": [
204 | "from sklearn.neighbors import KNeighborsClassifier\n",
205 | "from sklearn.model_selection import train_test_split\n",
206 | "from sklearn.metrics import accuracy_score\n",
207 | "\n",
208 | "train_df, test_df = train_test_split(df_iris, test_size=0.2, random_state=42)\n",
209 | "\n",
210 | "knn = KNeighborsClassifier()\n",
211 | "knn.fit(train_df[iris.feature_names],train_df[\"species\"])\n",
212 | "\n",
213 | "# Make predictions on the test set\n",
214 | "y_pred_test = knn.predict(test_df[iris.feature_names])\n",
215 | "y_pred_train = knn.predict(train_df[iris.feature_names])\n",
216 | "\n",
217 | "# Calculate the accuracy score\n",
218 | "accuracy_test= accuracy_score(test_df[\"species\"], y_pred_test)\n",
219 | "accuracy_train = accuracy_score(train_df[\"species\"], y_pred_train)"
220 | ]
221 | },
222 | {
223 | "cell_type": "markdown",
224 | "metadata": {},
225 | "source": [
226 | "**Note**: To link models and metrics using Vectice autolog, ensure each model and its metrics are in the same notebook cell (scikit metrics are currently supported)."
227 | ]
228 | },
229 | {
230 | "cell_type": "markdown",
231 | "metadata": {},
232 | "source": [
233 | "## Autolog your entire notebook's assets"
234 | ]
235 | },
236 | {
237 | "cell_type": "code",
238 | "execution_count": null,
239 | "metadata": {
240 | "id": "g5FOnLfHnY14"
241 | },
242 | "outputs": [],
243 | "source": [
244 | "autolog.notebook(note=\"My first iteration to Vectice to document iris dataset\", capture_schema_only=False) #You can add a note to comment what you just logged into Vectice"
245 | ]
246 | },
247 | {
248 | "cell_type": "markdown",
249 | "metadata": {},
250 | "source": [
251 | "#### You've logged your assets to Vectice with one line of code. Click the iteration link above to view them.\n",
252 | "**Note**: Autolog also allows you to log only the content of one cell, please check out our [documentation](https://api-docs.vectice.com/reference/vectice/autolog/) to learn more about the autolog functions and capabilities.
"
253 | ]
254 | },
255 | {
256 | "cell_type": "markdown",
257 | "metadata": {
258 | "id": "YnmFUplTpMoW"
259 | },
260 | "source": [
261 | "## 🥇 You have now learned how to successfully log all your metadata with one line of code. Log in to the Vectice app to continue documenting your work."
262 | ]
263 | }
264 | ],
265 | "metadata": {
266 | "colab": {
267 | "provenance": []
268 | },
269 | "kernelspec": {
270 | "display_name": ".venv",
271 | "language": "python",
272 | "name": "python3"
273 | },
274 | "language_info": {
275 | "codemirror_mode": {
276 | "name": "ipython",
277 | "version": 3
278 | },
279 | "file_extension": ".py",
280 | "mimetype": "text/x-python",
281 | "name": "python",
282 | "nbconvert_exporter": "python",
283 | "pygments_lexer": "ipython3",
284 | "version": "3.9.6"
285 | }
286 | },
287 | "nbformat": 4,
288 | "nbformat_minor": 0
289 | }
290 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vectice Getting started
2 | In this repository, you will find Vectice Quickstart and Tutorial projects, code and dataset samples to help you get started with Vectice.
3 |
4 | ## Quickstart: what to expect
5 | The Quickstart notebook in this repo will guide you through using the Vectice API to
6 |
7 | - Connect to Vectice
8 | - Capture key artifacts inside iterations
9 | - Auto-document notes and assets
10 |
11 | To get the most out of the Quickstart, use the notebook alongside the Quickstart project documentation in docs.vectice.com and the Quickstart project available in your personal workspace in the Vectice app.
12 |
13 | ## Tutorial: What to expect
14 | The tutorial notebook in this repo was used to log assets to the Tutorial project in Vectice. Browse this notebook to understand the assets that were captured in Vectice and that will be auto-documented in the App.
15 |
16 | For advanced technical insights and integration details, explore the [Vectice API reference documentation](https://api-docs.vectice.com/).
17 |
--------------------------------------------------------------------------------
/Tutorial data/MAE by month.csv:
--------------------------------------------------------------------------------
1 | Month,MAE
2 | Jan,64.2303049706522
3 | Feb,63.15788274148976
4 | Mar,65.0978690830475
--------------------------------------------------------------------------------
/Tutorial data/Predictions and Actuals.csv:
--------------------------------------------------------------------------------
1 | Months,Predictions,Actuals
2 | Jan-2022,135.7034065457863,140.75
3 | Feb-2022,233.25046984200952,36.744
4 | Mar-2022,236.54706893317592,237.096
--------------------------------------------------------------------------------
/Tutorial data/README.md:
--------------------------------------------------------------------------------
1 | # Vectice Getting started
2 |
3 | In this repository, you will find Vectice data necessary for the tutorial project.
--------------------------------------------------------------------------------
/tutorial/Data Preparation.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "c55e848f-4238-4272-bfa7-4d994617e58c",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Data Preparation Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Data Preparation\" phase of the **\"Tutorial: Forecast in store-unit sales** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": null,
30 | "id": "3ba6582a-2c82-4dee-a4d7-9ea20aa225f8",
31 | "metadata": {},
32 | "outputs": [],
33 | "source": [
34 | "import warnings\n",
35 | "warnings.filterwarnings(\"ignore\", category=DeprecationWarning)"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": null,
41 | "id": "356e8192-1a31-4853-a965-f6781a8e1d5e",
42 | "metadata": {},
43 | "outputs": [],
44 | "source": [
45 | "import pandas as pd\n",
46 | "import numpy as np\n",
47 | "import seaborn as sns\n",
48 | "import matplotlib.pyplot as plt"
49 | ]
50 | },
51 | {
52 | "attachments": {},
53 | "cell_type": "markdown",
54 | "id": "8ed8d365-4ae0-4e70-945a-8fc83ce94cc1",
55 | "metadata": {},
56 | "source": [
57 | "## Install the latest Vectice Python client library"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": null,
63 | "id": "de5b3da3-35d7-4d18-a121-9079c090a067",
64 | "metadata": {},
65 | "outputs": [],
66 | "source": [
67 | "%pip install --q vectice -U"
68 | ]
69 | },
70 | {
71 | "attachments": {},
72 | "cell_type": "markdown",
73 | "id": "bab305a9-312d-414d-b6bd-322f496db5d5",
74 | "metadata": {},
75 | "source": [
76 | "## Get started by connecting to Vectice"
77 | ]
78 | },
79 | {
80 | "cell_type": "code",
81 | "execution_count": null,
82 | "id": "43e7d571-0cbe-4c83-ad39-8788a6702fb7",
83 | "metadata": {},
84 | "outputs": [],
85 | "source": [
86 | "import vectice\n",
87 | "\n",
88 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
89 | ]
90 | },
91 | {
92 | "attachments": {},
93 | "cell_type": "markdown",
94 | "id": "897a6883-86b7-4c79-a1af-d5a9f50ed2f2",
95 | "metadata": {},
96 | "source": [
97 | "## Specify which project phase you want to document\n",
98 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Data Preparation phase and copy paste your Phase Id below."
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": null,
104 | "id": "d5bb04d4-b19c-41d0-bfc0-757c0e9e2513",
105 | "metadata": {},
106 | "outputs": [],
107 | "source": [
108 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Data Preparation Phase ID"
109 | ]
110 | },
111 | {
112 | "attachments": {},
113 | "cell_type": "markdown",
114 | "id": "00c94b0d-aaf1-4bdf-ae07-336c92edc14e",
115 | "metadata": {},
116 | "source": [
117 | "## Next we are going to create an iteration\n",
118 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
119 | ]
120 | },
121 | {
122 | "cell_type": "code",
123 | "execution_count": null,
124 | "id": "bc134b8f-92c2-4c46-95b5-0c0264d5b4b1",
125 | "metadata": {},
126 | "outputs": [],
127 | "source": [
128 | "iteration = phase.create_or_get_current_iteration()"
129 | ]
130 | },
131 | {
132 | "cell_type": "code",
133 | "execution_count": null,
134 | "id": "53ff21f4-388c-47a1-9249-82d055eac8c7",
135 | "metadata": {},
136 | "outputs": [],
137 | "source": [
138 | "df_initial = pd.read_csv(\"https://raw.githubusercontent.com/vectice/GettingStarted/main/Tutorial%20data/SampleSuperstore.csv\", converters = {'Postal Code': str})\n",
139 | "df_initial.to_csv(\"SampleSuperstore.csv\", index=False)"
140 | ]
141 | },
142 | {
143 | "attachments": {},
144 | "cell_type": "markdown",
145 | "id": "045a8aec-9741-407b-99dd-a4214d1d9c2b",
146 | "metadata": {},
147 | "source": [
148 | "## Log your origin dataset"
149 | ]
150 | },
151 | {
152 | "cell_type": "code",
153 | "execution_count": null,
154 | "id": "0aed4dfd-8366-40a2-8768-6541eb3208b0",
155 | "metadata": {},
156 | "outputs": [],
157 | "source": [
158 | "origin_ds = vectice.FileResource(paths=\"SampleSuperstore.csv\", dataframes=df_initial)\n",
159 | "\n",
160 | "\n",
161 | "origin_dataset = vectice.Dataset.origin(\n",
162 | " name=\"ProductSales Origin\",\n",
163 | " resource=origin_ds, \n",
164 | ")"
165 | ]
166 | },
167 | {
168 | "cell_type": "code",
169 | "execution_count": null,
170 | "id": "fbe2af6f-0188-416b-9639-069391503af0",
171 | "metadata": {},
172 | "outputs": [],
173 | "source": [
174 | "iteration.log(origin_dataset, section = \"select data\")"
175 | ]
176 | },
177 | {
178 | "attachments": {},
179 | "cell_type": "markdown",
180 | "id": "36232ae3",
181 | "metadata": {},
182 | "source": [
183 | "## Apply transformation to your origin dataset "
184 | ]
185 | },
186 | {
187 | "cell_type": "code",
188 | "execution_count": null,
189 | "id": "35d87dde-7a7b-4d44-ad97-d925f4c54ed5",
190 | "metadata": {},
191 | "outputs": [],
192 | "source": [
193 | "def wrangle(df): \n",
194 | " # Reducing Cardinality\n",
195 | " # Get the top 10 cities by value count \n",
196 | " top_ten_cities=df[\"City\"].value_counts().head(10).index\n",
197 | " # Filter the cities by top 10 cities\n",
198 | " df[\"City\"]=df[\"City\"].apply(lambda c: c if c in top_ten_cities else \"others\")\n",
199 | " # Get the top 10 states by value count\n",
200 | " top_ten_states=df[\"State\"].value_counts().head(10).index\n",
201 | " # Filter the states by top 10 states\n",
202 | " df[\"State\"]=df[\"State\"].apply(lambda c: c if c in top_ten_states else \"others\")\n",
203 | " \n",
204 | " # Dealing with Outliers\n",
205 | " # Get the 10% and 90% quantiles for profit distribution\n",
206 | " q1,q2 =df[\"Profit\"].quantile([0.1,0.9])\n",
207 | " # Filter the profit between the quantiles\n",
208 | " df=df[df[\"Profit\"].between(q1,q2)]\n",
209 | "\n",
210 | " return df"
211 | ]
212 | },
213 | {
214 | "cell_type": "code",
215 | "execution_count": null,
216 | "id": "9ef46fcf-1ab0-4e1c-b7a1-8acabc599926",
217 | "metadata": {},
218 | "outputs": [],
219 | "source": [
220 | "df_cleaned = wrangle(df_initial)\n",
221 | "df_cleaned.describe()"
222 | ]
223 | },
224 | {
225 | "cell_type": "code",
226 | "execution_count": null,
227 | "id": "668a3d7a-44ed-4596-ba8a-72d3e37320a6",
228 | "metadata": {},
229 | "outputs": [],
230 | "source": [
231 | "#Checking for outliers\n",
232 | "sns.displot(df_cleaned[\"Profit\"]);\n",
233 | "plt.savefig(\"Profit.png\")"
234 | ]
235 | },
236 | {
237 | "cell_type": "code",
238 | "execution_count": null,
239 | "id": "8eb10e84-38ee-454c-b3c4-c0ab32068bd2",
240 | "metadata": {},
241 | "outputs": [],
242 | "source": [
243 | "#Checking for outliers\n",
244 | "sns.displot(df_cleaned[\"Quantity\"])\n",
245 | "plt.savefig(\"Quantity.png\")"
246 | ]
247 | },
248 | {
249 | "cell_type": "code",
250 | "execution_count": null,
251 | "id": "f5710bd5-79c0-4c21-9a31-7a5b8f96d4a3",
252 | "metadata": {},
253 | "outputs": [],
254 | "source": [
255 | "df_cleaned.to_csv(\"ProductSales Cleaned.csv\", index=False)"
256 | ]
257 | },
258 | {
259 | "attachments": {},
260 | "cell_type": "markdown",
261 | "id": "b698099a",
262 | "metadata": {},
263 | "source": [
264 | "## Log your clean Dataset, add graphs attachments"
265 | ]
266 | },
267 | {
268 | "cell_type": "code",
269 | "execution_count": null,
270 | "id": "caa53736-2ba8-419d-9e57-ba759b83282a",
271 | "metadata": {},
272 | "outputs": [],
273 | "source": [
274 | "prepared_ds = vectice.FileResource(paths=\"ProductSales Cleaned.csv\", dataframes=df_cleaned)\n",
275 | "\n",
276 | "\n",
277 | "prepared_ds = vectice.Dataset.clean(\n",
278 | " name=\"ProductSales Cleaned\",\n",
279 | " resource=prepared_ds,\n",
280 | " derived_from=origin_dataset, #Origin Dataset for documenting the lineage\n",
281 | " attachments=[\"Profit.png\", \"Quantity.png\"] #Graphs attachments\n",
282 | ")"
283 | ]
284 | },
285 | {
286 | "attachments": {},
287 | "cell_type": "markdown",
288 | "id": "422501e6",
289 | "metadata": {},
290 | "source": [
291 | "### Log your \"ProductSales Cleaned\" dataset in your iteration in the section \"Clean data\""
292 | ]
293 | },
294 | {
295 | "cell_type": "code",
296 | "execution_count": null,
297 | "id": "9a546f90-5631-4d1a-b3b4-048d30443394",
298 | "metadata": {},
299 | "outputs": [],
300 | "source": [
301 | "iteration.log(prepared_ds, section = \"clean data\")"
302 | ]
303 | },
304 | {
305 | "cell_type": "code",
306 | "execution_count": null,
307 | "id": "9cf2bb94",
308 | "metadata": {},
309 | "outputs": [],
310 | "source": [
311 | "iteration.complete()"
312 | ]
313 | },
314 | {
315 | "attachments": {},
316 | "cell_type": "markdown",
317 | "id": "72b18d42",
318 | "metadata": {},
319 | "source": [
320 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Data Preparation phase of the Tutorial Project.
\n",
321 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
322 | ]
323 | }
324 | ],
325 | "metadata": {
326 | "kernelspec": {
327 | "display_name": "Python 3",
328 | "language": "python",
329 | "name": "python3"
330 | },
331 | "language_info": {
332 | "codemirror_mode": {
333 | "name": "ipython",
334 | "version": 3
335 | },
336 | "file_extension": ".py",
337 | "mimetype": "text/x-python",
338 | "name": "python",
339 | "nbconvert_exporter": "python",
340 | "pygments_lexer": "ipython3",
341 | "version": "3.9.6"
342 | }
343 | },
344 | "nbformat": 4,
345 | "nbformat_minor": 5
346 | }
347 |
--------------------------------------------------------------------------------
/tutorial/Data Understanding.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "eabedfd0-bda4-4a9f-9ef2-6514a91dbb98",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Data Understanding Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Data Understanding\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": null,
30 | "id": "6e6350fb-5aec-448e-9e86-4715055033ee",
31 | "metadata": {},
32 | "outputs": [],
33 | "source": [
34 | "import warnings\n",
35 | "warnings.filterwarnings(\"ignore\", category=DeprecationWarning)"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": null,
41 | "id": "dc1525e3-eb5c-4e5b-855f-47dc2229afbf",
42 | "metadata": {},
43 | "outputs": [],
44 | "source": [
45 | "import pandas as pd\n",
46 | "import numpy as np\n",
47 | "import seaborn as sns\n",
48 | "import matplotlib.pyplot as plt"
49 | ]
50 | },
51 | {
52 | "attachments": {},
53 | "cell_type": "markdown",
54 | "id": "6da9fd84-09a0-4d30-bc00-c91dea5cd98f",
55 | "metadata": {},
56 | "source": [
57 | "## Install the latest Vectice Python client library"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": null,
63 | "id": "43c38240-69a2-41fb-bda7-46b7c40b963f",
64 | "metadata": {},
65 | "outputs": [],
66 | "source": [
67 | "%pip install --q vectice -U"
68 | ]
69 | },
70 | {
71 | "attachments": {},
72 | "cell_type": "markdown",
73 | "id": "10195b2a-a959-4a7b-a20b-e45c292930ef",
74 | "metadata": {},
75 | "source": [
76 | "## Get started by connecting to Vectice"
77 | ]
78 | },
79 | {
80 | "cell_type": "code",
81 | "execution_count": null,
82 | "id": "d34bced5-491f-400b-ac5d-e4665f6f6ae8",
83 | "metadata": {},
84 | "outputs": [],
85 | "source": [
86 | "import vectice\n",
87 | "\n",
88 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
89 | ]
90 | },
91 | {
92 | "attachments": {},
93 | "cell_type": "markdown",
94 | "id": "90a36ebc-023d-4f18-8382-8d92044492e3",
95 | "metadata": {},
96 | "source": [
97 | "## Specify which project phase you want to document\n",
98 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Data Understanding phase and copy paste your Phase Id below."
99 | ]
100 | },
101 | {
102 | "cell_type": "code",
103 | "execution_count": null,
104 | "id": "9d57e0e9-fc47-4b91-81b0-2f79907c901a",
105 | "metadata": {},
106 | "outputs": [],
107 | "source": [
108 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Data Understanding Phase ID"
109 | ]
110 | },
111 | {
112 | "attachments": {},
113 | "cell_type": "markdown",
114 | "id": "9a7957b4-c5dc-49ff-9612-f58ee9e63146",
115 | "metadata": {},
116 | "source": [
117 | "## Next we are going to create an iteration\n",
118 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
119 | ]
120 | },
121 | {
122 | "cell_type": "code",
123 | "execution_count": null,
124 | "id": "b315169a-d68f-4a17-9b39-56694b8be697",
125 | "metadata": {},
126 | "outputs": [],
127 | "source": [
128 | "iteration = phase.create_or_get_current_iteration()"
129 | ]
130 | },
131 | {
132 | "cell_type": "code",
133 | "execution_count": null,
134 | "id": "6c59effc-5b3f-4b75-aae4-f3d46be1218f",
135 | "metadata": {},
136 | "outputs": [],
137 | "source": [
138 | "df = pd.read_csv(\"https://raw.githubusercontent.com/vectice/GettingStarted/main/Tutorial%20data/SampleSuperstore.csv\", converters = {'Postal Code': str})\n",
139 | "df.to_csv(\"SampleSuperstore.csv\", index=False)"
140 | ]
141 | },
142 | {
143 | "attachments": {},
144 | "cell_type": "markdown",
145 | "id": "ef495b02-b785-41d5-8741-0796c3cf8da2",
146 | "metadata": {},
147 | "source": [
148 | "## Log a dataset\n",
149 | "Use the following code block to create a local dataset and generate a graph:"
150 | ]
151 | },
152 | {
153 | "cell_type": "code",
154 | "execution_count": null,
155 | "id": "4722446c-389d-4543-9280-9558e0a07bb7",
156 | "metadata": {},
157 | "outputs": [],
158 | "source": [
159 | "origin_ds = vectice.FileResource(paths=\"SampleSuperstore.csv\", dataframes=df)\n",
160 | "\n",
161 | "\n",
162 | "origin_dataset = vectice.Dataset.origin(\n",
163 | " name=\"ProductSales Origin\",\n",
164 | " resource=origin_ds, \n",
165 | ")"
166 | ]
167 | },
168 | {
169 | "cell_type": "code",
170 | "execution_count": null,
171 | "id": "53bdadfd-c9d3-4c6e-acb4-930751df7a54",
172 | "metadata": {},
173 | "outputs": [],
174 | "source": [
175 | "iteration.log(origin_dataset, section = \"collect initial data\")"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": null,
181 | "id": "140a4667-ba4c-492b-820b-cfa676dfe184",
182 | "metadata": {},
183 | "outputs": [],
184 | "source": [
185 | "iteration.log(str(df.columns.values), section = \"describe data\")"
186 | ]
187 | },
188 | {
189 | "cell_type": "code",
190 | "execution_count": null,
191 | "id": "473c3d35-7050-4a06-b867-b2861755ee3d",
192 | "metadata": {},
193 | "outputs": [],
194 | "source": [
195 | "## Checking for Multicollinearity\n",
196 | "corr_matrix=df.select_dtypes(\"number\").drop(\"Sales\",axis=1).corr()\n",
197 | "sns.heatmap(corr_matrix);\n",
198 | "plt.savefig(\"corr_matrix.png\")"
199 | ]
200 | },
201 | {
202 | "attachments": {},
203 | "cell_type": "markdown",
204 | "id": "437759e3",
205 | "metadata": {},
206 | "source": [
207 | "## Log graphs"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "45b5eb6d",
214 | "metadata": {},
215 | "source": [
216 | "You can log multiple items to a single iteration by using the `iterarion.log()` method."
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": null,
222 | "id": "e95ed5c6-fb4b-47be-bd7c-00747f8a4f3e",
223 | "metadata": {},
224 | "outputs": [],
225 | "source": [
226 | "iteration.log(\"corr_matrix.png\", section = \"explore data\")"
227 | ]
228 | },
229 | {
230 | "cell_type": "code",
231 | "execution_count": null,
232 | "id": "9e200853-9172-4e9a-a2e0-476beaabcd91",
233 | "metadata": {},
234 | "outputs": [],
235 | "source": [
236 | "#Checking for outliers\n",
237 | "sns.displot(df[\"Quantity\"])\n",
238 | "plt.savefig(\"Quantity.png\")"
239 | ]
240 | },
241 | {
242 | "cell_type": "code",
243 | "execution_count": null,
244 | "id": "07eff006-fef5-476c-859a-c01947c84c4e",
245 | "metadata": {},
246 | "outputs": [],
247 | "source": [
248 | "iteration.log(\"Quantity.png\", section = \"explore data\")"
249 | ]
250 | },
251 | {
252 | "cell_type": "code",
253 | "execution_count": null,
254 | "id": "4ec7ecfc",
255 | "metadata": {},
256 | "outputs": [],
257 | "source": [
258 | "iteration.complete()"
259 | ]
260 | },
261 | {
262 | "attachments": {},
263 | "cell_type": "markdown",
264 | "id": "421b65ad",
265 | "metadata": {},
266 | "source": [
267 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Data Understanding phase of the Tutorial Project.
\n",
268 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
269 | ]
270 | }
271 | ],
272 | "metadata": {
273 | "kernelspec": {
274 | "display_name": "Python 3",
275 | "language": "python",
276 | "name": "python3"
277 | },
278 | "language_info": {
279 | "codemirror_mode": {
280 | "name": "ipython",
281 | "version": 3
282 | },
283 | "file_extension": ".py",
284 | "mimetype": "text/x-python",
285 | "name": "python",
286 | "nbconvert_exporter": "python",
287 | "pygments_lexer": "ipython3",
288 | "version": "3.9.6"
289 | }
290 | },
291 | "nbformat": 4,
292 | "nbformat_minor": 5
293 | }
294 |
--------------------------------------------------------------------------------
/tutorial/Model Deployment.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "ce429bd4-5bcc-47f6-9a7a-19b039cc87c1",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Deployment Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Deployment\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "3f34332a-2546-4d1f-86a5-cd263dd98f0d",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "3d9a66a7-e62d-459d-ab53-579644517548",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "ccd2d28a-abbc-4b5c-abf4-d9d6337bc28e",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "cd4f068f-60c6-436b-99b5-55575ecdbcb6",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "202bb8e0-4466-4383-b98e-ac735655a0af",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Deployment phase and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "3e19c58a-c203-4c84-8e1d-cd5ecbfa2d35",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") # Paste your Model Deployment phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "c9d27a6f-19e4-4f25-a50e-73e8fe0cc9d7",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "ef0de711-6ae8-484c-9831-f73d404f3e59",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "1ccf931b-9676-4f1b-868c-79c7f15eb0bf",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve A Previously Created Model\n",
114 | "We assume the model you stage in the previous Staging phase was approuved for deployment. For simplicity reasons, we will just fetch this model from Vectice retrieve its properties and add a fake endpoint "
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "81554fb3-316c-47ee-b04c-83c3f433285f",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "vect_model = connect.browse(\"MDV-xxxx\") #Pass your model ID Ridge Staging created on the Staging phase"
125 | ]
126 | },
127 | {
128 | "attachments": {},
129 | "cell_type": "markdown",
130 | "id": "38b747d7-e400-48a3-95ca-ceb61fb0d85c",
131 | "metadata": {},
132 | "source": [
133 | "## Log a Model\n",
134 | "Use the following code block to create a local Model"
135 | ]
136 | },
137 | {
138 | "cell_type": "code",
139 | "execution_count": null,
140 | "id": "0f73bd6f-b828-4603-ad8f-05cdb68f888b",
141 | "metadata": {},
142 | "outputs": [],
143 | "source": [
144 | "iteration.log(vect_model, section = \"deploy model\")"
145 | ]
146 | },
147 | {
148 | "attachments": {},
149 | "cell_type": "markdown",
150 | "id": "8ae90c1d-b385-422f-975e-9d7af6cadd0e",
151 | "metadata": {},
152 | "source": [
153 | "## Add a note\n",
154 | "Log the information for the deployment endpoint and model packaging as a note."
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": null,
160 | "id": "c7f7b1ec-19b2-4799-99f6-a4088e3fbc8c",
161 | "metadata": {},
162 | "outputs": [],
163 | "source": [
164 | "details = \"\"\"{\n",
165 | " \"Container image\": \"us-docker.pkg.dev/vertex-ai/prediction/sklearn-cpu.0-24:latest\",\n",
166 | " \"Model artifact location\": \"gs://dataproc-staging-us-west2-599225543291-rt9b6nzx/models/\",\n",
167 | " \"Prediction endpoint\": \"https://retail_prediction_service.com/predict\"\n",
168 | " }\"\"\"\n",
169 | "iteration.log(details, section = \"deploy model\")"
170 | ]
171 | },
172 | {
173 | "cell_type": "code",
174 | "execution_count": null,
175 | "id": "66ccf63e",
176 | "metadata": {},
177 | "outputs": [],
178 | "source": [
179 | "iteration.complete()"
180 | ]
181 | },
182 | {
183 | "attachments": {},
184 | "cell_type": "markdown",
185 | "id": "64ccc91e",
186 | "metadata": {},
187 | "source": [
188 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Deployment phase of the Tutorial Project.
\n",
189 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
190 | ]
191 | }
192 | ],
193 | "metadata": {
194 | "kernelspec": {
195 | "display_name": "Python 3",
196 | "language": "python",
197 | "name": "python3"
198 | },
199 | "language_info": {
200 | "codemirror_mode": {
201 | "name": "ipython",
202 | "version": 3
203 | },
204 | "file_extension": ".py",
205 | "mimetype": "text/x-python",
206 | "name": "python",
207 | "nbconvert_exporter": "python",
208 | "pygments_lexer": "ipython3",
209 | "version": "3.9.6"
210 | }
211 | },
212 | "nbformat": 4,
213 | "nbformat_minor": 5
214 | }
215 |
--------------------------------------------------------------------------------
/tutorial/Model Staging.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "attachments": {},
5 | "cell_type": "markdown",
6 | "id": "43ca7ce4-3223-401e-a4af-cc7603f196a0",
7 | "metadata": {},
8 | "source": [
9 | "# Before you start with this Model Staging Notebook\n",
10 | "\n",
11 | "This notebook is part of the Vectice tutorial project notebook series. It illustrates how to log the assets documented in the \"Model Staging\" phase of the **\"Tutorial: Forecast in store-unit sales\"** project you can find in your personal Vectice workspace.\n",
12 | "\n",
13 | "### Pre-requisites:\n",
14 | "Before using this notebook you will need:\n",
15 | "* An account in Vectice\n",
16 | "* An API key to connect to Vectice through the APIs\n",
17 | "* The Phase Id of the project where you want to log your work\n",
18 | "\n",
19 | "Refer to Vectice Tutorial Guide for more detailed instructions: https://docs.vectice.com/getting-started/tutorial\n",
20 | "\n",
21 | "\n",
22 | "### Other Resources\n",
23 | "* Vectice Documentation: https://docs.vectice.com/ \n",
24 | "* Vectice API documentation: https://api-docs.vectice.com/"
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "id": "156659ab-68d8-42bf-a296-b81419b77f59",
31 | "metadata": {},
32 | "source": [
33 | "## Install the latest Vectice Python client library"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "execution_count": null,
39 | "id": "13672b5c-e784-4c7c-a47b-1215a47a593a",
40 | "metadata": {},
41 | "outputs": [],
42 | "source": [
43 | "%pip install --q vectice -U"
44 | ]
45 | },
46 | {
47 | "attachments": {},
48 | "cell_type": "markdown",
49 | "id": "00d29059-b8b9-422e-bc6f-5c66fce6596c",
50 | "metadata": {},
51 | "source": [
52 | "## Get started by connecting to Vectice"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "id": "1645ed95-ef27-444a-b991-b35b7c9cad88",
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "import vectice\n",
63 | "\n",
64 | "connect = vectice.connect(api_token=\"your-api-key\", host = 'your-host-info') #Paste your API key"
65 | ]
66 | },
67 | {
68 | "attachments": {},
69 | "cell_type": "markdown",
70 | "id": "be757d4c-5049-43f6-b932-84b49c7038a0",
71 | "metadata": {},
72 | "source": [
73 | "## Specify which project phase you want to document\n",
74 | "In Vectice app, navigate to your personal workspace inside your default Tutorial project go to the Model Staging and copy paste your Phase Id below."
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": null,
80 | "id": "cfc1ff71-4a3b-4a70-adcd-7bbf690c5134",
81 | "metadata": {},
82 | "outputs": [],
83 | "source": [
84 | "phase = connect.phase(\"PHA-xxxx\") #Paste your own Model Staging Phase ID"
85 | ]
86 | },
87 | {
88 | "attachments": {},
89 | "cell_type": "markdown",
90 | "id": "361081b0-0995-4c05-924f-8feaab8fdde1",
91 | "metadata": {},
92 | "source": [
93 | "## Next we are going to create an iteration\n",
94 | "An iteration allows you to organize your work in repeatable sequences. You can have multiple iteration within a phase. Iteration can be organized into sections."
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "id": "94afc70e-37c1-475d-bc62-1bb8bdb887cd",
101 | "metadata": {},
102 | "outputs": [],
103 | "source": [
104 | "iteration = phase.create_or_get_current_iteration()"
105 | ]
106 | },
107 | {
108 | "attachments": {},
109 | "cell_type": "markdown",
110 | "id": "8667308a-bf28-4b8d-8553-9d05a8158e03",
111 | "metadata": {},
112 | "source": [
113 | "## Retrieve previously created Datasets\n",
114 | "You can retrieve a variety of Vectice Objects with the browse('VECTICE-ID') method. Namely, Phases, Iterations, Datasets, Models..."
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "id": "d934877d-cbba-4bc2-93d5-d723fa37b654",
121 | "metadata": {},
122 | "outputs": [],
123 | "source": [
124 | "origin_ds = connect.browse(\"DTV-xxxx\") #Paste your Origin Dataset ID (i.e ProductSales Origin) created on Data Understanding phase\n",
125 | "cleaned_ds = connect.browse(\"DTV-xxxx\") #Paste your Cleaned Dataset ID (i.e ProductSales Cleaned) created on Data Preparation phase\n",
126 | "modeling_dataset = connect.browse(\"DTV-xxxx\") #Paste your Model Dataset ID (i.e ProductSales Modeling) created on Data Modeling phase"
127 | ]
128 | },
129 | {
130 | "attachments": {},
131 | "cell_type": "markdown",
132 | "id": "5562fc69-f3fd-41f2-a09b-21c0322f4a6a",
133 | "metadata": {},
134 | "source": [
135 | "## Log a Staging Model\n",
136 | "\n",
137 | "Imaging you created this model through an automated training pipeline and you log it at the end of the process.
For the purpose of the tutorial we will simply create an empty model."
138 | ]
139 | },
140 | {
141 | "cell_type": "code",
142 | "execution_count": null,
143 | "id": "94d501da-41e2-46f6-890c-21a36e188b42",
144 | "metadata": {},
145 | "outputs": [],
146 | "source": [
147 | "vect_model = vectice.Model(name=\"scikit-learn Ridge Regression Stage model\",library=\"scikit-learn\", technique=\"Ridge Regression\", metrics={\"mae_test\": 63.02}, properties={\"quarter\": \"Q1\"}, derived_from=modeling_dataset)"
148 | ]
149 | },
150 | {
151 | "cell_type": "code",
152 | "execution_count": null,
153 | "id": "dc49e9c6-93f6-473a-84ff-13e5f72052bb",
154 | "metadata": {},
155 | "outputs": [],
156 | "source": [
157 | "iteration.log(origin_ds, section = \"ingest data\")"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": null,
163 | "id": "703aa51a-8476-4356-9326-58e0582e7b3c",
164 | "metadata": {},
165 | "outputs": [],
166 | "source": [
167 | "iteration.log(cleaned_ds, section = \"preprocess data\")"
168 | ]
169 | },
170 | {
171 | "cell_type": "code",
172 | "execution_count": null,
173 | "id": "145e04ed-09e3-4d33-bff5-c8ab51425594",
174 | "metadata": {},
175 | "outputs": [],
176 | "source": [
177 | "iteration.log(vect_model, section = \"train model\")"
178 | ]
179 | },
180 | {
181 | "attachments": {},
182 | "cell_type": "markdown",
183 | "id": "42e6cd6b-f39e-4b2d-a69f-22e9a5ab7bbd",
184 | "metadata": {},
185 | "source": [
186 | "## Add a note\n",
187 | "Use the following code block to save key performance metrics as a note that will be use for approving deployment to production"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": null,
193 | "id": "e33d20d7-e6ca-49bf-b4e5-fbe72795edfd",
194 | "metadata": {},
195 | "outputs": [],
196 | "source": [
197 | "iteration.log(\"\"\"Evaluation:\\nMAE vs Threshold: 63.02 vs 98 from Baseline \\nModel passed acceptance critera.\"\"\", section = \"evaluate model\")"
198 | ]
199 | },
200 | {
201 | "cell_type": "code",
202 | "execution_count": null,
203 | "id": "e2b804da",
204 | "metadata": {},
205 | "outputs": [],
206 | "source": [
207 | "iteration.complete()\n"
208 | ]
209 | },
210 | {
211 | "attachments": {},
212 | "cell_type": "markdown",
213 | "id": "e091dc76",
214 | "metadata": {},
215 | "source": [
216 | "## 🥇 Congrats! You learn how to succesfully use Vectice to auto-document the Model Staging phase of the Tutorial Project.
\n",
217 | "### Next we encourage you to explore other notebooks in the tutorial series. You can find those notebooks in Vectice Tutorial Guide: [Want to learn more about the other phases of the tutorial project?](https://docs.vectice.com/getting-started/tutorial#want-to-learn-more-about-the-other-phases-of-the-tutorial-project)"
218 | ]
219 | }
220 | ],
221 | "metadata": {
222 | "kernelspec": {
223 | "display_name": "Python 3",
224 | "language": "python",
225 | "name": "python3"
226 | },
227 | "language_info": {
228 | "codemirror_mode": {
229 | "name": "ipython",
230 | "version": 3
231 | },
232 | "file_extension": ".py",
233 | "mimetype": "text/x-python",
234 | "name": "python",
235 | "nbconvert_exporter": "python",
236 | "pygments_lexer": "ipython3",
237 | "version": "3.9.6"
238 | }
239 | },
240 | "nbformat": 4,
241 | "nbformat_minor": 5
242 | }
243 |
--------------------------------------------------------------------------------
/tutorial/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------