You are previewing Mastering .NET Machine Learning.
O'Reilly logo
Mastering .NET Machine Learning

Book Description

Master the art of machine learning with .NET and gain insight into real-world applications

About This Book

  • Based on .NET framework 4.6.1, includes examples on ASP.NET Core 1.0

  • Set up your business application to start using machine learning techniques

  • Familiarize the user with some of the more common .NET libraries for machine learning

  • Implement several common machine learning techniques

  • Evaluate, optimize and adjust machine learning models

  • Who This Book Is For

    This book is targeted at .Net developers who want to build complex machine learning systems. Some basic understanding of data science is required.

    What You Will Learn

  • Write your own machine learning applications and experiments using the latest .NET framework, including .NET Core 1.0

  • Set up your business application to start using machine learning.

  • Accurately predict the future using regressions.

  • Discover hidden patterns using decision trees.

  • Acquire, prepare, and combine datasets to drive insights.

  • Optimize business throughput using Bayes Classifier.

  • Discover (more) hidden patterns using KNN and Naïve Bayes.

  • Discover (even more) hidden patterns using K-Means and PCA.

  • Use Neural Networks to improve business decision making while using the latest ASP.NET technologies.

  • Explore “Big Data”, distributed computing, and how to deploy machine learning models to IoT devices – making machines self-learning and adapting

  • Along the way, learn about Open Data, Bing maps, and MBrace

  • In Detail

    .Net is one of the widely used platforms for developing applications. With the meteoric rise of Machine learning, developers are now keen on finding out how can they make their .Net applications smarter. Also, .NET developers are interested into moving into the world of devices and how to apply machine learning techniques to, well, machines.

    This book is packed with real-world examples to easily use machine learning techniques in your business applications. You will begin with introduction to F# and prepare yourselves for machine learning using .NET framework. You will be writing a simple linear regression model using an example which predicts sales of a product. Forming a base with the regression model, you will start using machine learning libraries available in .NET framework such as Math.NET, Numl.NET and Accord.NET with the help of a sample application. You will then move on to writing multiple linear regressions and logistic regressions.

    You will learn what is open data and the awesomeness of type providers. Next, you are going to address some of the issues that we have been glossing over so far and take a deep dive into obtaining, cleaning, and organizing our data. You will compare the utility of building a KNN and Naive Bayes model to achieve best possible results.

    Implementation of Kmeans and PCA using Accord.NET and Numl.NET libraries is covered with the help of an example application. We will then look at many of issues confronting creating real-world machine learning models like overfitting and how to combat them using confusion matrixes, scaling, normalization, and feature selection. You will now enter into the world of Neural Networks and move your line of business application to a hybrid scientific application. After you have covered all the above machine learning models, you will see how to deal with very large datasets using MBrace and how to deploy machine learning models to Internet of Thing (IoT) devices so that the machine can learn and adapt on the fly

    Style and approach

    This book will guide you in learning everything about how to tackle the flood of data being encountered these days in your .NET applications with the help of popular machine learning libraries offered by the .NET framework.

    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. Mastering .NET Machine Learning
      1. Table of Contents
      2. Mastering .NET Machine Learning
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewers
        1. eBooks, discount offers, and more
          1. Why subscribe?
      8. 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. Errata
          3. Piracy
          4. Questions
      9. 1. Welcome to Machine Learning Using the .NET Framework
        1. What is machine learning?
        2. Why .NET?
        3. What version of the .NET Framework are we using?
        4. Why write your own?
        5. Why open data?
        6. Why F#?
        7. Getting ready for machine learning
          1. Setting up Visual Studio
          2. Learning F#
        8. Third-party libraries
          1. Math.NET
          2. Accord.NET
          3. Numl
        9. Summary
      10. 2. AdventureWorks Regression
        1. Simple linear regression
          1. Setting up the environment
          2. Preparing the test data
          3. Standard deviation
          4. Pearson's correlation
          5. Linear regression
        2. Math.NET
          1. Regression try 1
          2. Regression try 2
        3. Accord.NET
          1. Regression
          2. Regression evaluation using RMSE
          3. Regression and the real world
          4. Regression against actual data
        4. AdventureWorks app
          1. Setting up the environment
          2. Updating the existing web project
          3. Implementing the regression
        5. Summary
      11. 3. More AdventureWorks Regression
        1. Introduction to multiple linear regression
          1. Intro example
          2. Keep adding x variables?
          3. AdventureWorks data
          4. Adding multiple regression to our production application
          5. Considerations when using multiple x variables
          6. Adding a third x variable to our model
        2. Logistic regression
          1. Intro to logistic regression
          2. Adding another x variable
          3. Applying a logistic regression to AdventureWorks data
          4. Categorical data
          5. Attachment point
          6. Analyzing results of the logistic regression
          7. Adding logistic regression to the application
        3. Summary
      12. 4. Traffic Stops – Barking Up the Wrong Tree?
        1. The scientific process
        2. Open data
        3. Hack-4-Good
          1. FsLab and type providers
          2. Data exploration
          3. Visualization
          4. Decision trees
          5. Accord
          6. numl
        4. Summary
      13. 5. Time Out – Obtaining Data
        1. Overview
        2. SQL Server providers
          1. Non-type provider
          2. SqlProvider
          3. Deedle
          4. MicrosoftSqlProvider
          5. SQL Server type provider wrap up
          6. Non SQL type providers
        3. Combining data
          1. Parallelism
          2. JSON type provider – authentication
        4. Summary
      14. 6. AdventureWorks Redux – k-NN and Naïve Bayes Classifiers
        1. k-Nearest Neighbors (k-NN)
          1. k-NN example
        2. Naïve Bayes
          1. Naïve Bayes in action
          2. One thing to keep in mind while using Naïve Bayes
        3. AdventureWorks
          1. Getting the data ready
          2. k-NN and AdventureWorks data
          3. Naïve Bayes and AdventureWorks data
        4. Making use of our discoveries
          1. Getting the data ready
          2. Expanding features
        5. Summary
      15. 7. Traffic Stops and Crash Locations – When Two Datasets Are Better Than One
        1. Unsupervised learning
          1. k-means
          2. Principle Component Analysis (PCA)
        2. Traffic stop and crash exploration
          1. Preparing the script and the data
          2. Geolocation analysis
          3. PCA
          4. Analysis summary
        3. The Code-4-Good application
          1. Machine learning assembly
          2. The UI
          3. Adding distance calculations
          4. Augmenting with human observations
        4. Summary
      16. 8. Feature Selection and Optimization
        1. Cleaning data
        2. Selecting data
          1. Collinearity
          2. Feature selection
          3. Normalization
          4. Scaling
        3. Overfitting and cross validation
          1. Cross validation – train versus test
          2. Cross validation – the random and mean test
          3. Cross validation – the confusion matrix and AUC
          4. Cross validation – unrelated variables
        4. Summary
      17. 9. AdventureWorks Production – Neural Networks
        1. Neural networks
          1. Background
          2. Neural network demo
          3. Neural network – try #1
          4. Neural network – try #2
        2. Building the application
          1. Setting up the models
          2. Building the UX
        3. Summary
      18. 10. Big Data and IoT
        1. AdventureWorks and the Internet of Bikes
          1. Data considerations
          2. MapReduce
          3. MBrace
          4. Distributed logistic regression
        2. The IoT
          1. PCL linear regression
          2. Service layer
          3. Universal Windows app and Raspberry Pi 2
          4. Next steps
        3. Summary
      19. Index