{"id":22019081,"url":"https://github.com/melvin-klein/algosto","last_synced_at":"2026-02-13T23:31:46.711Z","repository":{"id":260092233,"uuid":"880242194","full_name":"Melvin-klein/algosto","owner":"Melvin-klein","description":"A Python package that includes various stochastic algorithms.","archived":false,"fork":false,"pushed_at":"2025-03-22T15:16:15.000Z","size":2497,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-09-30T01:26:56.876Z","etag":null,"topics":["stochastic","stochastic-gradient-descent","stochastic-optimization"],"latest_commit_sha":null,"homepage":"https://www.algosto.dev","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Melvin-klein.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-29T11:31:55.000Z","updated_at":"2024-11-28T23:26:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"a7b33d58-3a15-44e1-bea6-e2d7cb8f6194","html_url":"https://github.com/Melvin-klein/algosto","commit_stats":null,"previous_names":["melvin-klein/algosto"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/Melvin-klein/algosto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Melvin-klein%2Falgosto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Melvin-klein%2Falgosto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Melvin-klein%2Falgosto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Melvin-klein%2Falgosto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Melvin-klein","download_url":"https://codeload.github.com/Melvin-klein/algosto/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Melvin-klein%2Falgosto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29423534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T22:20:51.549Z","status":"ssl_error","status_checked_at":"2026-02-13T22:20:49.838Z","response_time":78,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["stochastic","stochastic-gradient-descent","stochastic-optimization"],"created_at":"2024-11-30T05:15:41.367Z","updated_at":"2026-02-13T23:31:46.684Z","avatar_url":"https://github.com/Melvin-klein.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Algosto : May randomness be with you\n\nAlgosto, from the concatenation of french words *Algorithmes Stochastiques (/al.ɡo.ʁitm stɔ.kas.tik/)*, \nis a Python package built on top of *NumPy* that provides implementations of various stochastic algorithms.\n\nThe full documentation is available [here](https://www.algosto.dev).\n\n## Installation\n\nYou can install Algosto with:\n\n    pip install algosto\n\n## Usage\n\nThis section shows an example on how Algosto works by applying the\nstochastic gradient descent algorithm (SGD) to a quadratic function.\n\n### Workflow\n\nThe basic workflow needs four elements :\n\n**An objective function :** This is the function we want to minimize.\n    It is a Python function that takes a numpy matrix `(n, d)`,\n    where `n` is the number of points to handle and `d` is the dimension of points,\n    and returns a result vector of length `n`.\n\n**A constraint :** It is an object that defines the space in which the solver will optimize the function.\n    Obviously, the objective function needs to be defined on this space.\n\n**A solver :** In Algosto, solvers are always classes that need an objective function and a constraint to be instanciated.\n    Simply call the `fit` method to minimize the objective on the constraint.\n\n**A plot :** Algosto provides some functions to plot most used graph.\n    You can build your own graph using *Matplotlib* or *Plotly*.\n\n### Objective function\n\nBased on the workflow given just before, we start by defining the quadratic objective function\nand its gradient in order to use the SGD.\n\n    import numpy as np\n\n    def objective(x: np.array) -\u003e float :\n        return np.sum(x**2, axis=1)\n\n    def grad(x: np.array) -\u003e float :\n        return 2*x\n\n\u003e [!WARNING]\n\u003e As said before, objective functions and gradients need to be able to process multiple points simultaneously to work with Algosto.\n\u003e Specifically, if the function operates on points of dimension `d`, it should accept a numpy array with shape `(n, d)`\n\u003e and returns a numpy array of length `n`, where `n` is the number of points provided to the objective function or gradient.\n\nAlgosto provides some toy objective functions, of which the quadratic function is a part, that you can import like this :\n\n    from algosto.utils.functions import quadratic\n\n    objective, grad = quadratic()\n\n\u003e [!NOTE]\n\u003e You can find a list of all available functions in the [references](https://www.algosto.dev/references/utils/functions/index.html)\n\u003e section of the documentation.\n\n### Constraints\n\nNow, we need to specify the definition space. \nTo do that, Algosto provides object called *constraints* that you can import from the module ``algosto.constraints`` as follow :\n\n    import numpy as np\n    from algosto.constraints import RdBallConstraint\n\n    ct = RdBallConstraint(2, np.zeros(2), 5)\n\nWe define a two-dimensional ball in $\\mathbb{R}^d$, centered at the origin.\nConstraints provide the solver with information about the space within which it can optimize the objective function.\n\n\u003e [!NOTE]\n\u003e You can find a list of all available constraints in the [references](https://www.algosto.dev/references/constraints/index.html)\n\u003e section of the documentation.\n\n\u003e [!NOTE]\n\u003e If your constraint is not yet implemented, you can define your own.\n\u003e Refer to the constraint chapter in the cookbook to learn how.\n\n### Solver\n\nIt's time to speak about the solver itself.\nSolvers are avaible from the `algosto.solvers` module where you can find all the solvers implemented in Algosto.\nIn this example, we are going to use the stochastic gradient descent (SGD) to minimize the objective.\n\n    from algosto.solvers import SGDSolver\n\n    solver = SGDSolver(ct, objective)   \n\n\u003e [!NOTE]\n\u003e You can find a list of all available solvers in the [references](https://www.algosto.dev/references/solvers/index.html)\n\u003e section of the documentation.\n\nFinally, we can minimize the objective function with the help of the `fit` method :\n\n    from algosto.utils import plot\n\n    solver.fit()\n\n    plot(solver)\n\n### Full workflow code\n\nThe full Python code is avaible just below\n\n    import numpy as np\n    from algosto.functions import quadratic\n    from algosto.constraints import RdBallConstraint\n    from algosto.solvers import SGDSolver\n    from algosto.evaluate import trajectory\n\n    objective, grad = quadratic()\n\n    ct = RdBallConstraint(2, np.zeros(2), 5)\n\n    solver = SGDSolver(ct, objective, grad)\n\n    solver.fit()\n\n    plot(solver)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelvin-klein%2Falgosto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmelvin-klein%2Falgosto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelvin-klein%2Falgosto/lists"}