Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Save models to hdf5 and other formats #160

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
affe939
Update variablelength.rst
rtavenar Sep 12, 2019
95a3d3c
Update variablelength.rst
rtavenar Sep 12, 2019
ccca697
Install requirements for PyPI changed
rtavenar Sep 27, 2019
eaaf444
Merge branch 'master' of https://github.com/rtavenar/tslearn
rtavenar Sep 27, 2019
5f90e28
Create issue templates
rtavenar Sep 29, 2019
c0a335a
Update issue templates
rtavenar Sep 29, 2019
6ff911a
Update CONTRIBUTING.md
rtavenar Sep 29, 2019
c67438b
Create CODE_OF_CONDUCT.md
rtavenar Sep 29, 2019
80b6b5a
C++ build tools details
rtavenar Sep 30, 2019
6ae9112
Merge branch 'master' of https://github.com/rtavenar/tslearn
rtavenar Sep 30, 2019
3675e18
Include tests folder in wheels
rth Oct 2, 2019
447b9a3
Fix imports
rth Oct 2, 2019
b391b2c
Skip shapelets tests if keras / tensorflow is not installed
rth Oct 2, 2019
2e82ae2
Version 0.2.4
rth Oct 2, 2019
33b27e9
Merge pull request #154 from rth/include-tests-in-wheels
rtavenar Oct 2, 2019
6742485
Update CHANGELOG.md
rtavenar Oct 2, 2019
bd7f6e6
Update shapelets.py
rtavenar Oct 3, 2019
b840e5b
Update shapelets.py
rtavenar Oct 3, 2019
8c0875b
Update requirements_rtd.txt
rtavenar Oct 3, 2019
1254f7e
Update requirements_rtd.txt
rtavenar Oct 3, 2019
39ad33b
Update requirements.txt
rtavenar Oct 3, 2019
86f297f
More fixes to include test/ folder in sdist
rth Oct 10, 2019
b7499aa
Version 0.2.5
rtavenar Oct 10, 2019
1721482
Merge pull request #159 from rth/more-fixes-setup
rtavenar Oct 11, 2019
0c2cab1
bases module which contains BaseModelPackage and hdftools module for
kushalkolar Dec 4, 2019
45b979c
KShape utilizes BaseModelPackage to save the model as hdf5, json or
kushalkolar Dec 4, 2019
4dbb2ed
added example of how to save/load kshape models
kushalkolar Dec 4, 2019
6a81531
better export implementation, WIP
kushalkolar Dec 8, 2019
cc992c7
cleaner classmethods for the other save methods
kushalkolar Dec 8, 2019
0cae83b
remove model_params class attribute and declared _X_fit outside __init__
kushalkolar Dec 10, 2019
81b1883
docs
kushalkolar Dec 10, 2019
d6018af
modified: ../notebooks/save_load_kshape.ipynb
kushalkolar Dec 10, 2019
4f36d82
Change attributes that define whether or not a kShape model has been
kushalkolar Jan 3, 2020
2397646
JSON format works for saving models. Model params which are lists are by
kushalkolar Jan 3, 2020
2158838
updated example notebook
kushalkolar Jan 3, 2020
744f404
remove model from docstring
kushalkolar Jan 3, 2020
c3f208f
All docstrings in sklearn format. Simpler to_dict() method
kushalkolar Jan 4, 2020
a3183d4
docstrings in sklearn format and removed dataframe methods since tslearn
kushalkolar Jan 4, 2020
596cbaa
docstrings
kushalkolar Jan 4, 2020
564ea55
pep8 some things
kushalkolar Jan 4, 2020
8555e49
pep8 some things
kushalkolar Jan 4, 2020
bfe7bf3
more pep8'ing
kushalkolar Jan 4, 2020
1af8b80
make some methods protected
kushalkolar Jan 9, 2020
59b8a49
remove type annotations
kushalkolar Jan 9, 2020
19fb981
add h5py to requirements
kushalkolar Jan 9, 2020
f4e4089
conform to sklearn __init__
kushalkolar Jan 17, 2020
4e323e2
remove fstrings for python 2 support
kushalkolar Jan 17, 2020
f7d3edc
older metaclass syntax
kushalkolar Jan 17, 2020
140a47a
Merge branch 'dev' into master
rtavenar Jan 17, 2020
1e6afcc
added test_serialize_models module
kushalkolar Jan 20, 2020
44dd3c8
add _X_fit as KShape model param, think of a more elegant solution later
kushalkolar Jan 20, 2020
499df64
comment
kushalkolar Jan 20, 2020
bc450cc
test hdftools
kushalkolar Jan 20, 2020
5b604ff
tmpdir is actually temporary
kushalkolar Jan 20, 2020
ac275f0
remove notebook
kushalkolar Jan 20, 2020
e4aa375
_is_fitted typo
kushalkolar Jan 20, 2020
74c5890
make sure exception raised if not fitted and user tries to serialize
kushalkolar Jan 20, 2020
ebceb85
hdf5 doesn't store Nones, so store 'None' as a string
kushalkolar Jan 20, 2020
ede5a33
1. Add serialization to TimeSeriesKMeans and corresponding test.
kushalkolar Jan 20, 2020
b3feca4
KShape uses cluster_centers_ to check_dims for predict() instead of
kushalkolar Jan 20, 2020
d40069e
remove some dtypes (float128, builtin int, builtin float, bytes) from…
kushalkolar Jan 20, 2020
12a1c8d
more python 2 compatability
kushalkolar Jan 20, 2020
f589e59
more python2.7 compatability
kushalkolar Jan 20, 2020
d0c1e06
GAK uses BaseModelPackage
kushalkolar Jan 20, 2020
2074e35
changed ValueError to NotFittedError
kushalkolar Jan 20, 2020
600b8ff
1. KNeighborsTimeSeries inherits from BaseModelPackage for
kushalkolar Jan 20, 2020
0109af7
standardize docstrings
kushalkolar Jan 20, 2020
d775c62
BaseModelPackage doesn't inherit from BaseEstimator to make it easier to
kushalkolar Jan 20, 2020
e853138
knn ts classifier uses BaseModelPackage and has a test
kushalkolar Jan 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,24 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
A short code sample to reproduce the code

