Socket
Socket
Sign inDemoInstall

github.com/danieldk/golinear

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/danieldk/golinear

Package golinear trains and applies linear classifiers. The package is a binding against liblinear with a Go-ish interface. Trained models can be saved to and loaded from disk, to avoid the (potentially) costly training process. A model is trained using a problem. A problem consists of training instances, where each training instance has a class label and a feature vector. The training procedure attempts to find one or more functions that separate the instances of two classes. This model can then predict the class of unseen instances. Consider for instance that we would like to do sentiment analysis, using the following, humble, training corpus: To represent this as a problem, we have to convert the classses (positive/negative) to an integral class labels and extract features. In this case, we can simply label the classes as positive: 0, negative: 1. We will use the words as our features (a: 1, beautiful: 2, album: 3, crappy: 4, ugly: 5) and use booleans as our feature values. In other words, the sentences will have the following feature vectors: We can now construct the problem using this representation: The problem is used to train a linear classifier using a set of parameters to choose the type of solver, constraint violation cost, etc. We will use the default parameters, which train a L2-regularized L2-loss support vector classifier. Of course, now we would like to use this model to classify other sentences. For instance: We map this sentence to the feature vector that we used during training, simply ignoring words that we did not encounter while training the model: The Predict method of the model is used to predict the label of this feature vector. As expected, the model will predict the sentence to be positive (0).


Version published

Readme

Source

Introduction

GoDoc

golinear is a package for training and using linear classifiers in the Go programming language (golang).

Installation

To use this package, you need the liblinear library. On Mac OS X, you can install this library with Homebrew:

brew install liblinear

Ubuntu and Debian provide packages for liblinear. However, at the time of writing (July 2, 2014), these were serverly outdated. This package requires version 1.9 or later.

This latest API-stable version (v1) can be installed with the go command:

go get gopkg.in/danieldk/golinear.v1

or included in your source code:

import "gopkg.in/danieldk/golinear.v1"

The package documentation is available at: http://godoc.org/gopkg.in/danieldk/golinear.v1

Plans

  1. Port classification to Go.
  2. Port training to Go.

We will take a pragmatic approach to porting code to Go: if the performance penalty is minor, ported code will flow to the main branch. Otherwise, we will keep it around until the performance is good enough.

Examples

Examples for using golinear can be found at:

https://github.com/danieldk/golinear-examples

FAQs

Last updated on 29 Aug 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc