Skip to content

Commit

Permalink
deploy: 54b3bc2
Browse files Browse the repository at this point in the history
  • Loading branch information
rosericazondekon committed Jun 7, 2023
1 parent 92e3d90 commit 28a785b
Show file tree
Hide file tree
Showing 21 changed files with 253 additions and 123 deletions.
21 changes: 15 additions & 6 deletions _modules/pynssp/core/container.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,33 @@ <h1>Source code for pynssp.core.container</h1><div class="highlight"><pre>

<span class="sd"> An object of class NSSPContainer stores a value or an object</span>
<span class="sd"> The NSSPContainer class encapsulates a value or an object</span>

<span class="sd"> :param value: value to store</span>
<span class="sd"> :ivar value: Stored value</span>
<span class="sd"> :examples:</span>

<span class="sd"> &gt;&gt;&gt; from pynssp import NSSPContainer</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; cont = NSSPContainer(&quot;abcdef&quot;)</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Initializes an NSSPContainer class</span>

<span class="sd"> :param value: value to store</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">value</span></div>


<div class="viewcode-block" id="APIGraph"><a class="viewcode-back" href="../../../pynssp.core.html#pynssp.core.container.APIGraph">[docs]</a><span class="k">class</span> <span class="nc">APIGraph</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;A class to store an API graph&quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">response</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Initializes an APIGraph class</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;A class to store an API graph</span>

<span class="sd"> :param path: a string representing the location of a graph</span>
<span class="sd"> :param response: an object of class response</span>
<span class="sd"> :ivar path: the location of a graph file</span>
<span class="sd"> :ivar response: a response object</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">response</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Initializes an APIGraph class</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">path</span> <span class="o">=</span> <span class="n">path</span>
<span class="bp">self</span><span class="o">.</span><span class="n">response</span> <span class="o">=</span> <span class="n">response</span>
Expand Down
11 changes: 8 additions & 3 deletions _modules/pynssp/core/credentials.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,19 @@ <h1>Source code for pynssp.core.credentials</h1><div class="highlight"><pre>

<span class="sd"> A Credentials object has a username, a password and a key.</span>
<span class="sd"> A Credentials object gets API data via an API URL.</span>

<span class="sd"> :param username: a string for username (Default username = None)</span>
<span class="sd"> :param password: a string for password (Default password = None)</span>

<span class="sd"> :examples:</span>
<span class="sd"> &gt;&gt;&gt; from pynssp import Credentials</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; myProfile = Credentials(&quot;user&quot;, &quot;pass&quot;)</span>
<span class="sd"> &quot;&quot;&quot;</span>


<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">username</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">password</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Initializes a new Credentials object.</span>

<span class="sd"> :param username: a string for username (Default username = None)</span>
<span class="sd"> :param password: a string for password (Default password = None)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__k</span> <span class="o">=</span> <span class="n">Fernet</span><span class="p">(</span><span class="n">Fernet</span><span class="o">.</span><span class="n">generate_key</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__username</span> <span class="o">=</span> <span class="n">NSSPContainer</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__k</span><span class="o">.</span><span class="n">encrypt</span><span class="p">(</span><span class="n">username</span><span class="o">.</span><span class="n">encode</span><span class="p">()))</span> \
Expand Down
15 changes: 10 additions & 5 deletions _modules/pynssp/core/token.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,21 @@ <h1>Source code for pynssp.core.token</h1><div class="highlight"><pre>

<span class="sd"> A Token object has a token string and a key.</span>
<span class="sd"> A Token object can get API data via an API URL.</span>

<span class="sd"> :param token: a token string</span>
<span class="sd"> :param access_token: type of HTTP authentication. </span>
<span class="sd"> Should be &quot;Bearer&quot; or &quot;Basic&quot;. (Default value = &quot;Bearer&quot;)</span>
<span class="sd"> :ivar access_token: HTTP authentication type.</span>

<span class="sd"> :examples:</span>
<span class="sd"> &gt;&gt;&gt; from pynssp import Token</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; myTokenProfile = Token(&quot;abc123&quot;)</span>
<span class="sd"> &quot;&quot;&quot;</span>


