Coder Social home page Coder Social logo

joshloyal / sliced Goto Github PK

View Code? Open in Web Editor NEW
19.0 1.0 11.0 3.99 MB

sliced: scikit-learn compatible sufficient dimension reduction

Home Page: https://joshloyal.github.io/sliced/

License: MIT License

Python 72.83% Jupyter Notebook 23.03% Shell 3.92% Makefile 0.22%
machine-learning machine-learning-algorithms dimension-reduction dimensionality-reduction feature-selection variable-selection python sufficient-dimension-reduction

sliced's Introduction

Travis AppVeyor Coveralls CircleCI License

sliced

sliced is a python package offering a number of sufficient dimension reduction (SDR) techniques commonly used in high-dimensional datasets with a supervised target. It is compatible with scikit-learn.

Algorithms supported:

  • Sliced Inverse Regression (SIR) [1]
  • Sliced Average Variance Estimation (SAVE) [2]

Documentation / Website: https://joshloyal.github.io/sliced/

Example

Example that shows how to learn a one dimensional subspace from a dataset with ten features:

from sliced.datasets import make_cubic
from sliced import SlicedInverseRegression

# load the 10-dimensional dataset
X, y = make_cubic(random_state=123)

# Set the options for SIR
sir = SlicedInverseRegression(n_directions=1)

# fit the model
sir.fit(X, y)

# transform into the new subspace
X_sir = sir.transform(X)

Installation

Dependencies

sliced requires:

  • Python (>= 2.7 or >= 3.4)
  • NumPy (>= 1.8.2)
  • SciPy (>= 0.13.3)
  • Scikit-learn (>=0.17)

Additionally, to run examples, you need matplotlib(>=2.0.0).

Installation

You need a working installation of numpy and scipy to install sliced. If you have a working installation of numpy and scipy, the easiest way to install sliced is using pip:

pip install -U sliced

If you prefer, you can clone the repository and run the setup.py file. Use the following commands to get the copy from GitHub and install all the dependencies:

git clone https://github.com/joshloyal/sliced.git
cd sliced
pip install .

Or install using pip and GitHub:

pip install -U git+https://github.com/joshloyal/sliced.git

Testing

After installation, you can use pytest to run the test suite via setup.py:

python setup.py test

References:

[1]: Li, K C. (1991) "Sliced Inverse Regression for Dimension Reduction (with discussion)", Journal of the American Statistical Association, 86, 316-342.
[2]: Shao, Y, Cook, RD and Weisberg, S (2007). "Marginal Tests with Sliced Average Variance Estimation", Biometrika, 94, 285-296.

sliced's People

Contributors

joshloyal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

sliced's Issues

AttributeError: module 'numpy' has no attribute 'int'. `np.int` was a deprecated alias for the builtin `int`

I was trying to run this sir.fit(X, Y) and ran into the above issue with numpy 1.24

It looks like an easy fix to swap line 119 of base.py to one of the following:
slice_indicator = np.ones(y.shape[0], dtype=int)
slice_indicator = np.ones(y.shape[0], dtype=int32)
slice_indicator = np.ones(y.shape[0], dtype=int64)

Full AttributeError:

AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.