All Projects → goessl → MachineLearning

goessl / MachineLearning

Licence: MIT license
An easy neural network for Java!

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to MachineLearning

Machinelearning
An easy neural network for Java!
Stars: ✭ 122 (-2.4%)
Mutual labels:  lightweight, matrix, prediction, matrices, easy-to-use
Phpsci Carray
PHP library for scientific computing powered by C
Stars: ✭ 176 (+40.8%)
Mutual labels:  matrix, matrices
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-71.2%)
Mutual labels:  matrix, matrices
MatrixLib
Lightweight header-only matrix library (C++) for numerical optimization and machine learning. Contact me if there is an exciting opportunity.
Stars: ✭ 35 (-72%)
Mutual labels:  lightweight, matrix
Mathematics for Machine Learning
Learn mathematics behind machine learning and explore different mathematics in machine learning.
Stars: ✭ 28 (-77.6%)
Mutual labels:  matrix, matrix-calculations
Matswift
Matrix computation library in Swift
Stars: ✭ 17 (-86.4%)
Mutual labels:  matrix, matrix-calculations
query2report
Query2Report is a simple open source business intelligence platform that allows users to build report/dashboard for business analytics or enterprise reporting
Stars: ✭ 43 (-65.6%)
Mutual labels:  lightweight, easy-to-use
brute-md5
Advanced, Light Weight & Extremely Fast MD5 Cracker/Decoder/Decryptor written in Python 3
Stars: ✭ 16 (-87.2%)
Mutual labels:  lightweight, easy-to-use
DuiMini
Cross-platform, lightweight DirectUI GUI framework.
Stars: ✭ 13 (-89.6%)
Mutual labels:  lightweight, easy-to-use
Simple Php Router
Simple, fast and yet powerful PHP router that is easy to get integrated and in any project. Heavily inspired by the way Laravel handles routing, with both simplicity and expand-ability in mind.
Stars: ✭ 279 (+123.2%)
Mutual labels:  lightweight, easy-to-use
ytmous
Anonymous Youtube Proxy
Stars: ✭ 60 (-52%)
Mutual labels:  lightweight, easy-to-use
sparse
Sparse matrix formats for linear algebra supporting scientific and machine learning applications
Stars: ✭ 136 (+8.8%)
Mutual labels:  matrix, matrices
abacus
📐 C# cross precision 3D maths library.
Stars: ✭ 35 (-72%)
Mutual labels:  matrix, matrices
Fmatvec
A fast vector/matrix library
Stars: ✭ 5 (-96%)
Mutual labels:  matrix, matrices
fastverse
An Extensible Suite of High-Performance and Low-Dependency Packages for Statistical Computing and Data Manipulation in R
Stars: ✭ 123 (-1.6%)
Mutual labels:  weights, matrix-calculations
StringDB
StringDB is a modular, key/value pair archival DB designed to consume *tiny* amounts of ram & produce *tiny* databases.
Stars: ✭ 56 (-55.2%)
Mutual labels:  lightweight, easy-to-use
python-neuron
Neuron class provides LNU, QNU, RBF, MLP, MLP-ELM neurons
Stars: ✭ 38 (-69.6%)
Mutual labels:  prediction, neurons
RoundWidget
Java 实现的 Android 原生圆角矩形控件,圆角 FrameLayout 和圆角 ImageView
Stars: ✭ 86 (-31.2%)
Mutual labels:  weight, weights
matrix-appservice-mumble
Matrix <--> Murmur Bridge
Stars: ✭ 27 (-78.4%)
Mutual labels:  matrix
PermissionManager
This Library automatically search for permission in androidmanifests file and request for the same
Stars: ✭ 45 (-64%)
Mutual labels:  easy-to-use

Machine Learning

Deprecated

This repository is deprecated! Please use NeuralNetwork instead!

Java collection that provides Java packages for developing machine learning algorithms and that is

  • easy to use -> great for small projects or just to learn how machine learning works
  • small and simple -> easy to understand and make changes
  • lightweight (mostly because I'm a student who just started to learn how to code Java and can't code more complex :P)

Getting Started

Prerequisites

This project is written in pure vanilla Java so there is nothing needed than the standard libraries.

Installation

Just add all packages with the source files in the Source folder /src to your project and you are ready to go! Every class has a main test method. After installation just run any class so you can check if the installation was successful.

Code Example

Neural Network

Initialize a new network with a given architecture (number or inputs, number of neurons in the hidden layers and each layers activation function) (If you don't know what to choose, here is a rule of thumb for a average looking network:

  • number of hidden layers = 2
  • number of neurons per layer: number of inputs (except the last layer is the output layer = as many neurons as outputs)
  • activation functions: none)
//New network
final Network net = new Network(
        2,                                    //2 inputs
        new int[]{3, 1},                      //2 layers with 3 & 1 neurons
        new Network.ActivationFunction[]{
          Network.ActivationFunction.NONE,    //both layers with ...
          Network.ActivationFunction.NONE});  //... no activation function

Then you can seed the weights in the network (= randomize it).

net.seedWeights(-1, 1);

Prepare your training data and put it into a [Matrix] (src/main/java/neural/Matrix.java)

//Generate 10 training sets
//Every row represents one training set (10 rows = 10 sets)
//Every column gets fed into the same input/comes out of the same output
//(first column gets into the first input)
//(2 columns = 2 inputs / 1 column = 1 output)
final Matrix trainInput = new Matrix(10, 2);
final Matrix trainOutput = new Matrix(10, 1);
//Fill the training sets
//Inputs: two random numbers
//Outputs: average of these two numbers
final Random rand = new Random();
for(int set=0; set<trainInput.getHeight(); set++) {
  trainInput.set(set, 0, rand.nextInt(10));
  trainInput.set(set, 1, rand.nextInt(10));
  
  final double out = (trainInput.get(set, 0) + trainInput.get(set, 1)) / 2;
  trainOutput.set(set, 0, out);
}

Now your network is ready for training! Just tell it how drastic the changes should be, give it the training data and if it should print it's progress to the console.

  • learning rate: higher = faster training but to high could miss the optimum, slower = better result (sometimer it goes crazy and the cost just increase, then try decreasing the laerning rate)
  • inputs: training set inputs
  • outputs: wanted outputs the network should learn from
  • printToConsole: show the progress in the console
net.train(0.2, trainInput, trainOutput, true);

Now the network should be trained so let's have a look at the network itself by simply printing a basic representation and try forwarding the inputs.

System.out.println(net);
System.out.println(net.forward(trainInput));

And if we would like to get the mean squared error we just call the cost function on some data:

System.out.println(net.cost(trainInput, trainOutput));

Contributors

The two people who inspired me to try making my own machine learning project are Brandon Rohrer and Stephen Welch. Both make awesome YouTube videos that explain how machine learning works.

Brandon Rohrer:

Stephen Welch:

License (MIT)

MIT License

Copyright (c) 2017 Sebastian Gössl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].