<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token</span><span class="p">,</span> <span class="n">access_token</span><span class="o">=</span><span class="s2">&quot;Bearer&quot;</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Initializes a new Token object.</span>
<span class="sd"> </span>
<span class="sd"> :param token: a token string</span>
<span class="sd"> :param access_token: type of HTTP authentication. Should be `Bearer` or `Basic`. (Default value = &quot;Bearer&quot;)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__k</span> <span class="o">=</span> <span class="n">Fernet</span><span class="p">(</span><span class="n">Fernet</span><span class="o">.</span><span class="n">generate_key</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__token</span> <span class="o">=</span> <span class="n">NSSPContainer</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__k</span><span class="o">.</span><span class="n">encrypt</span><span class="p">(</span><span class="n">token</span><span class="o">.</span><span class="n">encode</span><span class="p">()))</span>
Expand All @@ -128,7 +135,6 @@ <h1>Source code for pynssp.core.token</h1><div class="highlight"><pre>

<span class="sd"> :param url: a string of API URL</span>
<span class="sd"> :returns: an object of class response</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">headers</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;Authorization&quot;</span><span class="p">:</span> <span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span>
Expand Down Expand Up @@ -175,7 +181,6 @@ <h1>Source code for pynssp.core.token</h1><div class="highlight"><pre>

<span class="sd"> :param file_ext: a non-empty character vector giving the file extension. (Default value = &quot;.pkl&quot;)</span>
<span class="sd"> :param file: (Default value = None)</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">pickle</span> <span class="kn">import</span> <span class="n">dump</span>
<span class="n">file_name</span> <span class="o">=</span> <span class="s2">&quot;tokenProfile&quot;</span> <span class="o">+</span> <span class="n">file_ext</span>
Expand Down
44 changes: 25 additions & 19 deletions _modules/pynssp/data.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,19 @@ <h1>Source code for pynssp.data</h1><div class="highlight"><pre>

<span class="sd"> :examples:</span>
<span class="sd"> </span>
<span class="sd"> &gt;&gt;&gt; from pynssp.data import *</span>
<span class="sd"> &gt;&gt;&gt; from pynssp.data import load_simulated_ts</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; simulated_ts = load_simulated_ts()</span>
<span class="sd"> &gt;&gt;&gt; simulated_ts.info()</span>
<span class="sd"> ... ## # Column Non-Null Count Dtype</span>
<span class="sd"> ... ## --- ------ -------------- -----</span>
<span class="sd"> ... ## 0 date 626 non-null object</span>
<span class="sd"> ... ## 1 week 626 non-null int64</span>
<span class="sd"> ... ## 2 year 626 non-null int64</span>
<span class="sd"> ... ## 3 cases 626 non-null int64</span>
<span class="sd"> ... ## 4 id 626 non-null object</span>
<span class="sd"> ... ## dtypes: int64(3), object(2)</span>
<span class="sd"> ... ## memory usage: 24.6+ KB</span>
<span class="sd"> ## # Column Non-Null Count Dtype</span>
<span class="sd"> ## --- ------ -------------- -----</span>
<span class="sd"> ## 0 date 626 non-null object</span>
<span class="sd"> ## 1 week 626 non-null int64</span>
<span class="sd"> ## 2 year 626 non-null int64</span>
<span class="sd"> ## 3 cases 626 non-null int64</span>
<span class="sd"> ## 4 id 626 non-null object</span>
<span class="sd"> ## dtypes: int64(3), object(2)</span>
<span class="sd"> ## memory usage: 24.6+ KB</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">stream</span> <span class="o">=</span> <span class="n">pkg_resources</span><span class="o">.</span><span class="n">resource_stream</span><span class="p">(</span><span class="vm">__name__</span><span class="p">,</span> <span class="s2">&quot;data/simulated_ts.csv&quot;</span><span class="p">)</span>
Expand All @@ -123,9 +124,11 @@ <h1>Source code for pynssp.data</h1><div class="highlight"><pre>

