Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Updated the documentation for time series #158

Merged
merged 119 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
fcc1924
Update readme with latest feedback (#39)
GalOshri Oct 31, 2018
e100472
Add THIRD-PARTY-NOTICES.txt and move CONTRIBUTING.md to root. (#40)
montebhoover Oct 31, 2018
8239922
Create CODE_OF_CONDUCT.md
ganik Nov 1, 2018
ad0af7c
Update issue templates
ganik Nov 1, 2018
19f4721
Create PULL_REQUEST_TEMPLATE.md
ganik Nov 1, 2018
1e16e64
Update issue templates
ganik Nov 1, 2018
007e624
Update issue templates
ganik Nov 1, 2018
110b0f9
Update issue templates
ganik Nov 1, 2018
0b5adef
Fixing link in CONTRIBUTING.md (#44)
justinormont Nov 2, 2018
a2ba6f5
Update contributing.md link. (#43)
montehoover Nov 4, 2018
45be3d7
Merge pull request #1 from Microsoft/master
ganik Nov 9, 2018
243325d
Initial checkin for ML.NET 0.7 upgrade
ganik Nov 9, 2018
cbfb439
fix tests
ganik Nov 9, 2018
653d8c1
put back columndropper
ganik Nov 10, 2018
1ae3060
fix tests
ganik Nov 10, 2018
10bd895
Update scikit-learn links to use https instead of http
Nov 19, 2018
bec566c
Merge pull request #56 from GalOshri/update-scikit-learn-https
justinormont Nov 20, 2018
725be2e
Merge pull request #2 from Microsoft/master
ganik Nov 23, 2018
f74b3c8
restart dotnetcore2 package work
ganik Nov 23, 2018
a9684bc
fix build
ganik Nov 23, 2018
0976828
fix mac & linux
ganik Nov 24, 2018
620d13d
fix build
ganik Nov 24, 2018
3e10cec
fix build
ganik Nov 24, 2018
04e87b7
dbg build
ganik Nov 24, 2018
98c8987
fix build
ganik Nov 24, 2018
d2e815f
fix build
ganik Nov 24, 2018
34c5f29
handle py 2.7
ganik Nov 24, 2018
bbb4c63
handle py27
ganik Nov 24, 2018
64da211
fix py27
ganik Nov 24, 2018
7ea0a25
fix build
ganik Nov 25, 2018
55308ec
fix build
ganik Nov 25, 2018
577d84e
fix build
ganik Nov 25, 2018
b571d22
ensure dependencies
ganik Nov 25, 2018
062d55a
ignore exceptions from ensure dependencies
ganik Nov 25, 2018
ace3cc9
Merge pull request #60 from ganik/ganik/dotnet2
ganik Nov 26, 2018
ab3d80d
up version
ganik Nov 26, 2018
36b4f48
Merge pull request #3 from Microsoft/master
ganik Nov 26, 2018
c2ce774
Merge branch 'master' into ganik/dotnet2
ganik Nov 26, 2018
d912ca5
Merge pull request #61 from ganik/ganik/dotnet2
ganik Nov 26, 2018
9fd5c3c
Update cv.py
zyw400 Nov 27, 2018
7c58875
Update cv.py
zyw400 Nov 27, 2018
1d02fc3
add a test for cv with data frame
zyw400 Nov 27, 2018
422bd8d
set DOTNET_SYSTEM_GLOBALIZATION_INVARIANT to true to fix app domain e…
ganik Nov 28, 2018
c6704fd
Merge pull request #62 from zyw400/yiwzh/fix_cv
ganik Nov 28, 2018
9d3376c
fix build
ganik Nov 28, 2018
83db226
Merge pull request #4 from Microsoft/master
ganik Nov 28, 2018
e54535d
Merge branch 'master' into ganik/amldocker
ganik Nov 28, 2018
4c68428
up version
ganik Nov 28, 2018
52ad2d0
Merge pull request #63 from ganik/ganik/amldocker
ganik Nov 28, 2018
341e01a
Add instructions for editing docstrings. (#51)
montebhoover Dec 6, 2018
9a0b50e
Fix build failures caused by dotnetcore2 module. (#67)
montebhoover Dec 7, 2018
0d2e4e6
Reduce number of build legs for PR validations and add nightly build …
montebhoover Dec 7, 2018
f7b7ded
Merge pull request #5 from Microsoft/master
ganik Dec 12, 2018
19b240e
Merge branch 'master' into ganik/mlnet.7
ganik Dec 12, 2018
b45a953
Increase version to 0.6.5. (#71)
montebhoover Dec 12, 2018
f3eb0bb
Update clr helper function to search multiple folders for clr binarie…
montebhoover Dec 15, 2018
155696c
fix drop column param name
ganik Dec 16, 2018
c94568d
Merge pull request #6 from Microsoft/master
ganik Dec 16, 2018
453a940
Merge branch 'master' into ganik/mlnet.7
ganik Dec 16, 2018
f95b3ba
Remove restricted permissions on build.sh script.
Dec 18, 2018
7a5e6d9
Fix lightgbm test failures by updating runtime dependencies.
montebhoover Dec 18, 2018
7a46ce1
fix TensorFlowScorer model_location paramter name
ganik Dec 18, 2018
7b7692c
Fix build.sh defaults so that it detects when running on a mac.
Dec 18, 2018
492751f
Since OneHotHashVectorizer is broken for output kind Key in ML.NET 0.…
ganik Dec 20, 2018
66cb189
Merge pull request #75 from montebhoover/improve_mac_ux
justinormont Dec 20, 2018
eb2b39f
fix tests
ganik Dec 20, 2018
d71a31e
Merge pull request #7 from Microsoft/master
ganik Dec 20, 2018
27d4a6a
Merge branch 'master' into ganik/mlnet.7
ganik Dec 20, 2018
af76d08
Merge pull request #8 from ganik/master
ganik Dec 20, 2018
c779510
fix pyproj test
ganik Dec 20, 2018
2bdfa41
Merge branch 'ganik/mlnet.7' of https://github.com/ganik/NimbusML int…
ganik Dec 20, 2018
d23d696
fix win 3.6 build
ganik Dec 20, 2018
172c1e8
fix comments
ganik Dec 20, 2018
80ce48f
Merge pull request #55 from ganik/ganik/mlnet.7
ganik Dec 20, 2018
b5f1c2e
Merge pull request #1 from Microsoft/master
zyw400 Jan 4, 2019
bfaf819
expose "parallel" to the fit/fit_transform function by including **pa…
zyw400 Jan 5, 2019
eaeb24c
add a test for the parallel
zyw400 Jan 5, 2019
a5997db
update parallel thread
zyw400 Jan 7, 2019
67530ff
fix tests comparison
zyw400 Jan 7, 2019
066469f
Update thread, retry build
zyw400 Jan 7, 2019
a9596ca
modify tests
zyw400 Jan 7, 2019
13d7b35
specify pytest-cov version
zyw400 Jan 7, 2019
af577c4
update pytest-cov version in build command for linux
zyw400 Jan 7, 2019
4dc79e1
for windows use the latest pytest-cov
zyw400 Jan 7, 2019
d2535be
Merge pull request #86 from zyw400/yiwzh/add_nthreads_to_graph
zyw400 Jan 8, 2019
3079d56
Enabled strong naming for DoNetBridge.dll (to be used for InternalsVi…
Jan 8, 2019
a556f39
Changed the keys to be the same as other internal repos
Jan 8, 2019
0fd4f0e
Changed the key filename
Jan 8, 2019
4f7f22b
Merge branch 'master' into strongname
Jan 9, 2019
b0c1e3a
Merge pull request #87 from shmoradims/strongname
Jan 9, 2019
9e57f19
Update to ML.NET 0.10.preview (#77)
montebhoover Jan 16, 2019
7c9a1c6
Simplify by using six.string_types (#89)
cclauss Jan 18, 2019
e5f2b65
Removed ISchema from DotNetBridge (#90)
Jan 24, 2019
dca1157
add configuration for python 3.7 (#101)
xadupre Apr 11, 2019
3616e73
Removing 3.7 for now as its not in PyPI
ganik May 7, 2019
210b220
Upgrade to ML.NET version 1.0.0 (#100)
ganik May 27, 2019
b5eb937
Fix latest Windows build issues. (#105)
pieths May 27, 2019
c35536d
Fixes #50 - summary() fails if called a second time. (#107)
pieths May 30, 2019
8da35e1
Fixes #99. Do not use hardcoded file separator. (#108)
pieths May 30, 2019
b4ec723
Delete the cached summaries when refitting a pipeline or a predictor.…
pieths Jun 1, 2019
91478d1
Fix signature import error when using latest version of scikit-learn.…
pieths Jun 2, 2019
a580331
Package System.Drawing.Common.dll as its missing in dotnetcore2 (#120)
ganik Jun 4, 2019
7848487
Upgrade the pytest-remotedata package to fix missing attribute error.…
pieths Jun 4, 2019
32e2d67
Upgrade version (#122)
ganik Jun 4, 2019
d09a5c5
Support quoted strings by default (#124)
ganik Jun 4, 2019
b57cfcc
upgrade to ML.NET 1.1 (#126)
ganik Jun 5, 2019
b4931e4
Put long running tests in to their own folder to shorten build times.…
pieths Jun 13, 2019
7863ca0
Expose ML.NET SSA & IID spike & changepoint detectors. (#135)
pieths Jun 14, 2019
3c689c6
Fix a few minor issues with time series unit tests and examples. (#139)
pieths Jun 18, 2019
207a6b6
Skip Image.py and Image_df.py tests for Ubuntu 14 (#149)
Stephen0620 Jun 18, 2019
0ca2b29
* Fixed the script for generating the documentation (#144)
Stephen0620 Jun 18, 2019
3b46629
Rename time_series package to timeseries. (#150)
pieths Jun 18, 2019
7c7d76b
Initial checkin
ganik Oct 19, 2018
07f70ed
Move to Hosted Mac pool
ganik Oct 19, 2018
d03db2e
Manually copied naming changes over from master.
montebhoover Oct 20, 2018
4f773be
merge master to temp/docs for updating the documentation (#134)
Stephen0620 Jun 12, 2019
38eda27
Merge branch 'documentation' into temp/docs (#143)
Stephen0620 Jun 18, 2019
6d97228
Added undersocres to the files of time series
Jun 25, 2019
2fd0608
Merge branch 'temp/docs' into new_docs
Stephen0620 Jun 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/DotNetBridge/Bridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Microsoft.ML.Trainers.FastTree;
using Microsoft.ML.Trainers.LightGbm;
using Microsoft.ML.Transforms;
using Microsoft.ML.TimeSeries;

namespace Microsoft.MachineLearning.DotNetBridge
{
Expand Down Expand Up @@ -328,6 +329,7 @@ private static unsafe int GenericExec(EnvironmentBlock* penv, sbyte* psz, int cd
//env.ComponentCatalog.RegisterAssembly(typeof(SaveOnnxCommand).Assembly);
//env.ComponentCatalog.RegisterAssembly(typeof(TimeSeriesProcessingEntryPoints).Assembly);
//env.ComponentCatalog.RegisterAssembly(typeof(ParquetLoader).Assembly);
env.ComponentCatalog.RegisterAssembly(typeof(ForecastExtensions).Assembly);

using (var ch = host.Start("Executing"))
{
Expand Down
1 change: 1 addition & 0 deletions src/DotNetBridge/DotNetBridge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
<PackageReference Include="Microsoft.ML.OnnxTransformer" Version="0.13.0" />
<PackageReference Include="Microsoft.ML.TensorFlow" Version="0.13.0" />
<PackageReference Include="Microsoft.ML.Ensemble" Version="0.13.0" />
<PackageReference Include="Microsoft.ML.TimeSeries" Version="0.13.0" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/Platforms/build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<PackageReference Include="Microsoft.ML.OnnxTransformer" Version="0.13.0" />
<PackageReference Include="Microsoft.ML.TensorFlow" Version="0.13.0" />
<PackageReference Include="Microsoft.ML.Ensemble" Version="0.13.0" />
<PackageReference Include="Microsoft.ML.TimeSeries" Version="0.13.0" />
</ItemGroup>

</Project>
6 changes: 4 additions & 2 deletions src/python/docs/sphinx/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=%PYTHONINTERPRETER% -m sphinx
)

:: Todo: Fix the issue here, the installtion guide is not showing correctly
set SOURCEDIR=.
set BUILDDIR=%~dp0_build
set SPHINXPROJ=microsoftml

if "%1" == "" goto html:
if "%1" == "" goto html:
set format=%1
goto next:

Expand Down Expand Up @@ -52,4 +54,4 @@ goto end:
@echo An issue happened. Check %BUILDDIR%\%format% is not here.

:end
popd
popd
27 changes: 26 additions & 1 deletion src/python/nimbusml.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<Compile Include="nimbusml\examples\examples_from_dataframe\GamRegressor_airquality_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\GlobalContrastRowScaler_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\Handler_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\IidChangePointDetector_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\SsaChangePointDetector_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\SsaSpikeDetector_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\Image_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\Indicator_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\FromKey_df.py" />
Expand All @@ -109,6 +112,7 @@
<Compile Include="nimbusml\examples\examples_from_dataframe\OneHotVectorizer_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\OnlineGradientDescentRegressor_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\OrdinaryLeastSquaresRegressor_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\IidSpikeDetector_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\PcaAnomalyDetector_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\PcaTransformer_df.py" />
<Compile Include="nimbusml\examples\examples_from_dataframe\RangeFilter_df.py" />
Expand All @@ -134,6 +138,9 @@
<Compile Include="nimbusml\examples\GlobalContrastRowScaler.py" />
<Compile Include="nimbusml\examples\Handler.py" />
<Compile Include="nimbusml\examples\Hinge.py" />
<Compile Include="nimbusml\examples\IidChangePointDetector.py" />
<Compile Include="nimbusml\examples\SsaChangePointDetector.py" />
<Compile Include="nimbusml\examples\SsaSpikeDetector.py" />
<Compile Include="nimbusml\examples\Image.py" />
<Compile Include="nimbusml\examples\Indicator.py" />
<Compile Include="nimbusml\examples\FromKey.py" />
Expand All @@ -159,6 +166,7 @@
<Compile Include="nimbusml\examples\OneVsRestClassifier.py" />
<Compile Include="nimbusml\examples\OnlineGradientDescentRegressor.py" />
<Compile Include="nimbusml\examples\OrdinaryLeastSquaresRegressor.py" />
<Compile Include="nimbusml\examples\IidSpikeDetector.py" />
<Compile Include="nimbusml\examples\PcaAnomalyDetector.py" />
<Compile Include="nimbusml\examples\PcaTransformer.py" />
<Compile Include="nimbusml\examples\PipelineWithGridSearchCV2.py" />
Expand All @@ -181,7 +189,6 @@
<Compile Include="nimbusml\examples\_Load_Save_Models.py" />
<Compile Include="nimbusml\examples\_Load_Save_Pipeline.py" />
<Compile Include="nimbusml\examples\_Load_Save_transforms.py" />
<Compile Include="nimbusml\examples\__init__.py" />
<Compile Include="nimbusml\feature_extraction\text\extractor\_ngram.py" />
<Compile Include="nimbusml\feature_extraction\text\extractor\_ngramhash.py" />
<Compile Include="nimbusml\feature_extraction\text\extractor\__init__.py" />
Expand Down Expand Up @@ -219,6 +226,11 @@
<Compile Include="nimbusml\internal\core\loss\__init__.py" />
<Compile Include="nimbusml\internal\core\multiclass\_onevsrestclassifier.py" />
<Compile Include="nimbusml\internal\core\multiclass\__init__.py" />
<Compile Include="nimbusml\internal\core\timeseries\_iidchangepointdetector.py" />
<Compile Include="nimbusml\internal\core\timeseries\_iidspikedetector.py" />
<Compile Include="nimbusml\internal\core\timeseries\_ssachangepointdetector.py" />
<Compile Include="nimbusml\internal\core\timeseries\_ssaspikedetector.py" />
<Compile Include="nimbusml\internal\core\timeseries\__init__.py" />
<Compile Include="nimbusml\internal\core\preprocessing\filter\_skipfilter.py" />
<Compile Include="nimbusml\internal\core\preprocessing\filter\_takefilter.py" />
<Compile Include="nimbusml\internal\core\preprocessing\schema\_columnduplicator.py" />
Expand Down Expand Up @@ -569,6 +581,16 @@
<Compile Include="nimbusml\tests\feature_extraction\text\test_sentiment.py" />
<Compile Include="nimbusml\tests\idv\__init__.py" />
<Compile Include="nimbusml\tests\preprocessing\normalization\test_meanvariancescaler.py" />
<Compile Include="nimbusml\tests\timeseries\test_iidchangepointdetector.py" />
<Compile Include="nimbusml\tests\timeseries\test_ssachangepointdetector.py" />
<Compile Include="nimbusml\tests\timeseries\test_ssaspikedetector.py" />
<Compile Include="nimbusml\tests\timeseries\test_iidspikedetector.py" />
<Compile Include="nimbusml\tests\timeseries\__init__.py" />
<Compile Include="nimbusml\timeseries\_iidchangepointdetector.py" />
<Compile Include="nimbusml\timeseries\_iidspikedetector.py" />
<Compile Include="nimbusml\timeseries\_ssachangepointdetector.py" />
<Compile Include="nimbusml\timeseries\_ssaspikedetector.py" />
<Compile Include="nimbusml\timeseries\__init__.py" />
<Compile Include="tests\test_estimator_checks.py" />
<Compile Include="nimbusml\tests\feature_extraction\text\test_lightlda.py" />
<Compile Include="nimbusml\tests\idv\test_idv.py" />
Expand Down Expand Up @@ -741,6 +763,7 @@
<Folder Include="nimbusml\internal\core\preprocessing\normalization\" />
<Folder Include="nimbusml\internal\core\preprocessing\schema\" />
<Folder Include="nimbusml\internal\core\preprocessing\text\" />
<Folder Include="nimbusml\internal\core\timeseries\" />
<Folder Include="nimbusml\internal\entrypoints\" />
<Folder Include="nimbusml\internal\utils\" />
<Folder Include="nimbusml\linear_model\" />
Expand All @@ -762,6 +785,7 @@
<Folder Include="nimbusml\tests\multiclass\" />
<Folder Include="nimbusml\tests\model_summary\" />
<Folder Include="nimbusml\tests\idv\" />
<Folder Include="nimbusml\tests\timeseries\" />
<Folder Include="nimbusml\tests\pipeline\" />
<Folder Include="nimbusml\tests\feature_extraction\" />
<Folder Include="nimbusml\tests\feature_extraction\categorical\" />
Expand All @@ -778,6 +802,7 @@
<Folder Include="nimbusml\tests\preprocessing\text\" />
<Folder Include="nimbusml\tests\scikit\" />
<Folder Include="nimbusml\tests\utils\" />
<Folder Include="nimbusml\timeseries\" />
<Folder Include="nimbusml\utils\" />
<Folder Include="tests\" />
<Folder Include="tools\" />
Expand Down
38 changes: 38 additions & 0 deletions src/python/nimbusml/examples/IidChangePointDetector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
###############################################################################
# IidChangePointDetector
from nimbusml import Pipeline, FileDataStream
from nimbusml.datasets import get_dataset
from nimbusml.timeseries import IidChangePointDetector

# data input (as a FileDataStream)
path = get_dataset('timeseries').as_filepath()

data = FileDataStream.read_csv(path)
print(data.head())
# t1 t2 t3
# 0 0.01 0.01 0.0100
# 1 0.02 0.02 0.0200
# 2 0.03 0.03 0.0200
# 3 0.03 0.03 0.0250
# 4 0.03 0.03 0.0005

# define the training pipeline
pipeline = Pipeline([
IidChangePointDetector(columns={'t2_cp': 't2'}, change_history_length=4)
])

result = pipeline.fit_transform(data)
print(result)

# t1 t2 t3 t2_cp.Alert t2_cp.Raw Score t2_cp.P-Value Score t2_cp.Martingale Score
# 0 0.01 0.01 0.0100 0.0 0.01 5.000000e-01 1.212573e-03
# 1 0.02 0.02 0.0200 0.0 0.02 4.960106e-01 1.221347e-03
# 2 0.03 0.03 0.0200 0.0 0.03 1.139087e-02 3.672914e-02
# 3 0.03 0.03 0.0250 0.0 0.03 2.058296e-01 8.164447e-02
# 4 0.03 0.03 0.0005 0.0 0.03 2.804577e-01 1.373786e-01
# 5 0.03 0.05 0.0100 1.0 0.05 1.448886e-06 1.315014e+04
# 6 0.05 0.07 0.0500 0.0 0.07 2.616611e-03 4.941587e+04
# 7 0.07 0.09 0.0900 0.0 0.09 3.053187e-02 2.752614e+05
# 8 0.09 99.00 99.0000 0.0 99.00 1.000000e-08 1.389396e+12
# 9 1.10 0.10 0.1000 1.0 0.10 3.778296e-01 1.854344e+07

37 changes: 37 additions & 0 deletions src/python/nimbusml/examples/IidSpikeDetector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
###############################################################################
# IidSpikeDetector
from nimbusml import Pipeline, FileDataStream
from nimbusml.datasets import get_dataset
from nimbusml.timeseries import IidSpikeDetector

# data input (as a FileDataStream)
path = get_dataset('timeseries').as_filepath()

data = FileDataStream.read_csv(path)
print(data.head())
# t1 t2 t3
# 0 0.01 0.01 0.0100
# 1 0.02 0.02 0.0200
# 2 0.03 0.03 0.0200
# 3 0.03 0.03 0.0250
# 4 0.03 0.03 0.0005

# define the training pipeline
pipeline = Pipeline([
IidSpikeDetector(columns={'t2_spikes': 't2'}, pvalue_history_length=5)
])

result = pipeline.fit_transform(data)
print(result)
# t1 t2 t3 t2_spikes.Alert t2_spikes.Raw Score t2_spikes.P-Value Score
# 0 0.01 0.01 0.0100 0.0 0.01 5.000000e-01
# 1 0.02 0.02 0.0200 0.0 0.02 4.960106e-01
# 2 0.03 0.03 0.0200 0.0 0.03 1.139087e-02
# 3 0.03 0.03 0.0250 0.0 0.03 2.058296e-01
# 4 0.03 0.03 0.0005 0.0 0.03 2.804577e-01
# 5 0.03 0.05 0.0100 1.0 0.05 3.743552e-03
# 6 0.05 0.07 0.0500 1.0 0.07 4.136079e-03
# 7 0.07 0.09 0.0900 0.0 0.09 2.242496e-02
# 8 0.09 99.00 99.0000 1.0 99.00 1.000000e-08
# 9 1.10 0.10 0.1000 0.0 0.10 4.015681e-01

40 changes: 40 additions & 0 deletions src/python/nimbusml/examples/SsaChangePointDetector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
###############################################################################
# SsaChangePointDetector
from nimbusml import Pipeline, FileDataStream
from nimbusml.datasets import get_dataset
from nimbusml.timeseries import SsaChangePointDetector

# data input (as a FileDataStream)
path = get_dataset('timeseries').as_filepath()

data = FileDataStream.read_csv(path)
print(data.head())
# t1 t2 t3
# 0 0.01 0.01 0.0100
# 1 0.02 0.02 0.0200
# 2 0.03 0.03 0.0200
# 3 0.03 0.03 0.0250
# 4 0.03 0.03 0.0005

# define the training pipeline
pipeline = Pipeline([
SsaChangePointDetector(columns={'t2_cp': 't2'},
change_history_length=4,
training_window_size=8,
seasonal_window_size=3)
])

result = pipeline.fit_transform(data)
print(result)

# t1 t2 t3 t2_cp.Alert t2_cp.Raw Score t2_cp.P-Value Score t2_cp.Martingale Score
# 0 0.01 0.01 0.0100 0.0 -0.111334 5.000000e-01 0.001213
# 1 0.02 0.02 0.0200 0.0 -0.076755 4.862075e-01 0.001243
# 2 0.03 0.03 0.0200 0.0 -0.034871 3.856320e-03 0.099119
# 3 0.03 0.03 0.0250 0.0 -0.012559 8.617091e-02 0.482400
# 4 0.03 0.03 0.0005 0.0 -0.015723 2.252377e-01 0.988788
# 5 0.03 0.05 0.0100 0.0 -0.001133 1.767711e-01 2.457946
# 6 0.05 0.07 0.0500 0.0 0.006265 9.170460e-02 0.141898
# 7 0.07 0.09 0.0900 0.0 0.002383 2.701134e-01 0.050747
# 8 0.09 99.00 99.0000 1.0 98.879520 1.000000e-08 210274.372059
# 9 1.10 0.10 0.1000 0.0 -57.817568 6.635692e-02 507877.454862
40 changes: 40 additions & 0 deletions src/python/nimbusml/examples/SsaSpikeDetector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
###############################################################################
# SsaSpikeDetector
from nimbusml import Pipeline, FileDataStream
from nimbusml.datasets import get_dataset
from nimbusml.timeseries import SsaSpikeDetector

# data input (as a FileDataStream)
path = get_dataset('timeseries').as_filepath()

data = FileDataStream.read_csv(path)
print(data.head())
# t1 t2 t3
# 0 0.01 0.01 0.0100
# 1 0.02 0.02 0.0200
# 2 0.03 0.03 0.0200
# 3 0.03 0.03 0.0250
# 4 0.03 0.03 0.0005

# define the training pipeline
pipeline = Pipeline([
SsaSpikeDetector(columns={'t2_spikes': 't2'},
pvalue_history_length=4,
training_window_size=8,
seasonal_window_size=3)
])

result = pipeline.fit_transform(data)
print(result)

# t1 t2 t3 t2_spikes.Alert t2_spikes.Raw Score t2_spikes.P-Value Score
# 0 0.01 0.01 0.0100 0.0 -0.111334 5.000000e-01
# 1 0.02 0.02 0.0200 0.0 -0.076755 4.862075e-01
# 2 0.03 0.03 0.0200 0.0 -0.034871 3.856320e-03
# 3 0.03 0.03 0.0250 0.0 -0.012559 8.617091e-02
# 4 0.03 0.03 0.0005 0.0 -0.015723 2.252377e-01
# 5 0.03 0.05 0.0100 0.0 -0.001133 1.767711e-01
# 6 0.05 0.07 0.0500 0.0 0.006265 9.170460e-02
# 7 0.07 0.09 0.0900 0.0 0.002383 2.701134e-01
# 8 0.09 99.00 99.0000 1.0 98.879520 1.000000e-08
# 9 1.10 0.10 0.1000 0.0 -57.817568 6.635692e-02
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
###############################################################################
# IidChangePointDetector
import pandas as pd
from nimbusml.timeseries import IidChangePointDetector

# Create a sample series with a change
input_data = [5, 5, 5, 5, 5, 5, 5, 5]
input_data.extend([7, 7, 7, 7, 7, 7, 7, 7])

X_train = pd.Series(input_data, name="ts")

cpd = IidChangePointDetector(confidence=95, change_history_length=4) << {'result': 'ts'}
data = cpd.fit_transform(X_train)

print(data)

# ts result.Alert result.Raw Score result.P-Value Score result.Martingale Score
# 0 5 0.0 5.0 5.000000e-01 0.001213
# 1 5 0.0 5.0 5.000000e-01 0.001213
# 2 5 0.0 5.0 5.000000e-01 0.001213
# 3 5 0.0 5.0 5.000000e-01 0.001213
# 4 5 0.0 5.0 5.000000e-01 0.001213
# 5 5 0.0 5.0 5.000000e-01 0.001213
# 6 5 0.0 5.0 5.000000e-01 0.001213
# 7 5 0.0 5.0 5.000000e-01 0.001213
# 8 7 1.0 7.0 1.000000e-08 10298.666376 <-- alert is on, predicted changepoint
# 9 7 0.0 7.0 1.328455e-01 33950.164799
# 10 7 0.0 7.0 2.613750e-01 60866.342063
# 11 7 0.0 7.0 3.776152e-01 78362.038772
# 12 7 0.0 7.0 5.000000e-01 0.009226
# 13 7 0.0 7.0 5.000000e-01 0.002799
# 14 7 0.0 7.0 5.000000e-01 0.001561
# 15 7 0.0 7.0 5.000000e-01 0.001213

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
###############################################################################
# IidSpikeDetector
import pandas as pd
from nimbusml.timeseries import IidSpikeDetector

X_train = pd.Series([5, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5], name="ts")

isd = IidSpikeDetector(confidence=95, pvalue_history_length=2.5) << {'result': 'ts'}

isd.fit(X_train, verbose=1)
data = isd.transform(X_train)

print(data)

# ts result.Alert result.Raw Score result.P-Value Score
# 0 5.0 0.0 5.0 5.000000e-01
# 1 5.0 0.0 5.0 5.000000e-01
# 2 5.0 0.0 5.0 5.000000e-01
# 3 5.0 0.0 5.0 5.000000e-01
# 4 5.0 0.0 5.0 5.000000e-01
# 5 10.0 1.0 10.0 1.000000e-08 <-- alert is on, predicted spike
# 6 5.0 0.0 5.0 2.613750e-01
# 7 5.0 0.0 5.0 2.613750e-01
# 8 5.0 0.0 5.0 5.000000e-01
# 9 5.0 0.0 5.0 5.000000e-01
# 10 5.0 0.0 5.0 5.000000e-01
Loading