|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "metadata": {}, |
| 5 | + "cell_type": "code", |
| 6 | + "source": [ |
| 7 | + "import pandas as pd\n", |
| 8 | + "import numpy as np" |
| 9 | + ], |
| 10 | + "id": "874e0a0fe3d5bb40", |
| 11 | + "outputs": [], |
| 12 | + "execution_count": null |
| 13 | + }, |
| 14 | + { |
| 15 | + "metadata": {}, |
| 16 | + "cell_type": "code", |
| 17 | + "source": [ |
| 18 | + "from evidently import ColumnType\n", |
| 19 | + "from evidently.future.report import Report\n", |
| 20 | + "from evidently.future.datasets import BinaryClassification, Regression\n", |
| 21 | + "from evidently.future.datasets import ColumnInfo\n", |
| 22 | + "from evidently.future.datasets import DataDefinition\n", |
| 23 | + "from evidently.future.descriptors import TextLength\n", |
| 24 | + "import pandas as pd\n", |
| 25 | + "from evidently.future.datasets import Dataset\n", |
| 26 | + "from evidently.future.presets.classification import ClassificationQuality\n", |
| 27 | + "from evidently.future.tests import lt" |
| 28 | + ], |
| 29 | + "id": "6d19a877eacd9045", |
| 30 | + "outputs": [], |
| 31 | + "execution_count": null |
| 32 | + }, |
| 33 | + { |
| 34 | + "cell_type": "code", |
| 35 | + "id": "initial_id", |
| 36 | + "metadata": { |
| 37 | + "collapsed": true |
| 38 | + }, |
| 39 | + "source": [ |
| 40 | + "from evidently.future.presets import DataSummaryPreset\n", |
| 41 | + "\n", |
| 42 | + "num_rows = 20\n", |
| 43 | + "np.random.seed(42)\n", |
| 44 | + "\n", |
| 45 | + "# Generate numerical data with some missing values\n", |
| 46 | + "num_col1 = np.random.randint(1, 100, num_rows).astype(float)\n", |
| 47 | + "num_col2 = np.random.uniform(10, 500, num_rows)\n", |
| 48 | + "num_col1[5] = np.nan \n", |
| 49 | + "num_col2[12] = np.nan \n", |
| 50 | + "\n", |
| 51 | + "# Generate categorical data with some missing values\n", |
| 52 | + "cat_col1 = np.random.choice(['A', 'B', 'C'], num_rows)\n", |
| 53 | + "cat_col2 = np.random.choice(['X', 'Y', 'Z'], num_rows)\n", |
| 54 | + "cat_col1[3] = np.nan \n", |
| 55 | + "cat_col2[8] = np.nan \n", |
| 56 | + "\n", |
| 57 | + "# Generate text data with some missing values\n", |
| 58 | + "text_col = np.random.choice(['Hello world', 'Test string', 'Sample text', 'Random text'], num_rows)\n", |
| 59 | + "text_col[6] = np.nan \n", |
| 60 | + "\n", |
| 61 | + "# Generate datetime data with some missing values\n", |
| 62 | + "date_col = pd.date_range(start='2025-01-01', periods=num_rows, freq='D')\n", |
| 63 | + "date_col = date_col.to_series().astype(\"object\") # Convert to object to allow NaNs\n", |
| 64 | + "date_col.iloc[10] = np.nan \n", |
| 65 | + "\n", |
| 66 | + "# Create DataFrame\n", |
| 67 | + "df = pd.DataFrame({\n", |
| 68 | + " 'Numerical_1': num_col1,\n", |
| 69 | + " 'Numerical_2': num_col2,\n", |
| 70 | + " 'Categorical_1': cat_col1,\n", |
| 71 | + " 'Categorical_2': cat_col2,\n", |
| 72 | + " 'Text': text_col,\n", |
| 73 | + " 'Datetime': date_col.values, \n", |
| 74 | + " 'Datetime2': date_col.values,\n", |
| 75 | + " 'Datetime3': date_col.values,\n", |
| 76 | + "})\n", |
| 77 | + "\n", |
| 78 | + "report = Report(\n", |
| 79 | + " [\n", |
| 80 | + " DataSummaryPreset(row_count_tests=[lt(1)])\n", |
| 81 | + " ],\n", |
| 82 | + " tags=[\"t2\"],\n", |
| 83 | + ")\n", |
| 84 | + "\n", |
| 85 | + "report.set_model_id(\"m2\")\n", |
| 86 | + "\n", |
| 87 | + "snapshot = report.run(df, None, metadata={\"metadata_item\": \"meta_value\"}, tags=[\"t3\"])" |
| 88 | + ], |
| 89 | + "outputs": [], |
| 90 | + "execution_count": null |
| 91 | + }, |
| 92 | + { |
| 93 | + "metadata": {}, |
| 94 | + "cell_type": "code", |
| 95 | + "source": "snapshot", |
| 96 | + "id": "4f09cb9ac4f36265", |
| 97 | + "outputs": [], |
| 98 | + "execution_count": null |
| 99 | + }, |
| 100 | + { |
| 101 | + "metadata": {}, |
| 102 | + "cell_type": "code", |
| 103 | + "source": [ |
| 104 | + "import uuid\n", |
| 105 | + "from evidently.future.workspace import CloudWorkspace\n", |
| 106 | + "\n", |
| 107 | + "client = CloudWorkspace(token=\"\", url=\"http://localhost:8003\")\n", |
| 108 | + "client.add_run(uuid.UUID(\"01956698-b6d3-7ab0-9add-776f1a77ba78\"), snapshot)" |
| 109 | + ], |
| 110 | + "id": "aa73787e3b5151c7", |
| 111 | + "outputs": [], |
| 112 | + "execution_count": null |
| 113 | + }, |
| 114 | + { |
| 115 | + "metadata": {}, |
| 116 | + "cell_type": "code", |
| 117 | + "source": [ |
| 118 | + "from evidently.ui.workspace import CloudWorkspace\n", |
| 119 | + "import uuid\n", |
| 120 | + "\n", |
| 121 | + "client = CloudWorkspace(token=\"\", url=\"http://localhost:8003\")\n", |
| 122 | + "client.add_run(uuid.UUID(\"0195d6d0-ee9e-7b79-be49-a790c3a0692e\"), snapshot, include_data=True)" |
| 123 | + ], |
| 124 | + "id": "514d62511c317e01", |
| 125 | + "outputs": [], |
| 126 | + "execution_count": null |
| 127 | + }, |
| 128 | + { |
| 129 | + "metadata": {}, |
| 130 | + "cell_type": "code", |
| 131 | + "source": "", |
| 132 | + "id": "2c13c4f2a9ffea3c", |
| 133 | + "outputs": [], |
| 134 | + "execution_count": null |
| 135 | + }, |
| 136 | + { |
| 137 | + "metadata": {}, |
| 138 | + "cell_type": "code", |
| 139 | + "source": "", |
| 140 | + "id": "1a74a64406ca5910", |
| 141 | + "outputs": [], |
| 142 | + "execution_count": null |
| 143 | + } |
| 144 | + ], |
| 145 | + "metadata": { |
| 146 | + "kernelspec": { |
| 147 | + "display_name": "Python 3", |
| 148 | + "language": "python", |
| 149 | + "name": "python3" |
| 150 | + }, |
| 151 | + "language_info": { |
| 152 | + "codemirror_mode": { |
| 153 | + "name": "ipython", |
| 154 | + "version": 2 |
| 155 | + }, |
| 156 | + "file_extension": ".py", |
| 157 | + "mimetype": "text/x-python", |
| 158 | + "name": "python", |
| 159 | + "nbconvert_exporter": "python", |
| 160 | + "pygments_lexer": "ipython2", |
| 161 | + "version": "2.7.6" |
| 162 | + } |
| 163 | + }, |
| 164 | + "nbformat": 4, |
| 165 | + "nbformat_minor": 5 |
| 166 | +} |
0 commit comments