Giter VIP home page Giter VIP logo

lvq1_classifier's Introduction

LVQ1 Classifier

Implementation of a learning vector quantization classifier in python 2.7.

The LVQ classifier can be used by importing the class Lvq1 from the lvq1.py file.

Note that only the standard LVQ classifier also known as LVQ1 is implemented. Other versions of LVQ such as OLVQ1 or LVQ3 will be added in potential future updates.

Required libraries

  • SciPy
  • NumPy

How to use

This is an example of how to use the LVQ model in code.

from lvq.lvq1 import Lvq1
from lvq.lvq_exceptions import InvalidParameterException

training_data , target_labels = getTrainingData() # Get list of training samples and label list
validation_data, validation_labels = getValidationData() # Get list of validation samples and label list


neuron_counts = [5, 5] # Number of neurons per class
labels = [0, 1] # Label for each class
max_epochs = 100
patience = 5 # Number of epochs to wait before stopping training
init_lr = 0.1 # Initial learning rate

try:
  # Create model object
  lvq_network = Lvq1([5,5], [0, 1], max_epochs, lr_hyperparam, patience)
  lvq_network.set_early_stopping(True)
  
  # Manually set validation instead of randomly splitting the training set
  lvq_network.set_validation_set(validation_data, validation_labels)
  
  # Train by initializing neuron weights with values of samples in the training data
  lvq_network.train(training_data, target_labels, "real-samples")  
  
except InvalidParameterException as exception:
  print(exception)

lvq1_classifier's People

Contributors

mathewstylianidis avatar

Stargazers

Chuan avatar yuanke avatar

Watchers

James Cloos 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.