Skip to main content

mlrose-ky: Machine Learning, Randomized Optimization, and SEarch

PyPI Version Codacy Badge Codacy Badge wakatime

mlrose-ky is a Python package for applying some of the most common randomized optimization and search algorithms to a range of different optimization problems, over both discrete- and continuous-valued parameter spaces.

Project Background

mlrose-ky is a fork of the mlrose-hiive repository, which itself was a fork of the original mlrose repository.

The original mlrose was developed to support students of Georgia Tech's OMSCS/OMSA offering of CS 7641: Machine Learning.

Later, mlrose-hiive introduced a number of improvements (for example, the Runners submodule) and bug fixes on top of mlrose, though it lacked documentation, contained some mysterious bugs and inefficiencies, and was unmaintained as of around 2022.

Today, mlrose-ky introduces additional improvements and bug fixes on top of mlrose-hiive. Some of these improvements include:

  • Added documentation to every class, method, and function (i.e., descriptive docstrings, strong type-hints, and comments)
  • New documentation available here: https://nkapila6.github.io/mlrose-ky/
  • Increased test coverage from ~5% to ~99% (and still aiming for 100% coverage)
  • Actively being maintained
  • Fully backwards compatible with mlrose-hiive
  • Optimized Python code with NumPy vectorization

Main Features

This repository includes implementations of all randomized optimization algorithms taught in the course, as well as functionality to apply these algorithms to integer-string optimization problems, such as N-Queens and the Knapsack problem; continuous-valued optimization problems, such as the neural network weight problem; and tour optimization problems, such as the Travelling Salesperson problem. It also has the flexibility to solve user-defined optimization problems.

Randomized Optimization Algorithms

  • Implementations of: hill climbing, randomized hill climbing, simulated annealing, genetic algorithm, and (discrete) MIMIC;
  • Solve both maximization and minimization problems;
  • Define the algorithm's initial state or start from a random state;
  • Define your own simulated annealing decay schedule or use one of three pre-defined, customizable decay schedules: geometric decay, arithmetic decay, or exponential decay.

Problem Types

  • Solve discrete-value (bit-string and integer-string), continuous-value, and tour optimization (travelling salesperson) problems;
  • Define your own fitness function for optimization or use a pre-defined function.
  • Pre-defined fitness functions exist for solving the: One Max, Flip Flop, Four Peaks, Six Peaks, Continuous Peaks, Knapsack, Travelling Salesperson, N-Queens, and Max-K Color optimization problems.

Machine Learning Weight Optimization

  • Optimize the weights of neural networks, linear regression models, and logistic regression models using randomized hill climbing, simulated annealing, the genetic algorithm, or gradient descent;
  • Supports classification and regression neural networks.

Project Improvements and Updates

The mlrose-ky project is undergoing significant improvements to enhance code quality, documentation, and testing. Below is a list of tasks that have been completed or are in progress:

  1. Fix Python Warnings and Errors: All Python warnings and errors have been addressed, except for a few unavoidable ones like "duplicate code." ✅

  2. Add Python 3.10 Type Hints: Type hints are being added to all function and method definitions, as well as method properties ( e.g., self.foo: str = 'bar'), to improve code clarity and maintainability. ✅

  3. Enhance Documentation: NumPy-style docstrings are being added to all functions and methods, with at least a one-line docstring at the top of every file summarizing its contents. This will make the codebase more understandable and easier to use for others. ✅

  4. Increase Test Coverage: Tests are being added using Pytest, with a goal of achieving 100% code coverage to ensure the robustness of the codebase. ✅

  5. Resolve TODO/FIXME Comments: A thorough search is being conducted for any TODO, FIXME, or similar comments, and their respective issues are being resolved. ✅

  6. Optimize Code: Vanilla Python loops are being optimized where possible by vectorizing them with NumPy to enhance performance.

  7. Improve Code Quality: Any other sub-optimal code, bugs, or code quality issues are being addressed to ensure a high standard of coding practices. ✅

  8. Clean Up Codebase: All commented-out code is being removed to keep the codebase clean and maintainable. ✅

Installation

mlrose-ky was written in Python 3 and requires NumPy, SciPy, and Scikit-Learn (sklearn).

The latest version can be installed using pip:

pip install mlrose-ky --upgrade

Once it is installed, simply import it like so:

import mlrose_ky as mlrose

Documentation

The official mlrose-ky documentation can be found here.

