Index
+ + +C
++ | + |
G
++ | + |
I
++ |
M
+
|
+
P
+S
++ | + |
' + + '' + + _("Hide Search Matches") + + "
" + ) + ); + }, + + /** + * helper function to hide the search marks again + */ + hideSearchWords: () => { + document + .querySelectorAll("#searchbox .highlight-link") + .forEach((el) => el.remove()); + document + .querySelectorAll("span.highlighted") + .forEach((el) => el.classList.remove("highlighted")); + localStorage.removeItem("sphinx_highlight_terms") + }, + + initEscapeListener: () => { + // only install a listener if it is really needed + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return; + if (DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS && (event.key === "Escape")) { + SphinxHighlight.hideSearchWords(); + event.preventDefault(); + } + }); + }, +}; + +_ready(() => { + /* Do not call highlightSearchWords() when we are on the search page. + * It will highlight words from the *previous* search query. + */ + if (typeof Search === "undefined") SphinxHighlight.highlightSearchWords(); + SphinxHighlight.initEscapeListener(); +}); diff --git a/docs/build/html/_static/tabs.css b/docs/build/html/_static/tabs.css new file mode 100644 index 0000000000000000000000000000000000000000..957ba60d6989db4103dd1d921ba291879b0544e1 --- /dev/null +++ b/docs/build/html/_static/tabs.css @@ -0,0 +1,89 @@ +.sphinx-tabs { + margin-bottom: 1rem; +} + +[role="tablist"] { + border-bottom: 1px solid #a0b3bf; +} + +.sphinx-tabs-tab { + position: relative; + font-family: Lato,'Helvetica Neue',Arial,Helvetica,sans-serif; + color: #1D5C87; + line-height: 24px; + margin: 0; + font-size: 16px; + font-weight: 400; + background-color: rgba(255, 255, 255, 0); + border-radius: 5px 5px 0 0; + border: 0; + padding: 1rem 1.5rem; + margin-bottom: 0; +} + +.sphinx-tabs-tab[aria-selected="true"] { + font-weight: 700; + border: 1px solid #a0b3bf; + border-bottom: 1px solid white; + margin: -1px; + background-color: white; +} + +.sphinx-tabs-tab:focus { + z-index: 1; + outline-offset: 1px; +} + +.sphinx-tabs-panel { + position: relative; + padding: 1rem; + border: 1px solid #a0b3bf; + margin: 0px -1px -1px -1px; + border-radius: 0 0 5px 5px; + border-top: 0; + background: white; +} + +.sphinx-tabs-panel.code-tab { + padding: 0.4rem; +} + +.sphinx-tab img { + margin-bottom: 24 px; +} + +/* Dark theme preference styling */ + +@media (prefers-color-scheme: dark) { + body[data-theme="auto"] .sphinx-tabs-panel { + color: white; + background-color: rgb(50, 50, 50); + } + + body[data-theme="auto"] .sphinx-tabs-tab { + color: white; + background-color: rgba(255, 255, 255, 0.05); + } + + body[data-theme="auto"] .sphinx-tabs-tab[aria-selected="true"] { + border-bottom: 1px solid rgb(50, 50, 50); + background-color: rgb(50, 50, 50); + } +} + +/* Explicit dark theme styling */ + +body[data-theme="dark"] .sphinx-tabs-panel { + color: white; + background-color: rgb(50, 50, 50); +} + +body[data-theme="dark"] .sphinx-tabs-tab { + color: white; + background-color: rgba(255, 255, 255, 0.05); +} + +body[data-theme="dark"] .sphinx-tabs-tab[aria-selected="true"] { + border-bottom: 2px solid rgb(50, 50, 50); + background-color: rgb(50, 50, 50); +} diff --git a/docs/build/html/_static/tabs.js b/docs/build/html/_static/tabs.js new file mode 100644 index 0000000000000000000000000000000000000000..48dc303c8c0165f4c8735d84bb8e09132d0edb58 --- /dev/null +++ b/docs/build/html/_static/tabs.js @@ -0,0 +1,145 @@ +try { + var session = window.sessionStorage || {}; +} catch (e) { + var session = {}; +} + +window.addEventListener("DOMContentLoaded", () => { + const allTabs = document.querySelectorAll('.sphinx-tabs-tab'); + const tabLists = document.querySelectorAll('[role="tablist"]'); + + allTabs.forEach(tab => { + tab.addEventListener("click", changeTabs); + }); + + tabLists.forEach(tabList => { + tabList.addEventListener("keydown", keyTabs); + }); + + // Restore group tab selection from session + const lastSelected = session.getItem('sphinx-tabs-last-selected'); + if (lastSelected != null) selectNamedTabs(lastSelected); +}); + +/** + * Key focus left and right between sibling elements using arrows + * @param {Node} e the element in focus when key was pressed + */ +function keyTabs(e) { + const tab = e.target; + let nextTab = null; + if (e.keyCode === 39 || e.keyCode === 37) { + tab.setAttribute("tabindex", -1); + // Move right + if (e.keyCode === 39) { + nextTab = tab.nextElementSibling; + if (nextTab === null) { + nextTab = tab.parentNode.firstElementChild; + } + // Move left + } else if (e.keyCode === 37) { + nextTab = tab.previousElementSibling; + if (nextTab === null) { + nextTab = tab.parentNode.lastElementChild; + } + } + } + + if (nextTab !== null) { + nextTab.setAttribute("tabindex", 0); + nextTab.focus(); + } +} + +/** + * Select or deselect clicked tab. If a group tab + * is selected, also select tab in other tabLists. + * @param {Node} e the element that was clicked + */ +function changeTabs(e) { + // Use this instead of the element that was clicked, in case it's a child + const notSelected = this.getAttribute("aria-selected") === "false"; + const positionBefore = this.parentNode.getBoundingClientRect().top; + const notClosable = !this.parentNode.classList.contains("closeable"); + + deselectTabList(this); + + if (notSelected || notClosable) { + selectTab(this); + const name = this.getAttribute("name"); + selectNamedTabs(name, this.id); + + if (this.classList.contains("group-tab")) { + // Persist during session + session.setItem('sphinx-tabs-last-selected', name); + } + } + + const positionAfter = this.parentNode.getBoundingClientRect().top; + const positionDelta = positionAfter - positionBefore; + // Scroll to offset content resizing + window.scrollTo(0, window.scrollY + positionDelta); +} + +/** + * Select tab and show associated panel. + * @param {Node} tab tab to select + */ +function selectTab(tab) { + tab.setAttribute("aria-selected", true); + + // Show the associated panel + document + .getElementById(tab.getAttribute("aria-controls")) + .removeAttribute("hidden"); +} + +/** + * Hide the panels associated with all tabs within the + * tablist containing this tab. + * @param {Node} tab a tab within the tablist to deselect + */ +function deselectTabList(tab) { + const parent = tab.parentNode; + const grandparent = parent.parentNode; + + Array.from(parent.children) + .forEach(t => t.setAttribute("aria-selected", false)); + + Array.from(grandparent.children) + .slice(1) // Skip tablist + .forEach(panel => panel.setAttribute("hidden", true)); +} + +/** + * Select grouped tabs with the same name, but no the tab + * with the given id. + * @param {Node} name name of grouped tab to be selected + * @param {Node} clickedId id of clicked tab + */ +function selectNamedTabs(name, clickedId=null) { + const groupedTabs = document.querySelectorAll(`.sphinx-tabs-tab[name="${name}"]`); + const tabLists = Array.from(groupedTabs).map(tab => tab.parentNode); + + tabLists + .forEach(tabList => { + // Don't want to change the tabList containing the clicked tab + const clickedTab = tabList.querySelector(`[id="${clickedId}"]`); + if (clickedTab === null ) { + // Select first tab with matching name + const tab = tabList.querySelector(`.sphinx-tabs-tab[name="${name}"]`); + deselectTabList(tab); + selectTab(tab); + } + }) +} + +if (typeof exports === 'undefined') { + exports = {}; +} + +exports.keyTabs = keyTabs; +exports.changeTabs = changeTabs; +exports.selectTab = selectTab; +exports.deselectTabList = deselectTabList; +exports.selectNamedTabs = selectNamedTabs; diff --git a/docs/build/html/genindex.html b/docs/build/html/genindex.html new file mode 100644 index 0000000000000000000000000000000000000000..f08e21c4942b0a14f8b0837327598ae56feac67f --- /dev/null +++ b/docs/build/html/genindex.html @@ -0,0 +1,231 @@ + + + + + + ++ | + |
+ | + |
+ |
|
+
+ | + |
A CUSUM-based tool for AI Monitoring
+AIM-CU is a statistical tool for AI monitoring using cumulative sum (AIM-CU). AIM-CU computes:
+The parameter choices for change-point detection based on an acceptable false alarm rate
Detection delay estimates for a given displacement of the performance metric from the target for those parameter choices.
Clone AIM-CU repository.
+git clone https://github.com/DIDSR/AIM-CU.git
+
Run the following commands to install required dependencies (Python = 3.10 is used).
+apt-get -y install python3
+apt-get -y install pip
+cd AIM-CU
+pip install -r requirements.txt
+
Run AIM-CU.
+python3 app.py
+
Open the URL http://0.0.0.0:7860 that is running the AIM-CU locally.
+AIM-CU can also be run through the demo available at https://huggingface.co/spaces/didsr/AIM-CU. If Space is paused, click on Restart button.
+Contents:
+ ++ p | ||
+ |
+ package | + |
+ |
+ package.ARLTheoretical | + |
+ |
+ package.cusum | + |
+ |
+ package.utils | + |
Cumulative Sum (CUSUM)
+@author: smriti.prathapan
+CUSUM class and its functionalities.
+Detects a change in the process.
+pre_change_days (int) – Number of days for in-control phase.
normalized_ref_value (float, optional) – Normalized reference value for detecting a unit standard deviation change in mean of the process. Defaults to 0.5.
normalized_threshold (float, optional) – Normalized threshold. Defaults to 4.
Compute CUSUM for the observations in x
+x (list[float]) – Performance metric to be monitored
mu_0 (float) – In-control mean of the observations/performance metric
k (float) – Reference value related to the magnitude of change that one is interested in detecting
Positive cumulative sum, negative cumulative sum, and CUSUM
+tuple[list[float], list[float], list[float]]
+Initialize with the configuration file.
+Plot CUSUM value using Plotly
+CUSUM plot using Plotly graph object.
+go.Figure
+Plot the input metric using Plotly.
+Scatter plot as Plotly graph object.
+go.Figure
+Plot AI output using Plotly.
+Scatter plot as Plotly graph object.
+go.Figure
+Assign the performance metric data to be used for CUSUM.
+data_csv (DataFrame or TextFileReader) – A comma-separated values (csv) file is returned as two-dimensional data structure with labeled axes.
+Read the provided performance metric data to be used for CUSUM for an example.
+Use initial days to calculate in-control mean and standard deviation.
+init_days (int, optional) – Initial days when observations are considered stable. Defaults to 30.
+Set the timeline of observations.
+data (np.ndarray) – Data of the metric values across the observations.
+Parameter |
+Description |
+
---|---|
μ_in |
+The mean of the performance metric when the process is in-control, i.e., when there is no performance drift |
+
ARL_0 |
+Number of observations before the control chart signals a false detection |
+
σ_in |
+The in-control standard deviation of the metric |
+
ARL_1 |
+Number of observations before the control chart signals a true detection |
+
k |
+The normalized reference value, which is related to the magnitude of change that one is interested in detecting. k = 0.5 is the default choice for detecting a unit standard deviation change |
+
S_hi |
+Cumulative sum of positive changes in the metric |
+
h |
+The normalized threshold or control limit (default =4). This threshold determines when the control chart signals a detection |
+
S_lo |
+Cumulative sum of negative changes in the metric |
+
A two-sided CUSUM control chart computes the cumulative differences or +deviations of individual observations from the target mean (or +in-control mean, \(\mu_{in}\)). The positive and negative cumulative +sums are calculated:
+where d denotes a unit of time, \(x_d\) is the value of quantity +being monitored at time \(d\), \(\hat{\mu}_{in}\) is the +in-control mean of \(x_d\), and \(K\) is a “reference value” +related to the magnitude of change that one is interested in detecting. +\(S_{hi}\) and \(S_{lo}\) are the cumulative sum of positive and +negative changes. To detect a change in the observed values from the +in-control mean, the CUSUM scheme accumulates deviations that are +\(K\) units away from the in-control mean. Let \(\sigma_{in}\) +denote the in-control standard deviation of \(x_d\).
+ARLTheoretical
+@author: smriti.prathapan
+Get the ARL1 along with k values.
+h (float) – Normalized threshold.
shift_in_mean (list[float]) – List of the values of shift in mean.
dict_ARL0_k (OrderedDict) – Data dictionary of ARL0 and k
Table for ARL1 and k values.
+pd.DataFrame
+Calculate ARL_1 with given Shift in Mean (mu1) and k.
+h (float) – Normalized threshold.
k (float) – Normalized reference value.
mu1 (float) – Intended shift in mean.
Detection delay (ARL1).
+float
+provides normalized reference values k for provided list of ARL0, given the value of normalized threshold h.
+h (float) – Normalized threshold.
list_ARL_0 (list) – List of ARL0 values.
Dataframe of ARL0 and k, Data dictionary of ARL0 and k; where k is normalized reference value.
+tuple[pd.Dataframe, OrderedDict]
+Calculation for the reference value for given h and ARL_0.
+h (float) – Normalized threshold.
ARL_0 (float) – ARL0 value.
Normalized reference value k.
+float
+Utilities to handle different operations
+Get the great_table as HTML from Pandas dataframe.
+df (pd.DataFrame) – Dataframe to rendera as a table.
+Table in HTML format.
+gt.GT
+Populate ARLTheoretical.summary_table_df_ARL0_k.
+summary_table_df_ARL0_k (pd.DataFrame) – Dataframe of ARL0 and its respective values of k.
h (float) – Normalized threshold.
Table of ARL0 and k in HTML format.
+gt.GT
+Populate Multiindex table specific for ARLTheoretical.summary_table_df_ARL1_k
+summary_table_df_ARL1_k (pd.DataFrame) – Dataframe with ARL1 and k values.
dict_ARL0_k (OrderedDict) – Data Dictionary with the mapping between ARL0 and k.
h (float) – Normalized threshold.
Table for ARL1 and k in HTML format.
+gt.GT
++ Searching for multiple words only shows matches that contain + all words. +
+ + + + + + + + +