Giter Site home page Giter Site logo

search's Introduction

Search

Overview

This a simple Python class that allows to concurrently minimize or maximize arbitrary functions, by brute forcing a grid of parameters.

Disclaimer

This implementation has only two aims: ease and speed of use, not algorithm efficiency.

Dependencies

  • numpy
  • tqdm

Tutorial

Simply instantiate a Search object, define the parameters space with the method grid(**kwargs) and use the method minimize(function) to minimize a given function.

from search import Search
import numpy as np


# given data
x = np.linspace(0, 10, 100)
y = 3 * x + 2  # 3 and 2 are the parameters to infer


# loss function
def loss(x, y, a, b):
    y_pred = x * a + b
    loss = np.mean((y - y_pred)**2)
    return loss


search = Search(workers=4)  # 4 workers Pool
# `grid` requires iterable parameters,
# so giving [x] acts as one parameters `x`
search.grid(
    a=np.linspace(0, 11, 100),
    b=np.linspace(0, 11, 100),
    x=[x],
    y=[y]
)
data = search.minimize(loss)
print(data[0]["parameters"])  # a = 3, b = 2

search's People

Contributors

kerighan avatar

Stargazers

 avatar Benoit Linard avatar  avatar

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.