Skip to content

Commit

Permalink
chore: update notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrugman committed Jun 15, 2022
1 parent a553b8a commit f6bdb6e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
55 changes: 33 additions & 22 deletions popmon/notebooks/popmon_tutorial_advanced.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -47,7 +46,8 @@
"import pandas as pd\n",
"\n",
"import popmon\n",
"from popmon import resources"
"from popmon import resources\n",
"from popmon.config import Settings, Report"
]
},
{
Expand Down Expand Up @@ -103,8 +103,11 @@
"metadata": {},
"outputs": [],
"source": [
"settings = Settings()\n",
"settings.report.extended_report = False\n",
"\n",
"df.pm_stability_report(\n",
" time_axis=\"DATE\", time_width=\"1w\", time_offset=\"2015-07-02\", extended_report=False\n",
" time_axis=\"DATE\", time_width=\"1w\", time_offset=\"2015-07-02\", settings=settings\n",
")"
]
},
Expand All @@ -122,12 +125,14 @@
"metadata": {},
"outputs": [],
"source": [
"# reuse the previous settings\n",
"settings.monitoring.pull_rules={\"*_pull\": [10, 7, -7, -10]}\n",
"\n",
"df.pm_stability_report(\n",
" time_axis=\"DATE\",\n",
" time_width=\"1w\",\n",
" time_offset=\"2015-07-02\",\n",
" extended_report=False,\n",
" pull_rules={\"*_pull\": [10, 7, -7, -10]},\n",
" settings=settings,\n",
")"
]
},
Expand Down Expand Up @@ -178,11 +183,14 @@
"\n",
" sdf = spark.createDataFrame(df)\n",
"\n",
" settings = Settings()\n",
" settings.report.extended_report = False\n",
"\n",
" sdf.pm_stability_report(\n",
" time_axis=\"DATE\",\n",
" time_width=\"1w\",\n",
" time_offset=\"2015-07-02\",\n",
" extended_report=False,\n",
" settings=settings,\n",
" )"
]
},
Expand All @@ -204,16 +212,19 @@
"metadata": {},
"outputs": [],
"source": [
"settings = Settings()\n",
"settings.report.extended_report = False\n",
"\n",
"df_ref = pd.read_csv(\n",
" resources.data(\"flight_delays_reference.csv.gz\"), index_col=0, parse_dates=[\"DATE\"]\n",
")\n",
"df.pm_stability_report(\n",
" time_axis=\"DATE\",\n",
" time_width=\"1w\",\n",
" time_offset=\"2015-07-02\",\n",
" extended_report=False,\n",
" reference_type=\"external\",\n",
" reference=df_ref,\n",
" settings=settings,\n",
")"
]
},
Expand All @@ -235,8 +246,8 @@
" time_axis=\"DATE\",\n",
" time_width=\"1w\",\n",
" time_offset=\"2015-07-02\",\n",
" extended_report=False,\n",
" reference_type=\"expanding\",\n",
" settings=settings,\n",
")"
]
},
Expand All @@ -255,13 +266,14 @@
"metadata": {},
"outputs": [],
"source": [
"settings.comparison.window = 5\n",
"\n",
"df.pm_stability_report(\n",
" time_axis=\"DATE\",\n",
" time_width=\"1w\",\n",
" time_offset=\"2015-07-02\",\n",
" extended_report=False,\n",
" reference_type=\"rolling\",\n",
" window=5,\n",
" settings=settings,\n",
")"
]
},
Expand Down Expand Up @@ -400,15 +412,18 @@
"metadata": {},
"outputs": [],
"source": [
"report_settings = Report()\n",
"report_settings.last_n = 0\n",
"report_settings.skip_first_n = 0\n",
"report_settings.skip_last_n = 0\n",
"report_settings.section.histograms.plot_hist_n = 2\n",
"report_settings.skip_empty_plots = True\n",
"report_settings.report_filepath = None\n",
"\n",
"report.regenerate(\n",
" last_n=0,\n",
" skip_first_n=0,\n",
" skip_last_n=0,\n",
" plot_hist_n=2,\n",
" skip_empty_plots=True,\n",
" report_filepath=None,\n",
" store_key=\"html_report\",\n",
" sections_key=\"report_sections\",\n",
" report_settings=settings,\n",
")"
]
},
Expand All @@ -432,11 +447,7 @@
"from popmon.base import Pipeline\n",
"from popmon.visualization import SectionGenerator, ReportGenerator\n",
"\n",
"monitoring_rules = {\n",
" \"*_pull\": [7, 4, -4, -7],\n",
" \"*_zscore\": [7, 4, -4, -7],\n",
" \"[!p]*_unknown_labels\": [0.5, 0.5, 0, 0],\n",
"}\n",
"\n",
"datastore = {\n",
" \"hists\": df.pm_make_histograms(time_axis=\"DATE\", time_width=\"1w\", time_offset=\"2015-07-02\")\n",
"}\n",
Expand Down Expand Up @@ -556,7 +567,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.8.8"
},
"nteract": {
"version": "0.15.0"
Expand Down
10 changes: 7 additions & 3 deletions popmon/notebooks/popmon_tutorial_basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -76,7 +75,8 @@
"source": [
"import pandas as pd\n",
"import popmon\n",
"from popmon import resources"
"from popmon import resources\n",
"from popmon.config import Report"
]
},
{
Expand Down Expand Up @@ -149,7 +149,11 @@
},
"outputs": [],
"source": [
"report.regenerate(extended_report=False, plot_hist_n=3)"
"report_settings = Report()\n",
"report_settings.extended_report = False\n",
"report_settings.section.histograms.plot_hist_n = 6\n",
"\n",
"report.regenerate(report_settings=report_settings)"
]
},
{
Expand Down

0 comments on commit f6bdb6e

Please sign in to comment.