Giter Site home page Giter Site logo

bayes's Introduction

Bayes Build

Bayes is a Naive Bayes Classifier for iOS and Mac platforms.

Bayes is implemented in Swift and takes advantage of generics to enable any Hashable, Equatable type of your choosing or creation for use as category or feature.

Installation

Swift Package

Bayes is built as a Swift package.

CocoaPods

Bayes is available as a CocoaPod, but has not yet been versioned and submitted to trunk. So to use it:

pod 'Bayes', git: 'https://github.com/fcanas/Bayes.git'

Since Bayes is written in Swift, you will need to be using a recent version of CocoaPods (>0.36) and you may need to add use_frameworks! to your Podfile. See this blog post for more information.

Framework

The project includes framework targets for iOS and Mac. Pull the repository and build the appropriate target for you. When Bayes reaches a release milestone, it will be appropriately tagged and should be easily available via Carthage.

Use

var eventSpace = EventSpace<String, String>()

eventSpace.observe("Cat", features: ["paw", "tail", "claw"])
eventSpace.observe("Cat", features: ["stripe", "tail", "whisker", "ear"])
eventSpace.observe("Cat", features: ["meow", "vertical pupil"])

eventSpace.observe("Dog", features: ["paw", "tail", "bark"])
eventSpace.observe("Dog", features: ["wag", "fetch", "tail", "paw"])

var classifier = BayesianClassifier(eventSpace: eventSpace)

XCTAssertEqual(classifier.classify(["claw", "tail"])!, "Cat", "Should categorize as Cat, due to claw")
XCTAssertEqual(classifier.classify(["bark", "tail"])!, "Dog", "Should categorize as Dog, due to bark")
XCTAssertEqual(classifier.classify(["tail"])!, "Cat", "Should categorize as Cat, due to base rate")
XCTAssertEqual(classifier.classify(["paw", "tail"])!, "Dog", "Should categorize as Dog, due to prevalence of paw")

Contribute

Contributions are welcome. Please note the following guidelines

  • Test public functionality
  • Make everything as private as possible; use private and internal aggressively and only expose what is necessary for external functionality
  • Favor structs over classes
  • Extract standard mathematical functions that may simplify implementation of future models, e.g. product, argmax

bayes's People

Contributors

fcanas avatar veritech avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

bayes's Issues

Gaussian Event Model

Modeling a continuous event space requires a new event model. I think this warrants creating an event space protocol.

td-idf

For easier use with document classification

change from struct to class, any issues?

Hi Fabien,
thanks for the great code.
For a personal project, I need to use BayesianClassifier through a computed var, with get access only. Unfortunately, because it's a struct, and it's mutated when calling .observe(), the compiler won't let me do it....

Changing struct to class seems to do the job. I'm however unsure about the consequence.

Would you have any recommendations?
thanks!
-M

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.