-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add transformer base class and adapt preprocessor / converter to fit + apply #4285
Merged
vigsterkr
merged 61 commits into
shogun-toolbox:feature/transformers
from
vinx13:feature/transformers
May 30, 2018
Merged
Changes from 57 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
c4d77f9
Add transformer base class
vinx13 bf42a2b
Make converter and preprocessor subclasses of transformer
vinx13 5f838b6
Cleanup dense preprocessors and rename init to fit
vinx13 76eb698
Cleanup string preprocessors and rename init to fit
vinx13 5ff86f3
Cleanup pca preprocessors and rename init to fit
vinx13 c898878
Cleanup and rename api in DependenceMaximization
vinx13 73bc7ec
Update meta examples using 'fit' api
vinx13 3168500
Update FisherLDA api
vinx13 140c8c2
Update doc of FisherLDA
vinx13 8c0cb93
Cleanup preprocessors
vinx13 5b48af8
Cleanup preprocessors
vinx13 03b6061
Add transformer to swig
vinx13 521d12c
Add transformer::apply(features, inplace) api
vinx13 5cdd269
Adapt python examples to new transformer api
vinx13 cd738f9
Fix indent in python examples
vinx13 4c57338
Deprecate densepreproc old api add apply_to_matrix
vinx13 7c4ace0
Cleanup and implement apply_to_matrix in dense preproc subclasses
vinx13 62dc621
Cleanup and refactor PCA and FisherLDA
vinx13 ff8fd5f
Remove DimensionReductionPreprocessor
vinx13 a423241
Implement apply in kernel pca
vinx13 04c0884
Fix swig
vinx13 49e9f25
Split template implementation of string preproc
vinx13 5ecf291
Implement apply api in string preproc, deprecate apply_to_string_feat…
vinx13 8cd24e3
Implement apply in sparse preproc
vinx13 715bdb7
Use fwd declaration
vinx13 3d72162
Drop DimensionReductionPreproc in python example
vinx13 0072350
Unref input features in transformer::apply
vinx13 74117e7
Fix wrong index in LogPlusOne
vinx13 2aa1a47
Fix string preprocessor
vinx13 c11da19
Fix refcount bug
vinx13 0913587
Update meta example using transformer::apply
vinx13 b921804
Register params in PCA / KernelPCA
vinx13 e5850f0
Fix ref count in DensePreproc
vinx13 bfac72e
Fix wrong index in RandomFourierGaussPreproc
vinx13 05b98ea
Update tests using transformer::apply
vinx13 ae55c2a
Fix ref count
vinx13 9f94402
Throw error in out-of-place mode in sparse preproc
vinx13 f18664e
Update doc of transformers
vinx13 4f486a6
Refactor ICA converters into fit + apply
vinx13 cf2904c
Some-ize and use fit / apply api in tests and meta examples of ica
vinx13 2c4b067
Use transformer::apply in unit tests
vinx13 34a7958
Some-ize PCA test
vinx13 7f9ca1a
Don't create new features instance in StringPreproc
vinx13 069df5d
Some-ize unittests
vinx13 c30e7e6
Apply formatter
vinx13 a83ee08
Fix ica converters
vinx13 3dc409e
Don't ref the result features in preproc
vinx13 2bfc4b5
Some-ize lars unittests to fix ref count
vinx13 e7ed858
Fix indent
vinx13 e52712e
Use std min/max instead of cmath
vinx13 2e7a488
Use better var name in meta example
vinx13 560cc99
Minor codestyle improvement
vinx13 88aa5a5
Fix PruneVarSubMean
vinx13 4793cf4
Convert to dense feats in ica base class
vinx13 aaeea9b
Use 'override' in preproc
vinx13 fc49cd2
Use std::copy
vinx13 f0a29c1
Remove 'override' as inconsistent override cause many warnings
vinx13 b927fc1
Fix style
vinx13 26e5224
Rename transformer::apply -> transform
vinx13 2937f88
Fix transformer rename in swig
vinx13 8493511
Add %newobject to transformer in swig
vinx13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 18 additions & 19 deletions
37
examples/undocumented/python/converter_locallylinearembedding.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
#!/usr/bin/env python | ||
data = '../data/fm_train_real.dat' | ||
parameter_list = [[data,20],[data,30]] | ||
from tools.load import LoadMatrix | ||
|
||
def converter_locallylinearembedding (data_fname,k): | ||
try: | ||
from shogun import RealFeatures, CSVFile | ||
try: | ||
from shogun import LocallyLinearEmbedding | ||
except ImportError: | ||
print("LocallyLinearEmbedding not available") | ||
exit(0) | ||
lm=LoadMatrix() | ||
data = lm.load_numbers('../data/fm_train_real.dat') | ||
|
||
features = RealFeatures(CSVFile(data_fname)) | ||
parameter_list = [[data, 20], [data, 30]] | ||
|
||
converter = LocallyLinearEmbedding() | ||
converter.set_target_dim(1) | ||
converter.set_k(k) | ||
converter.apply(features) | ||
def converter_locallylinearembeeding (data, k): | ||
from shogun import RealFeatures | ||
from shogun import LocallyLinearEmbedding | ||
|
||
features = RealFeatures(data) | ||
|
||
converter = LocallyLinearEmbedding() | ||
converter.set_k(k) | ||
|
||
converter.fit(features) | ||
features = converter.apply(features) | ||
|
||
return features | ||
|
||
return features | ||
except ImportError: | ||
print('No Eigen3 available') | ||
|
||
if __name__=='__main__': | ||
print('LocallyLinearEmbedding') | ||
converter_locallylinearembedding(*parameter_list[0]) | ||
converter_locallylinearembeeding(*parameter_list[0]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
examples/undocumented/python/preprocessor_dimensionreductionpreprocessor.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new API here!