You are previewing F# for Machine Learning Essentials.
O'Reilly logo
F# for Machine Learning Essentials

Book Description

Get up and running with machine learning with F# in a fun and functional way

About This Book

  • Design algorithms in F# to tackle complex computing problems

  • Be a proficient F# data scientist using this simple-to-follow guide

  • Solve real-world, data-related problems with robust statistical models, built for a range of datasets

  • Who This Book Is For

    If you are a C# or an F# developer who now wants to explore the area of machine learning, then this book is for you. Familiarity with theoretical concepts and notation of mathematics and statistics would be an added advantage.

    What You Will Learn

  • Use F# to find patterns through raw data

  • Build a set of classification systems using Accord.NET, Weka, and F#

  • Run machine learning jobs on the Cloud with MBrace

  • Perform mathematical operations on matrices and vectors using Math.NET

  • Use a recommender system for your own problem domain

  • Identify tourist spots across the globe using inputs from the user with decision tree algorithms

  • In Detail

    The F# functional programming language enables developers to write simple code to solve complex problems. With F#, developers create consistent and predictable programs that are easier to test and reuse, simpler to parallelize, and are less prone to bugs.

    If you want to learn how to use F# to build machine learning systems, then this is the book you want.

    Starting with an introduction to the several categories on machine learning, you will quickly learn to implement time-tested, supervised learning algorithms. You will gradually move on to solving problems on predicting housing pricing using Regression Analysis. You will then learn to use Accord.NET to implement SVM techniques and clustering. You will also learn to build a recommender system for your e-commerce site from scratch. Finally, you will dive into advanced topics such as implementing neural network algorithms while performing sentiment analysis on your data.

    Style and approach

    This book is a fast-paced tutorial guide that uses hands-on examples to explain real-world applications of machine learning. Using practical examples, the book will explore several machine learning techniques and also describe how you can use F# to build machine learning systems.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. F# for Machine Learning Essentials
      1. Table of Contents
      2. F# for Machine Learning Essentials
      3. Credits
      4. Foreword
      5. About the Author
      6. Acknowledgments
      7. About the Reviewers
        1. eBooks, discount offers, and more
          1. Why subscribe?
      9. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      10. 1. Introduction to Machine Learning
        1. Objective
          1. Getting in touch
          2. Different areas where machine learning is being used
        2. Why use F#?
          1. Supervised machine learning
            1. Training and test dataset/corpus
            2. Some motivating real life examples of supervised learning
            3. Nearest Neighbour algorithm (a.k.a k-NN algorithm)
            4. Distance metrics
            5. Decision tree algorithms
              1. Linear regression
              2. Logistic regression
              3. Recommender systems
        3. Unsupervised learning
        4. Machine learning frameworks
        5. Machine learning for fun and profit
        6. Recognizing handwritten digits – your "Hello World" ML program
          1. How does this work?
        7. Summary
      11. 2. Linear Regression
        1. Objective
        2. Different types of linear regression algorithms
        3. APIs used
          1. Math.NET Numerics for F# 3.7.0
          2. Getting Math.NET
          3. Experimenting with Math.NET
        4. The basics of matrices and vectors (a short and sweet refresher)
          1. Creating a vector
          2. Creating a matrix
          3. Finding the transpose of a matrix
          4. Finding the inverse of a matrix
          5. Trace of a matrix
        5. QR decomposition of a matrix
          1. SVD of a matrix
        6. Linear regression method of least square
        7. Finding linear regression coefficients using F#
        8. Finding the linear regression coefficients using Math.NET
        9. Putting it together with Math.NET and FsPlot
        10. Multiple linear regression
        11. Multiple linear regression and variations using Math.NET
        12. Weighted linear regression
        13. Plotting the result of multiple linear regression
        14. Ridge regression
        15. Multivariate multiple linear regression
        16. Feature scaling
        17. Summary
      12. 3. Classification Techniques
        1. Objective
        2. Different classification algorithms you will learn
        3. Some interesting things you can do
          1. Binary classification using k-NN
            1. How does it work?
          2. Finding cancerous cells using k-NN: a case study
        4. Understanding logistic regression
          1. The sigmoid function chart
          2. Binary classification using logistic regression (using Accord.NET)
        5. Multiclass classification using logistic regression
          1. How does it work?
        6. Multiclass classification using decision trees
          1. Obtaining and using WekaSharp
          2. How does it work?
        7. Predicting a traffic jam using a decision tree: a case study
        8. Challenge yourself!
        9. Summary
      13. 4. Information Retrieval
        1. Objective
        2. Different IR algorithms you will learn
        3. What interesting things can you do?
        4. Information retrieval using tf-idf
          1. Measures of similarity
            1. Generating a PDF from a histogram
            2. Minkowski family
            3. L1 family
            4. Intersection family
            5. Inner Product family
            6. Fidelity family or squared-chord family
            7. Squared L2 family
            8. Shannon's Entropy family
              1. Combinations
              2. Set-based similarity measures
            9. Similarity of asymmetric binary attributes
          2. Some example usages of distance metrics
            1. Finding similar cookies using asymmetric binary similarity measures
          3. Grouping/clustering color images based on Canberra distance
          4. Summary
      14. 5. Collaborative Filtering
        1. Objective
        2. Different classification algorithms you will learn
        3. Vocabulary of collaborative filtering
        4. Baseline predictors
          1. Basis of User-User collaborative filtering
          2. Implementing basic user-user collaborative filtering using F#
          3. Code walkthrough
          4. Variations of gap calculations and similarity measures
        5. Item-item collaborative filtering
        6. Top-N recommendations
        7. Evaluating recommendations
          1. Prediction accuracy
          2. Confusion matrix (decision support)
        8. Ranking accuracy metrics
          1. Prediction-rating correlation
        9. Working with real movie review data (Movie Lens)
        10. Summary
      15. 6. Sentiment Analysis
        1. Objective
        2. What you will learn
        3. A baseline algorithm for SA using SentiWordNet lexicons
        4. Handling negations
        5. Identifying praise or criticism with sentiment orientation
        6. Pointwise Mutual Information
        7. Using SO-PMI to find sentiment analysis
        8. Summary
      16. 7. Anomaly Detection
        1. Objective
          1. Different classification algorithms
          2. Some cool things you will do
          3. The different types of anomalies
        2. Detecting point anomalies using IQR (Interquartile Range)
        3. Detecting point anomalies using Grubb's test
        4. Grubb's test for multivariate data using Mahalanobis distance
          1. Code walkthrough
        5. Chi-squared statistic to determine anomalies
        6. Detecting anomalies using density estimation
        7. Strategy to convert a collective anomaly to a point anomaly problem
        8. Dealing with categorical data in collective anomalies
        9. Summary
      17. Index