{"id":13474659,"url":"https://github.com/ddbourgin/numpy-ml","last_synced_at":"2025-05-12T13:18:50.405Z","repository":{"id":40614182,"uuid":"179893494","full_name":"ddbourgin/numpy-ml","owner":"ddbourgin","description":"Machine learning, in numpy","archived":false,"fork":false,"pushed_at":"2023-10-29T00:53:03.000Z","size":10514,"stargazers_count":16087,"open_issues_count":38,"forks_count":3802,"subscribers_count":458,"default_branch":"master","last_synced_at":"2025-05-12T13:18:31.174Z","etag":null,"topics":["attention","bayesian-inference","gaussian-mixture-models","gaussian-processes","good-turing-smoothing","gradient-boosting","hidden-markov-models","knn","lstm","machine-learning","mfcc","neural-networks","reinforcement-learning","resnet","topic-modeling","vae","wavenet","wgan-gp","word2vec"],"latest_commit_sha":null,"homepage":"https://numpy-ml.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddbourgin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-04-06T22:29:49.000Z","updated_at":"2025-05-12T09:56:27.000Z","dependencies_parsed_at":"2024-01-16T15:43:33.613Z","dependency_job_id":"a6ab9550-01ba-41c0-9b88-1e846ac96f39","html_url":"https://github.com/ddbourgin/numpy-ml","commit_stats":{"total_commits":315,"total_committers":17,"mean_commits":"18.529411764705884","dds":0.3841269841269841,"last_synced_commit":"b0359af5285fbf9699d64fd5ec059493228af03e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddbourgin%2Fnumpy-ml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddbourgin%2Fnumpy-ml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddbourgin%2Fnumpy-ml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddbourgin%2Fnumpy-ml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddbourgin","download_url":"https://codeload.github.com/ddbourgin/numpy-ml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745196,"owners_count":21957319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attention","bayesian-inference","gaussian-mixture-models","gaussian-processes","good-turing-smoothing","gradient-boosting","hidden-markov-models","knn","lstm","machine-learning","mfcc","neural-networks","reinforcement-learning","resnet","topic-modeling","vae","wavenet","wgan-gp","word2vec"],"created_at":"2024-07-31T16:01:13.874Z","updated_at":"2025-05-12T13:18:50.372Z","avatar_url":"https://github.com/ddbourgin.png","language":"Python","readme":"# numpy-ml\nEver wish you had an inefficient but somewhat legible collection of machine\nlearning algorithms implemented exclusively in NumPy? No?\n\n## Installation\n\n### For rapid experimentation\nTo use this code as a starting point for ML prototyping / experimentation, just clone the repository, create a new [virtualenv](https://pypi.org/project/virtualenv/), and start hacking:\n\n```sh\n$ git clone https://github.com/ddbourgin/numpy-ml.git\n$ cd numpy-ml \u0026\u0026 virtualenv npml \u0026\u0026 source npml/bin/activate\n$ pip3 install -r requirements-dev.txt\n```\n\n### As a package\nIf you don't plan to modify the source, you can also install numpy-ml as a\nPython package: `pip3 install -u numpy_ml`.\n\nThe reinforcement learning agents train on environments defined in the [OpenAI\ngym](https://github.com/openai/gym). To install these alongside numpy-ml, you\ncan use `pip3 install -u 'numpy_ml[rl]'`.\n\n## Documentation\nFor more details on the available models, see the [project documentation](https://numpy-ml.readthedocs.io/).\n\n## Available models\n\u003cdetails\u003e\n  \u003csummary\u003eClick to expand!\u003c/summary\u003e\n\n1. **Gaussian mixture model**\n    - EM training\n\n2. **Hidden Markov model**\n    - Viterbi decoding\n    - Likelihood computation\n    - MLE parameter estimation via Baum-Welch/forward-backward algorithm\n\n3. **Latent Dirichlet allocation** (topic model)\n    - Standard model with MLE parameter estimation via variational EM\n    - Smoothed model with MAP parameter estimation via MCMC\n\n4. **Neural networks**\n    * Layers / Layer-wise ops\n        - Add\n        - Flatten\n        - Multiply\n        - Softmax\n        - Fully-connected/Dense\n        - Sparse evolutionary connections\n        - LSTM\n        - Elman-style RNN\n        - Max + average pooling\n        - Dot-product attention\n        - Embedding layer\n        - Restricted Boltzmann machine (w. CD-n training)\n        - 2D deconvolution (w. padding and stride)\n        - 2D convolution (w. padding, dilation, and stride)\n        - 1D convolution (w. padding, dilation, stride, and causality)\n    * Modules\n        - Bidirectional LSTM\n        - ResNet-style residual blocks (identity and convolution)\n        - WaveNet-style residual blocks with dilated causal convolutions\n        - Transformer-style multi-headed scaled dot product attention\n    * Regularizers\n        - Dropout\n    * Normalization\n        - Batch normalization (spatial and temporal)\n        - Layer normalization (spatial and temporal)\n    * Optimizers\n        - SGD w/ momentum\n        - AdaGrad\n        - RMSProp\n        - Adam\n    * Learning Rate Schedulers\n        - Constant\n        - Exponential\n        - Noam/Transformer\n        - Dlib scheduler\n    * Weight Initializers\n        - Glorot/Xavier uniform and normal\n        - He/Kaiming uniform and normal\n        - Standard and truncated normal\n    * Losses\n        - Cross entropy\n        - Squared error\n        - Bernoulli VAE loss\n        - Wasserstein loss with gradient penalty\n        - Noise contrastive estimation loss\n    * Activations\n        - ReLU\n        - Tanh\n        - Affine\n        - Sigmoid\n        - Leaky ReLU\n        - ELU\n        - SELU\n        - GELU\n        - Exponential\n        - Hard Sigmoid\n        - Softplus\n    * Models\n        - Bernoulli variational autoencoder\n        - Wasserstein GAN with gradient penalty\n        - word2vec encoder with skip-gram and CBOW architectures\n    * Utilities\n        - `col2im` (MATLAB port)\n        - `im2col` (MATLAB port)\n        - `conv1D`\n        - `conv2D`\n        - `deconv2D`\n        - `minibatch`\n\n5. **Tree-based models**\n    - Decision trees (CART)\n    - [Bagging] Random forests\n    - [Boosting] Gradient-boosted decision trees\n\n6. **Linear models**\n    - Ridge regression\n    - Logistic regression\n    - Ordinary least squares\n    - Weighted linear regression\n    - Generalized linear model (log, logit, and identity link)\n    - Gaussian naive Bayes classifier\n    - Bayesian linear regression w/ conjugate priors\n        - Unknown mean, known variance (Gaussian prior)\n        - Unknown mean, unknown variance (Normal-Gamma / Normal-Inverse-Wishart prior)\n\n7. **n-Gram sequence models**\n    - Maximum likelihood scores\n    - Additive/Lidstone smoothing\n    - Simple Good-Turing smoothing\n\n8. **Multi-armed bandit models**\n    - UCB1\n    - LinUCB\n    - Epsilon-greedy\n    - Thompson sampling w/ conjugate priors\n        - Beta-Bernoulli sampler\n    - LinUCB\n\n8. **Reinforcement learning models**\n    - Cross-entropy method agent\n    - First visit on-policy Monte Carlo agent\n    - Weighted incremental importance sampling Monte Carlo agent\n    - Expected SARSA agent\n    - TD-0 Q-learning agent\n    - Dyna-Q / Dyna-Q+ with prioritized sweeping\n\n9. **Nonparameteric models**\n    - Nadaraya-Watson kernel regression\n    - k-Nearest neighbors classification and regression\n    - Gaussian process regression\n\n10. **Matrix factorization**\n    - Regularized alternating least-squares\n    - Non-negative matrix factorization\n\n11. **Preprocessing**\n    - Discrete Fourier transform (1D signals)\n    - Discrete cosine transform (type-II) (1D signals)\n    - Bilinear interpolation (2D signals)\n    - Nearest neighbor interpolation (1D and 2D signals)\n    - Autocorrelation (1D signals)\n    - Signal windowing\n    - Text tokenization\n    - Feature hashing\n    - Feature standardization\n    - One-hot encoding / decoding\n    - Huffman coding / decoding\n    - Byte pair encoding / decoding\n    - Term frequency-inverse document frequency (TF-IDF) encoding\n    - MFCC encoding\n\n12. **Utilities**\n    - Similarity kernels\n    - Distance metrics\n    - Priority queue\n    - Ball tree\n    - Discrete sampler\n    - Graph processing and generators\n\u003c/details\u003e\n\n## Contributing\n\nAm I missing your favorite model? Is there something that could be cleaner /\nless confusing? Did I mess something up? Submit a PR! The only requirement is\nthat your models are written with just the [Python standard\nlibrary](https://docs.python.org/3/library/) and [NumPy](https://www.numpy.org/). The\n[SciPy library](https://scipy.github.io/devdocs/) is also permitted under special\ncircumstances ;)\n\nSee full contributing guidelines [here](./CONTRIBUTING.md).\n","funding_links":[],"categories":["Tutorials","Python","Machine Learning","深度学习大类","Data Science","Repos","Ecosystem"],"sub_categories":["Tools Guidance","3. Coding","通识教程","Machine Learning","General-Purpose Machine Learning","AI/ML"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddbourgin%2Fnumpy-ml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddbourgin%2Fnumpy-ml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddbourgin%2Fnumpy-ml/lists"}