JAVA Framework for Artificial Intelligence, Machine Learning or Neural Network

Encog

Encog Machine Learning Framework is an advanced machine learning framework that supports a variety of advanced algorithms, as well as support classes to normalize and process data. Machine learning algorithms such as Support Vector Machines, Artificial Neural Networks, Genetic Programming, Bayesian Networks, Hidden Markov Models, Genetic Programming and Genetic Algorithms are supported. Most Encog training algoritms are multi-threaded and scale well to multicore hardware. Encog can also make use of a GPU to further speed processing time.

It was written by Jeff Heaton in the early 90s, and was the standard Java DL framework for a long time. I do not believe that Encog handles distributed computing, works with GPUs, Hadoop, Spark or Kafka, or takes into account many of the algorithmic advances in DL since 2006.

Neuroph 

Neuroph is lightweight Java neural network framework to develop common neural network architectures. It contains well designed, open source Java library with small number of basic classes which correspond to basic NN concepts. Also has nice GUI neural network editor to quickly create Java neural network components.
Neuroph is VERY focused on neural networks and you can express a connection between just about anything. For very custom/non-standard neural networks of different typologies than the typical Elman/Jordan, NEAT, HyperNEAT, Feedforward type networks, then Neuroph will fit the bill nicely.

Deeplearning4J

Deeplearning4j is the first commercial-grade, open-source, distributed deep-learning library written for Java and Scala. Integrated with Hadoop and Spark, DL4J is designed to be used in business environments, rather than as a research tool. Skymind is its commercial support arm.

It works on distributed CPUs or GPUs using Spark as an access layer. It's certified on CDH5 and soon on HDP... And it includes implementations of LSTMs (RNNs), deep convolutional nets, RBMs, DBNs and word2vec, among other neural nets. It is currently the most popular DL tool for the JVM, and one of the top 5 DL libraries in the world.

Deeplearning4j is powered by the numerical computing lib ND4J, or n-dimensional arrays for Java. Basically, they ported Numpy to the JVM. That makes DL4J extensible, and they are planning to add other algos like reinforcement learning in the near future. ND4J, in turn, runs on libND4J, a C++ library that makes the computation fast. They also built the vectorization library, Canova, that takes any type of data and turns it into a vector that neural nets can understand. They are also trying to solve some of the ETL problems upstream from NNs.

Read More

Levenshtein Distance in Java - Fuzzy Logic to match names or any strings

Levenshtein Distance is a well-known algorithm that takes two strings and returns an integer representing the number of changes that need to be made to one string in order to have it transformed to the second string.

Apache Commons Lang library already has a method in the StringUtils class for this called getLevenshteinDistance. That’s nice to know so that you don’t have to implement your own. You can use the Levenshtein Distance to perform “fuzzy matching” between two strings with a calculation like:

percentMatch = 1 – (levenshteinDistance / longestStringLength) * 100

The “longestStringLength” is the length of the longer of the two strings (use something like Math.max(a.length(), b.length())).
Read More

Quartz Scheduler with Spring 4

Spring provides couple of classes that simplify the usage of Quartz within Spring-based applications.

There are 2 ways to configure a Job in Spring using Quartz:

A : Using MethodInvokingJobDetailFactoryBean

    This is the simplest among two.


<!-- For times when you just need to invoke a method on a specific object -->
<bean id="simpleJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="myJobBean" />
    <property name="targetMethod" value="myMethod" />
</bean>

Above job configuration simply invokes myMethod method of bean myJobBean which is simple POJO

B : Using JobDetailFactoryBean

When you need more advanced setup, need to pass data to job, being more flexible.
<!-- For times when you need more complex processing, passing data to the scheduled job -->
<bean name="complexJobDetail"    class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
    <property name="jobClass" value="com.websystique.spring.quartz.ScheduledJob" />
    <property name="jobDataMap">
        <map>
            <entry key="anotherBean" value-ref="anotherBean" />
        </map>
    </property>
    <property name="durability" value="true" />
</bean>


 Also there are two method to configure trigger:

Trigger defines the time when scheduler will run your scheduled job. There are two possible trigger type:
A: Simple Trigger , using SimpleTriggerFactoryBean
You can specify start time, delay between triggers and repeatInterval(frequency) to run the job.

<!-- Run the job every 2 seconds with initial delay of 1 second -->
<bean id="simpleTrigger"  class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
    <property name="jobDetail" ref="simpleJobDetail" />
    <property name="startDelay" value="1000" />
    <property name="repeatInterval" value="2000" />
</bean>
B: Cron Trigger , using CronTriggerFactoryBean
It’s more flexible and allows you to choose scheduled job at specific instance (time, day, date,..) and frequency in future.

<!-- Run the job every 5 seconds only on Weekends -->
<bean id="cronTrigger"  class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
    <property name="jobDetail" ref="complexJobDetail" />
    <property name="cronExpression" value="0/5 * * ? * SAT-SUN" />
</bean>
 
SchedulerFactoryBean glues together jobDetails and triggers to Configure Quartz Scheduler

<!-- Scheduler factory bean to glue together jobDetails and triggers to Configure Quartz Scheduler -->
<bean  class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="jobDetails">
        <list>
            <ref bean="simpleJobDetail" />
            <ref bean="complexJobDetail" />
        </list>
    </property>
    <property name="triggers">
        <list>
            <ref bean="simpleTrigger" />
            <ref bean="cronTrigger" />
        </list>
    </property>
</bean>


 
Read More