Clojure for Machine Learning

Clojure for Machine Learning
eBook: $29.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $79.98    Print cover: $49.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Covers a lot of machine learning techniques with Clojure programming.
  • Encompasses precise patterns in data to predict future outcomes using various machine learning techniques
  • Packed with several machine learning libraries available in the Clojure ecosystem

Book Details

Language : English
Paperback : 292 pages [ 235mm x 191mm ]
Release Date : April 2014
ISBN : 1783284358
ISBN 13 : 9781783284351
Author(s) : Akhil Wali
Topics and Technologies : All Books, Big Data and Business Intelligence, Open Source

Table of Contents

Chapter 1: Working with Matrices
Chapter 2: Understanding Linear Regression
Chapter 3: Categorizing Data
Chapter 4: Building Neural Networks
Chapter 5: Selecting and Evaluating Data
Chapter 6: Building Support Vector Machines
Chapter 7: Clustering Data
Chapter 8: Anomaly Detection and Recommendation
Chapter 9: Large-scale Machine Learning
Appendix: References
  • Chapter 1: Working with Matrices
    • Introducing Leiningen
    • Representing matrices
    • Generating matrices
    • Adding matrices
    • Multiplying matrices
    • Transposing and inverting matrices
    • Interpolating using matrices
    • Summary
  • Chapter 2: Understanding Linear Regression
    • Understanding single-variable linear regression
    • Understanding gradient descent
    • Understanding multivariable linear regression
      • Gradient descent with multiple variables
    • Understanding Ordinary Least Squares
    • Using linear regression for prediction
    • Understanding regularization
    • Summary
  • Chapter 3: Categorizing Data
    • Understanding the binary and multiclass classification
    • Understanding the Bayesian classification
    • Using the k-nearest neighbors algorithm
    • Using decision trees
    • Summary
  • Chapter 4: Building Neural Networks
    • Understanding nonlinear regression
    • Representing neural networks
    • Understanding multilayer perceptron ANNs
    • Understanding the backpropagation algorithm
    • Understanding recurrent neural networks
    • Building SOMs
    • Summary
  • Chapter 5: Selecting and Evaluating Data
    • Understanding underfitting and overfitting
      • Evaluating a model
      • Understanding feature selection
    • Varying the regularization parameter
    • Understanding learning curves
    • Improving a model
    • Using cross-validation
    • Building a spam classifier
    • Summary
  • Chapter 6: Building Support Vector Machines
    • Understanding large margin classification
      • Alternative forms of SVMs
    • Linear classification using SVMs
    • Using kernel SVMs
      • Sequential minimal optimization
      • Using kernel functions
    • Summary
  • Chapter 7: Clustering Data
    • Using K-means clustering
      • Clustering data using clj-ml
    • Using hierarchical clustering
    • Using Expectation-Maximization
    • Using SOMs
    • Reducing dimensions in the data
    • Summary

Akhil Wali

Akhil Wali is a software developer, and has been writing code since 1997. Currently, his areas of work are ERP and business intelligence systems. He has also worked in several other areas of computer engineering, such as search engines, document collaboration, and network protocol design. He mostly works with C# and Clojure. He is also well versed in several other popular programming languages such as Ruby, Python, Scheme, and C. He currently works with Computer Generated Solutions, Inc. This is his first book.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


- 4 submitted: last submission 27 May 2014

Page: 23 | Type: Technical

In core.matrix 0.3.0, M/* can be used to perform both inner product multiplication as well as element-wise multiplication.

In versions of core.matrix greater than 0.10.0, M/* only performs element-wise multiplication.

Page: 9 | Type: Technical

This is valid issue. It should be ':use' instead of ':import' in the information box

Page: 24 | Type: Technical

 It must be 'm x q' in the second para.
Page 78 | Type: Code
The last line of the function should be (/ positive total) instead of (/ positive negative).

Here's what the corrected version of the function should be:


(defn probability
  "Calculates the probability of a specific category
   given some attributes, depending on the training data."
  [attribute & {:keys
                [category prior-positive prior-negative data]
                :or {category nil
                     data fish-training-data}}]
  (let [by-category (if category
                      (filter category data)
        positive (count (filter attribute by-category))
        negative (- (count by-category) positive)
        total (+ positive negative)]
    (/ positive total)))

Page: 17 | Type: Code

The code given in the book is as follows:

(defn id-mat

  "Creates an identity matrix of n x n size"


  (let [init (square-mat :clatrix n 0)

       identity-f (fn [i j n]

                     (if (= i j) 1 n))]

    (cl/map-indexed identity-f init)))

It should be as follows:

(defn id-mat

  "Creates an identity matrix of n x n size"


  (let [init (square-mat n 0 :implementation :clatrix)

        identity-f (fn [i j n]

                     (if (= i j) 1 n))]

    (cl/map-indexed identity-f init)))



Page: 18 | Type: Code


The code given in the book is as follows:

(defn rand-square-clmat

  "Generates a random clatrix matrix of size n x n"


  (cl/map rand-int (square-mat :clatrix n 100)))


It should be as follows:

(defn rand-square-clmat
  "Generates a random clatrix matrix of size n x n"
  (cl/map rand-int (square-mat n 100 :implementation :clatrix)))

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Clojure for Machine Learning +    Node.js Blueprints =
50% Off
the second eBook
Price for both: €32.25

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Build systems that use machine learning techniques in Clojure
  • Understand machine learning problems such as regression, classifi cation, and clustering
  • Discover the data structures used in machine learning techniques such as artifi cial neural networks and support vector machines
  • Implement machine learning algorithms in Clojure
  • Learn more about Clojure libraries to build machine learning systems
  • Discover techniques to improve and debug solutions built on machine learning techniques
  • Use machine learning techniques in a cloud architecture for the modern Web

In Detail

Clojure for Machine Learning is an introduction to machine learning techniques and algorithms. This book demonstrates how you can apply these techniques to real-world problems using the Clojure programming language.

It explores many machine learning techniques and also describes how to use Clojure to build machine learning systems. This book starts off by introducing the simple machine learning problems of regression and classification. It also describes how you can implement these machine learning techniques in Clojure. The book also demonstrates several Clojure libraries, which can be useful in solving machine learning problems.

Clojure for Machine Learning familiarizes you with several pragmatic machine learning techniques. By the end of this book, you will be fully aware of the Clojure libraries that can be used to solve a given machine learning problem.


A book that brings out the strengths of Clojure programming that have to facilitate machine learning. Each topic is described in substantial detail, and examples and libraries in Clojure are also demonstrated.

Who this book is for

If you are a Clojure developer who wants to explore the area of machine learning, this book is for you. Basic understanding of the Clojure programming language is required. Familiarity with theoretical concepts and notation of mathematics and statistics would be an added advantage.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software