Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Go Machine Learning Projects

You're reading from   Go Machine Learning Projects Eight projects demonstrating end-to-end machine learning and predictive analytics applications in Go

Arrow left icon
Product type Paperback
Published in Nov 2018
Publisher Packt
ISBN-13 9781788993401
Length 348 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Xuanyi Chew Xuanyi Chew
Author Profile Icon Xuanyi Chew
Xuanyi Chew
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. How to Solve All Machine Learning Problems 2. Linear Regression - House Price Prediction FREE CHAPTER 3. Classification - Spam Email Detection 4. Decomposing CO2 Trends Using Time Series Analysis 5. Clean Up Your Personal Twitter Timeline by Clustering Tweets 6. Neural Networks - MNIST Handwriting Recognition 7. Convolutional Neural Networks - MNIST Handwriting Recognition 8. Basic Facial Detection 9. Hot Dog or Not Hot Dog - Using External Services 10. What's Next? 11. Other Books You May Enjoy

Linear regression

Now that that's all done, let's do some linear regression! But first, let's clean up our code. We'll move our exploratory work so far into a function called exploration(). Then we will reread the file, split the dataset into training and testing dataset, and perform all the transformations before finally running the regression. For that, we will use github.com/sajari/regression and apply the regression.

The first part looks like this:

func main() {
// exploratory() // commented out because we're done with exploratory work.

f, err := os.Open("train.csv")
mHandleErr(err)
defer f.Close()
hdr, data, indices, err := ingest(f)
rows, cols, XsBack, YsBack, newHdr, newHints := clean(hdr, data, indices, datahints, ignored)
Xs := tensor.New(tensor.WithShape(rows, cols), tensor.WithBacking(XsBack))
it, err := native.MatrixF64(Xs...
You have been reading a chapter from
Go Machine Learning Projects
Published in: Nov 2018
Publisher: Packt
ISBN-13: 9781788993401
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 $19.99/month. Cancel anytime