Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
F# for Machine Learning Essentials

You're reading from  F# for Machine Learning Essentials

Product type Book
Published in Feb 2016
Publisher
ISBN-13 9781783989348
Pages 194 pages
Edition 1st Edition
Languages
Author (1):
Sudipta Mukherjee Sudipta Mukherjee
Profile icon Sudipta Mukherjee

Table of Contents (16) Chapters

F# for Machine Learning Essentials
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. Introduction to Machine Learning 2. Linear Regression 3. Classification Techniques 4. Information Retrieval 5. Collaborative Filtering 6. Sentiment Analysis 7. Anomaly Detection Index

Finding linear regression coefficients using F#


The following is an example problem that can be solved using linear regression.

For seven programs, the amount of disk I/O operations and processor times were measured and the results were captured in a list of tuples. Here is that list: (14,2), (16,5),(27,7) (42,9), (39, 10), (50,13), (83,20). The task for linear regression is to fit a model for these data points.

For this experiment, you will write the solution using F# from scratch, building each block one at a time.

  1. Create a new F# program script in LINQPad as shown and highlighted in the following image:

  2. Add the following variables to represent the data points:

  3. Add the following code to find the values needed to calculate b0 and b1:

  4. Once you do this, you will get the following output:

The following is the final output we receive:

Now in order to understand how good your linear regression model fits the data, we need to plot the actual data points as scatter plots and the regression line as a straight...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}