<div class="viewcode-block" id="get_scenario1"><a class="viewcode-back" href="../../pynssp.html#pynssp.data.get_scenario1">[docs]</a><span class="k">def</span> <span class="nf">get_scenario1</span><span class="p">():</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Return a subset of the simulated time series data (&#39;scenario #1&#39;).</span>

<span class="sd"> :examples:</span>
<span class="sd"> </span>
<span class="sd"> &gt;&gt;&gt; from pynssp.data import *</span>
<span class="sd"> &gt;&gt;&gt; from pynssp import get_scenario1</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; scenario1_ts = get_scenario1()</span>
<span class="sd"> &gt;&gt;&gt; scenario1_ts.info()</span>
<span class="sd"> &quot;&quot;&quot;</span>
Expand All @@ -135,9 +138,11 @@ <h1>Source code for pynssp.data</h1><div class="highlight"><pre>

<div class="viewcode-block" id="get_scenario2"><a class="viewcode-back" href="../../pynssp.html#pynssp.data.get_scenario2">[docs]</a><span class="k">def</span> <span class="nf">get_scenario2</span><span class="p">():</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Return a subset of the simulated time series data (&#39;scenario #2&#39;).</span>

<span class="sd"> :examples:</span>
<span class="sd"> </span>
<span class="sd"> &gt;&gt;&gt; from pynssp.data import *</span>
<span class="sd"> &gt;&gt;&gt; from pynssp import get_scenario2</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; scenario2_ts = get_scenario2()</span>
<span class="sd"> &gt;&gt;&gt; scenario2_ts.info()</span>
<span class="sd"> &quot;&quot;&quot;</span>
Expand All @@ -150,15 +155,16 @@ <h1>Source code for pynssp.data</h1><div class="highlight"><pre>

<span class="sd"> :examples:</span>
<span class="sd"> </span>
<span class="sd"> &gt;&gt;&gt; from pynssp.data import *</span>
<span class="sd"> &gt;&gt;&gt; from pynssp import load_nssp_stopwords</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; stopwords = load_nssp_stopwords()</span>
<span class="sd"> &gt;&gt;&gt; stopwords.info()</span>
<span class="sd"> ... ## # Column Non-Null Count Dtype</span>
<span class="sd"> ... ## --- ------ -------------- -----</span>
<span class="sd"> ... ## 1 word 835 non-null object</span>
<span class="sd"> ... ## 2 type 835 non-null object</span>
<span class="sd"> ... ## dtypes: int64(1), object(2)</span>
<span class="sd"> ... ## memory usage: 13.2+ KB</span>
<span class="sd"> ## # Column Non-Null Count Dtype</span>
<span class="sd"> ## --- ------ -------------- -----</span>
<span class="sd"> ## 1 word 835 non-null object</span>
<span class="sd"> ## 2 type 835 non-null object</span>
<span class="sd"> ## dtypes: int64(1), object(2)</span>
<span class="sd"> ## memory usage: 13.2+ KB</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">stream</span> <span class="o">=</span> <span class="n">pkg_resources</span><span class="o">.</span><span class="n">resource_stream</span><span class="p">(</span><span class="vm">__name__</span><span class="p">,</span> <span class="s2">&quot;data/nssp_stopwords.csv&quot;</span><span class="p">)</span>
Expand Down
4 changes: 3 additions & 1 deletion _modules/pynssp/detectors/ewma.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,15 @@ <h1>Source code for pynssp.detectors.ewma</h1><div class="highlight"><pre>
<span class="sd"> :returns: Original pandas data frame with detection results.</span>
<span class="sd"> :examples:</span>
<span class="sd"> </span>
<span class="sd"> &gt;&gt;&gt; from pynssp import alert_ewma</span>
<span class="sd"> &gt;&gt;&gt; import pandas as pd</span>
<span class="sd"> &gt;&gt;&gt; import numpy as np</span>
<span class="sd"> &gt;&gt;&gt; from pynssp.detectors.ewma import *</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; df = pd.DataFrame({</span>
<span class="sd"> ... &quot;date&quot;: pd.date_range(&quot;2020-01-01&quot;, &quot;2020-12-31&quot;),</span>
<span class="sd"> ... &quot;count&quot;: np.random.randint(0, 101, size=366)</span>
<span class="sd"> ... })</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; df_ewma = alert_ewma(df)</span>
<span class="sd"> &gt;&gt;&gt; df_ewma.head()</span>
<span class="sd"> &quot;&quot;&quot;</span>
Expand Down
3 changes: 3 additions & 0 deletions _modules/pynssp/detectors/nbinom.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,15 @@ <h1>Source code for pynssp.detectors.nbinom</h1><div class="highlight"><pre>
<span class="sd"> whether or not a time term was included.</span>
<span class="sd"> :examples:</span>
<span class="sd"> </span>
<span class="sd"> &gt;&gt;&gt; from pnssp import alert_nbinom</span>
<span class="sd"> &gt;&gt;&gt; import pandas as pd</span>
<span class="sd"> &gt;&gt;&gt; import numpy as np</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; df = pd.DataFrame({</span>
<span class="sd"> ... &quot;date&quot;: pd.date_range(start=&quot;2014-01-05&quot;, end=&quot;2022-02-05&quot;, freq=&quot;W&quot;),</span>
<span class="sd"> ... &quot;count&quot;: np.random.poisson(lam=25, size=(len(pd.date_range(start=&quot;2014-01-05&quot;, end=&quot;2022-02-05&quot;, freq=&quot;W&quot;)),))</span>
<span class="sd"> ... })</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; df_nbinom = alert_nbinom(df, baseline_end = &quot;2020-03-01&quot;)</span>
<span class="sd"> &gt;&gt;&gt; df_nbinom.head()</span>
<span class="sd"> &quot;&quot;&quot;</span>
Expand Down
4 changes: 3 additions & 1 deletion _modules/pynssp/detectors/regression.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ <h1>Source code for pynssp.detectors.regression</h1><div class="highlight"><pre>
<span class="sd"> :returns: Original pandas data frame with detection results.</span>
<span class="sd"> :examples:</span>
<span class="sd"> </span>
<span class="sd"> &gt;&gt;&gt; from pynssp import alert_regression</span>
<span class="sd"> &gt;&gt;&gt; import pandas as pd</span>
<span class="sd"> &gt;&gt;&gt; import numpy as np</span>
<span class="sd"> &gt;&gt;&gt; from pynssp.detectors.regression import *</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; df = pd.DataFrame({</span>
<span class="sd"> ... &quot;date&quot;: pd.date_range(&quot;2020-01-01&quot;, &quot;2020-12-31&quot;),</span>
<span class="sd"> ... &quot;count&quot;: np.random.randint(0, 101, size=366)</span>
<span class="sd"> ... })</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; df_regression = alert_regression(df)</span>
<span class="sd"> &gt;&gt;&gt; df_regression.head()</span>

Expand Down
3 changes: 3 additions & 0 deletions _modules/pynssp/detectors/serfling.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,15 @@ <h1>Source code for pynssp.detectors.serfling</h1><div class="highlight"><pre>
<span class="sd"> a binary alarm indicator field, and a binary indicator</span>
<span class="sd"> :examples:</span>
<span class="sd"> </span>
<span class="sd"> &gt;&gt;&gt; from pynssp import alert_serfling</span>
<span class="sd"> &gt;&gt;&gt; import pandas as pd</span>
<span class="sd"> &gt;&gt;&gt; import numpy as np</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; df = pd.DataFrame({</span>
<span class="sd"> ... &quot;date&quot;: pd.date_range(start=&quot;2014-01-05&quot;, end=&quot;2022-02-05&quot;, freq=&quot;W&quot;),</span>
<span class="sd"> ... &quot;count&quot;: np.random.poisson(lam=25, size=(len(pd.date_range(start=&quot;2014-01-05&quot;, end=&quot;2022-02-05&quot;, freq=&quot;W&quot;)),))</span>
<span class="sd"> ... })</span>
<span class="sd"> &gt;&gt;&gt; </span>
<span class="sd"> &gt;&gt;&gt; df_serfling = alert_serfling(df, baseline_end = &quot;2020-03-01&quot;)</span>
<span class="sd"> &gt;&gt;&gt; df_serfling.head()</span>
<span class="sd"> &quot;&quot;&quot;</span>
Expand Down
Loading

0 comments on commit 28a785b

Please sign in to comment.