1- Random Fourier Features
2- ====================================================================================================
3-
41<div align =" center " >
52 <img src =" ./figures/logo_long.svg " width =" 480 " alt =" rfflearn logo " />
63</div >
74
5+ <div align =" center " >
6+ <img src =" https://img.shields.io/badge/PYTHON-%3E%3D3.9-blue.svg?logo=python&logoColor=white " >
7+   ;
8+ <img src =" https://img.shields.io/badge/LICENSE-MIT-orange.svg " >
9+   ;
10+ <img src =" https://img.shields.io/badge/COVERAGE-97%25-green.svg " >
11+   ;
12+ <img src =" https://img.shields.io/badge/QUALITY-9.96/10.0-yellow.svg " >
13+ </div >
14+
15+
16+ Random Fourier Features
17+ ====================================================================================================
18+
819This repository provides the Python module ` rfflearn ` which is a Python library of random Fourier
920features (hereinafter abbreviated as RFF) [ 1, 2] for kernel methods, like support vector
1021machine [ 3, 4] and Gaussian process model [ 5] . Features of this module are:
@@ -36,6 +47,34 @@ The author will provide implementations of the other algorithms soon.
3647
3748** NOTE** : The author confirmed that the ` rfflearn ` module works on PyTorch 2.0! :tada :
3849
50+
51+ Installation
52+ ----------------------------------------------------------------------------------------------------
53+
54+ Please install from PyPI.
55+
56+ ``` shell
57+ pip install rfflearn
58+ ```
59+
60+ If you need GPU support, Optuna support or SHAP support,
61+ you need to install the following packages.
62+
63+ ``` shell
64+ # For GPU support.
65+ pip install torch
66+
67+ # For Optuna support.
68+ pip install optuna
69+
70+ # For SHAP support.
71+ pip install matplotlib shap
72+ ```
73+
74+ The author recommends using [ venv] ( https://docs.python.org/3/library/venv.html ) or
75+ [ Docker] ( https://www.docker.com/ ) to avoid polluting your environment.
76+
77+
3978Minimal example
4079----------------------------------------------------------------------------------------------------
4180
@@ -109,24 +148,55 @@ the California housing dataset, and the followings are the visualization results
109148` rfflearn.shap_feature_importance ` and ` rfflearn.permutation_feature_importance ` .
110149
111150<div align =" center " >
112- <img src =" ./examples/feature_importances_for_california_housing/figure_california_housing_shap_importance.png " width =" 400 " alt =" Permutation importances of Boston housing dataset " />
113- <img src =" ./examples/feature_importances_for_california_housing/figure_california_housing_permutation_importance.png " width =" 400 " alt =" SHAP importances of Boston housing dataset " />
151+ <img src =" ./examples/feature_importances_for_california_housing/figures/ figure_california_housing_shap_importance.png " width =" 450 " alt =" Permutation importances of Boston housing dataset " />
152+ <img src =" ./examples/feature_importances_for_california_housing/figures/ figure_california_housing_permutation_importance.png " width =" 450 " alt =" SHAP importances of Boston housing dataset " />
114153</div >
115154
116155
117- Requirements and installation
156+ Quick Tutorial
118157----------------------------------------------------------------------------------------------------
119158
120- The author recommends using a docker image for building the environment for the ` rfflearn ` ,
121- however, of course, you can install the necessary packages on your environment directly.
122- See [ SETUP.md] ( ./SETUP.md ) for more details.
159+ At first, please clone the ` random-fourier-features ` repository from GitHub:
160+
161+ ``` console
162+ git clone https://github.com/tiskw/random-fourier-features.git
163+ cd random-fourier-features
164+ ```
165+
166+ If you are using the docker image, enter into the docker container by the following command
167+ (not necessary to run thw following if you don't use docker):
168+
169+ ``` console
170+ docker run --rm -it --gpus all -v `pwd`:/work -w /work -u `id -u`:`id -g` tiskw/pytorch:latest bash
171+ ```
172+
173+ Then, launch python3 and try the following minimal code that runs support vector classification
174+ with random Fourier features on an artificial tiny dataset.
175+
176+ ``` python
177+ >> > import numpy as np # Import Numpy
178+ >> > import rfflearn.cpu as rfflearn # Import our module
179+ >> > X = np.array([[- 1 , - 1 ], [- 2 , - 1 ], [1 , 1 ], [2 , 1 ]]) # Define input data
180+ >> > y = np.array([1 , 1 , 2 , 2 ]) # Defile label data
181+ >> > svc = rfflearn.RFFSVC().fit(X, y) # Training
182+ >> > svc.score(X, y) # Inference (on CPU)
183+ 1.0
184+ >> > svc.predict(np.array([[- 0.8 , - 1 ]]))
185+ array([1 ])
186+ ```
187+
188+ ### Next Step
189+
190+ Now you succeeded in installing the ` rfflearn ` module.
191+ The author's recommendation for the next step is to see the [ examples directory] ( /examples )
192+ and try a code you are interested in.
123193
124194
125195Notes
126196----------------------------------------------------------------------------------------------------
127197
128- - The name of this module is changed from ` pyrff ` to ` rfflearn ` on Oct 2020, because the package name
129- ` pyrff ` already exists in PyPI.
198+ - The name of this module is changed from ` pyrff ` to ` rfflearn ` on Oct 2020, because the package
199+ name ` pyrff ` already exists in PyPI.
130200- If the number of training data is huge, an error message like `RuntimeError: The task could not be
131201 sent to the workers as it is too large for 'send_bytes'` will be raised from the joblib library.
132202 The reason for this error is that the ` sklearn.svm.LinearSVC ` uses ` joblib ` as a multiprocessing
@@ -142,7 +212,8 @@ Notes
142212License
143213----------------------------------------------------------------------------------------------------
144214
145- [ MIT Licence] ( https://opensource.org/licenses/mit-license.php )
215+ This software is distributed under the [ MIT Licence] ( https://opensource.org/licenses/mit-license.php ) .
216+ See [ LICENSE] ( ./LICENSE ) for more information.
146217
147218
148219Reference
0 commit comments