A Jupyter notebook containing the examples used in the documentation is also available here.

Licensing, Authors, Acknowledgements

mlrose-ky was forked from the mlrose-hiive repository, which was a fork of the original mlrose repository.

The original mlrose was written by Genevieve Hayes and is distributed under the 3-Clause BSD license.

You can cite mlrose-ky in research publications and reports as follows:

Please also keep the original authors' citations:

  • Rollings, A. (2020). mlrose: Machine Learning, Randomized Optimization and SEarch package for Python, hiive extended remix. https://github.com/hiive/mlrose. Accessed: day month year.
  • Hayes, G. (2019). mlrose: Machine Learning, Randomized Optimization and SEarch package for Python. https://github.com/gkhayes/mlrose. Accessed: day month year.

Thanks to David S. Park for the MIMIC enhancements (from https://github.com/parkds/mlrose).

BibTeX entries:

@misc{Nakamura24,
    author = {Nakamura, K.},
    title = {{mlrose-ky: Machine Learning, Randomized Optimization and SEarch package for Python}},
    year = 2024,
    howpublished = {\url{https://github.com/knakamura13/mlrose-ky/}},
    note = {Accessed: day month year}
}

@misc{Rollings20,
    author = {Rollings, A.},
    title = {{mlrose: Machine Learning, Randomized Optimization and SEarch package for Python, hiive extended remix}},
    year = 2020,
    howpublished = {\url{https://github.com/hiive/mlrose/}},
    note = {Accessed: day month year}
}

@misc{Hayes19,
    author = {Hayes, G.},
    title = {{mlrose: Machine Learning, Randomized Optimization and SEarch package for Python}},
    year = 2019,
    howpublished = {\url{https://github.com/gkhayes/mlrose/}},
    note = {Accessed: day month year}
}

Collaborators

nkapila6
Nikhil Kapila
knakamura13
Kyle Nakamura
gitongah
Edwin Mbaabu

Contributors

knakamura13
Kyle Nakamura
hiive
hiive
gkhayes
Dr Genevieve Hayes
ChristopherBilg
Chris Bilger
nkapila6
Nikhil Kapila
gitongah
Edwin Mbaabu
Agrover112
Agrover112
domfrecent
Dominic Frecentese
harrisonfloam
harrisonfloam
AlexWendland
Alex Wendland
cooknl
CAPN
KevinJBoyer
Kevin Boyer
parkds
David
davideasaf
David Asaf
jfs42
Jason Seeley
sareini
Muhammad Sareini
nibelungvalesti
nibelungvalesti
tadmorgan
W. Tad Morgan
mjschock
Michael Schock
jlm429
John Mansfield
dstrube1
David Strube
austin-bowen
Austin Bowen
bspivey
Ben Spivey
dreadn0ught
David
brokensandals
Jacob Williams
vpipkt
Jason T Brown
zerolinux5
Jesus Magana
ksbeattie
Keith Beattie
MatthewCaseres
Matthew Caseres
cbhyphen
cbhyphen
dsctt
Daniel Scott
wyang36
Kira Yang

Metadata

Release files for mlrose-ky 1.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlrose-ky 1.1.6
File Size Uploaded Provenance Actions
mlrose_ky-1.1.6.tar.gz 86.7 kB Without provenance Details for mlrose_ky-1.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mlrose-ky 1.1.6
File Interpreter ABI Platform Actions
mlrose_ky-1.1.6-py3-none-any.whl Python 3 none any Details for mlrose_ky-1.1.6-py3-none-any.whl

Total release size: 225.6 kB

Release files / mlrose_ky-1.1.6.tar.gz

Download URL mlrose_ky-1.1.6.tar.gz
Size 86.7 kB
Tags Source
SHA-256 checksum
How to use checksums
50a7e2fec9ca6c64418809185acf96aa220d4c62ae8d67519a30bd281dcc7758
BLAKE2b-256 checksum
How to use checksums
d912db9f576553caa2df5b435a8e941ff29426c199e5aaee28b6967a97d4682a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release files / mlrose_ky-1.1.6-py3-none-any.whl

Download URL mlrose_ky-1.1.6-py3-none-any.whl
Size 138.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a17b7740ca3d6487ade235f683cb7bb898c567bb77adbccba909cae347411ee0
BLAKE2b-256 checksum
How to use checksums
704215468ac78cebe768284a05b397f4540f2790de30891182097f7df88b53c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Security for mlrose-ky 1.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page