**Expected behavior**
A clear and concise description of what you expected to happen.

**Environment (please complete the following information):**
- OS: [e.g. iOS]
- tslearn version [e.g. 0.2.2]

**Additional context**
Add any other context about the problem here.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: new feature
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -51,6 +51,13 @@ bound constraint on warping path length
its parameter is set, that is now considered sufficient to identify the
constraint.

## [v0.2.4]

### Fixed

* The `tests` subdirectory is now made a python package and hence included in
wheels

## [v0.2.2]

### Fixed
Expand Down
74 changes: 74 additions & 0 deletions CODE_OF_CONDUCT.md
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
118 changes: 118 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -16,3 +16,121 @@ We are welcoming contributions in the following forms:
If you would like to contribute by implementing a new feature reported in the Issues, maybe starting with [Issues that are attached the "good first issue" label](https://github.com/rtavenar/tslearn/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) would be a good idea.

When submitting code, please think about code quality, adding proper docstrings including doctests with high code coverage.

## More details on Pull requests

The preferred workflow for contributing to tslearn is to fork the
[main repository](https://github.com/rtavenar/tslearn) on
GitHub, clone, and develop on a branch. Steps:

1. Fork the [project repository](https://github.com/rtavenar/tslearn)
by clicking on the 'Fork' button near the top right of the page. This creates
a copy of the code under your GitHub user account. For more details on
how to fork a repository see [this guide](https://help.github.com/articles/fork-a-repo/).

2. Clone your fork of the tslearn repo from your GitHub account to your local disk:

```bash
$ git clone git@github.com:YourLogin/tslearn.git
$ cd tslearn
```

3. Create a ``feature`` branch to hold your development changes:

```bash
$ git checkout -b my-feature
```

Always use a ``feature`` branch. It's good practice to never work on the ``master`` branch!

4. Develop the feature on your feature branch. Add changed files using ``git add`` and then ``git commit`` files:

```bash
$ git add modified_files
$ git commit
```

to record your changes in Git, then push the changes to your GitHub account with:

```bash
$ git push -u origin my-feature
```

5. Follow [these instructions](https://help.github.com/articles/creating-a-pull-request-from-a-fork)
to create a pull request from your fork. This will send an email to the committers.

(If any of the above seems like magic to you, please look up the
[Git documentation](https://git-scm.com/documentation) on the web, or ask a friend or another contributor for help.)

### Pull Request Checklist

We recommended that your contribution complies with the
following rules before you submit a pull request:

- Follow the PEP8 Guidelines.

- If your pull request addresses an issue, please use the pull request title
to describe the issue and mention the issue number in the pull request description.
This will make sure a link back to the original issue is created.

- All public methods should have informative docstrings with sample
usage presented as doctests when appropriate.

- Please prefix the title of your pull request with `[MRG]` (Ready for
Merge), if the contribution is complete and ready for a detailed review.
An incomplete contribution -- where you expect to do more work before
receiving a full review -- should be prefixed `[WIP]` (to indicate a work
in progress) and changed to `[MRG]` when it matures. WIPs may be useful
to: indicate you are working on something to avoid duplicated work,
request broad review of functionality or API, or seek collaborators.
WIPs often benefit from the inclusion of a
[task list](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments)
in the PR description.

- When adding additional functionality, provide at least one
example script in the ``tslearn/docs/examples/`` folder. Have a look at other
examples for reference. Examples should demonstrate why the new
functionality is useful in practice and, if possible, compare it
to other methods available in tslearn.

- Documentation and high-coverage tests are necessary for enhancements to be
accepted. Bug-fixes or new features should be provided with
[non-regression tests](https://en.wikipedia.org/wiki/Non-regression_testing).
These tests verify the correct behavior of the fix or feature. In this
manner, further modifications on the code base are granted to be consistent
with the desired behavior.
For the Bug-fixes case, at the time of the PR, this tests should fail for
the code base in master and pass for the PR code.

- At least one paragraph of narrative documentation with links to
references in the literature (with PDF links when possible) and
the example.

You can also check for common programming errors with the following
tools:


- No pyflakes warnings, check with:

```bash
$ pip install pyflakes
$ pyflakes path/to/module.py
```

- No PEP8 warnings, check with:

```bash
$ pip install pep8
$ pep8 path/to/module.py
```

- AutoPEP8 can help you fix some of the easy redundant errors:

```bash
$ pip install autopep8
$ autopep8 path/to/pep8.py
```

Bonus points for contributions that include a performance analysis with
a benchmark script and profiling output (please report on the mailing
list or on the GitHub issue).
22 changes: 9 additions & 13 deletions README.md
Expand Up @@ -43,28 +43,24 @@ Using `pip` should also work fine:
pip install tslearn
```

In this case, you should have `numpy`, `cython` and C++ build tools available
at build time.

## Using latest github-hosted version

If you want to get `tslearn`'s latest version, you can refer to the repository hosted at github:
If you want to get `tslearn`'s latest version, you can refer to the repository
hosted at github:
```bash
pip install git+https://github.com/rtavenar/tslearn.git
```

## Troubleshooting

It seems on some platforms `Cython` dependency does not install properly.
If you experiment such an issue, try installing it with the following command:

```bash
pip install cython
```

before you start installing `tslearn`.
If it still does not work, we suggest you switch to `conda` installation.
In this case, you should have `numpy`, `cython` and C++ build tools available
at build time.

# Documentation and API reference

The documentation, including a gallery of examples, is hosted at [readthedocs](http://tslearn.readthedocs.io/en/latest/index.html).
The documentation, including a gallery of examples, is hosted at
[readthedocs](http://tslearn.readthedocs.io/en/latest/index.html).

# Already available

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -6,3 +6,4 @@ scikit-learn
joblib>=0.12
tensorflow<2
keras
h5py
2 changes: 1 addition & 1 deletion requirements_rtd.txt
Expand Up @@ -8,7 +8,7 @@ ipykernel
nbsphinx
sphinx-gallery
pillow
tensorflow
tensorflow<2
keras
Pygments
numba
Expand Down
4 changes: 2 additions & 2 deletions setup.py
@@ -1,4 +1,4 @@
from setuptools import setup
from setuptools import setup, find_packages
from codecs import open
import numpy
import os
Expand All @@ -22,7 +22,7 @@
long_description=README,
long_description_content_type='text/markdown',
include_dirs=[numpy.get_include()],
packages=['tslearn'],
packages=find_packages(),
package_data={"tslearn": [".cached_datasets/Trace.npz"]},
data_files=[("", ["LICENSE"])],
install_requires=['numpy', 'scipy', 'scikit-learn', 'Cython', 'numba',
Expand Down
2 changes: 1 addition & 1 deletion tslearn/__init__.py
@@ -1,7 +1,7 @@
import os

__author__ = 'Romain Tavenard romain.tavenard[at]univ-rennes2.fr'
__version__ = "0.2.3"
__version__ = "0.2.5"
__bibtex__ = r"""@misc{tslearn,
title={tslearn: A machine learning toolkit dedicated to time-series data},
author={Tavenard, Romain and Faouzi, Johann and Vandewiele, Gilles},
Expand Down