Machine Learning with Rust (Keiko Nakamura) (Z-Library)

Author: Keiko Nakamura

商业

In this stimulating journey of Rust, you'll learn how to use the Rust programming language in conjunction with machine learning. It's not a full guide to learning machine learning with Rust. Instead, it's more of a journey that shows you what's possible when you use Rust to solve machine learning problems. Some people like Rust because it is quick and safe. This book shows how those qualities can help machine learning a lot. To begin, we will show you what Rust is and how it works. This is so that everyone, even those who are new to Rust, can follow along. Then, we look at some basic machine learning concepts, such as linear and logistic regression, and show how to use Rust's tools and libraries to make these ideas work. You will learn more complex techniques like decision trees, support vector machines, and how to work with data as we go along. It goes all the way up to neural networks and image recognition, and we show you how to use Rust for these types of tasks step by step. We use real-world examples, such as COVID data and the CIFAR-10 image set, to show how Rust works with issues that come up in the real world. This book is all about discovery and experimentation. To see what you can do with them, we use various Rust tools for machine learning. It's a fun way to see how Rust can be used in machine learning, and it will make you want to try new things and learn more on your own. This is only the beginning; there is so much more to uncover as you continue to explore machine learning with Rust.

📄 File Format: PDF
💾 File Size: 7.0 MB
23
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
(This page has no text content)
📄 Page 2
MACHINE LEARNING WITH RUST A practical attempt to explore Rust and its libraries across popular machine learning techniques Keiko Nakamura
📄 Page 3
Preface In this stimulating book, you'll learn how to use the Rust programming language in conjunction with machine learning. It's not a full guide to learning machine learning with Rust. Instead, it's more of a journey that shows you what's possible when you use Rust to solve machine learning problems. Some people like Rust because it is quick and safe. This book shows how those qualities can help machine learning a lot. To begin, we will show you what Rust is and how it works. This is so that everyone, even those who are new to Rust, can follow along. Then, we look at some basic machine learning concepts, such as linear and logistic regression, and show how to use Rust's tools and libraries to make these ideas work. You will learn more complex techniques like decision trees, support vector machines, and how to work with data as we go along. It goes all the way up to neural networks and image recognition, and we show you how to use Rust for these types of tasks step by step. We use real-world examples, such as COVID data and the CIFAR-10 image set, to show how Rust works with issues that come up in the real world. This book is all about discovery and experimentation. To see what you can do with them, we use various Rust tools for machine learning. It's a fun way to see how Rust can be used in machine learning, and it will make you want to try new things and learn more on your own. This is only the beginning; there is so much more to uncover as you continue to explore machine learning with Rust. In this book you will learn how to: Exploit Rust's efficiency and safety to construct fast machine learning models. Use Rust's ndarray crate for numerical computations to manipulate complex machine learning data. Find out how Rust's extensible machine learning framework, linfa, works across algorithms to comprehend the ecosystem.
📄 Page 4
Use Rust's precision and speed to construct linear and logistic regression. See how Rust crates simplify decision trees and random forests for prediction and categorization. Learn to implement and optimize probabilistic classifiers, SVMs and closest neighbor methods in Rust. Use Rust's computing power to study neural networks and CNNs for picture recognition and processing. Apply learnt strategies to COVID and CIFAR-10 datasets to address realistic problems and obtain insights.
📄 Page 5
Prologue Prior to starting this writing expedition, I had a clear but challenging objective: to discover how the language Rust, which is known for being fast and safe, can work with the constantly changing field of machine learning. This book was written out of a mix of interest and a strong desire to go where no one has gone before, mapping out the places where Rust and machine learning meet. It's more of an exploration and story of finding than a claim to mastery. As the author, I'm not inviting you on this journey as a perfect teacher, but as a fellow learner eager to find out what can be done by combining the strength of Rust with the flexibility of machine learning methods. It was important to make it clear from the start that this book is not meant to be the only way to learn machine learning with Rust. It's more of a starting point or introduction for people who are interested in what Rust can do for machine learning projects. Sharing knowledge and trying new things is what these pages are all about. The goal is to get you interested and give you a base from which to build. We start with the basics and show you how Rust works so that even people who are new to the language can see what it can do. The steps in the book are similar to how I learned Rust: from getting to know its syntax and features to looking into how its ideas can be used to make machine learning methods work better, they are similar. The exploring spirit of this book stays true as we learn about different machine learning techniques, from basic algorithms to more complex neural networks. The datasets of COVID, CIFAR-10 and practical examples are meant to show the way by showing how Rust's features, such as its speed, memory safety, and concurrency, can be used to deal with the problems that come up in machine learning projects. The main idea of this book is to ask questions, learn, and discover what hasn't been explored before. Developers and experts alike think that combining Rust and machine learning can lead to new discoveries.
📄 Page 6
Although there are technical details, the story does not present them as a declaration of knowledge. Instead, it does so as a conversation, encouraging you to try new things, dig deeper, and help us learn more. Finally, I want to recommend this book to anyone who is interested in what can happen when Rust and machine learning come together. It opens the door to new ideas by showing how the rules of a systems programming language can be combined with machine learning to encourage new ideas. As we turn the pages together, let's start this journey with an open mind and a desire to learn, ready to discover the huge possibilities that lie ahead. At any point, you encounter correction, please do not forget to highlight them up to us at support@gitforgits.com Copyright © 2024 by GitforGits All rights reserved. This book is protected under copyright laws and no part of it may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without the prior written permission of the publisher. Any unauthorized reproduction, distribution, or transmission of this work may result in civil and criminal penalties and will be dealt with in the respective jurisdiction at anywhere in India, in accordance with the applicable copyright laws. Published by: GitforGits Publisher: Sonal Dhandre www.gitforgits.com
📄 Page 7
support@gitforgits.com Printed in India First Printing: January 2024 ISBN: 9788119177936 Cover Design by: Kitten Publishing For permission to use material from this book, please contact GitforGits at support@gitforgits.com.
📄 Page 8
Content Preface GitforGits Acknowledgement Chapter 1: Rust Basics for Machine Learning Machine Learning Landscape Structure and Components of Machine Learning Types of Machine Learning Why Rust for ML? Prospects of Machine Learning Basics of Rust Programming Memory Safety and Ownership Concurrency Error Handling Comprehensive Ecosystem and Package Management Interoperability with Different Languages Cargo and Popular Rust Packages Cargo Overview Managing Dependencies Cargo's Extensibility ndarray and ndarray-linalg Linfa tch-rs and tract Setting up Rust Environment Installing Rust and Cargo Selecting IDE or Text Editor Initializing New Project Installing Essential Packages Testing Environment with Simple Program Structure Machine Learning Projects Root Directory and Workspace Configuration
📄 Page 9
Source Code Organization Data Folder for Datasets and Resources Model Artifacts and Evaluation Metrics Documentation and Notebooks My First Rust Program Setting up Project Directory Creating Main Rust File Importing Library and Initializing Arrays Performing Array Operations Running the Program Organizing Dependencies in Cargo.toml Creating Feature Flags Utilizing Dev and Build Dependencies Versioning in Cargo Rust IDEs Why IntelliJ? Downloading and Installing IntelliJ IDEA Installing Rust Plugin Configuring IDE Creating First Rust Project in IntelliJ Debugging and Testing in IntelliJ Preparing ML Environment for Release Optimizing Code for Release Managing Dependencies and Updating Crates Setting Version Number and Metadata Creating Release Profile Packaging and Distributing the Project Summary Chapter 2: Data Wrangling with Rust Introduction Read CSV Files Adding CSV Crate and File I/O Libraries Reading CSV File
📄 Page 10
Dealing with Headers and Specific Fields Data Validation Storing Records in a Data Structure Data Cleaning with Polars Installing Polars and Importing Data Handling Missing Values Removing Outliers Normalizing and Scaling Features Data Transformation Feature Engineering Creating Polynomial Features Creating Interaction Terms Categorical Variable Encoding Binning and Discretization Normalization and Standardization Plotters and Data Visualization Install Plotters Basic Plot Creation Populating Data Points Advanced Customization Plotting Multiple Series Data Export: JSON, Parquet, Feather and Binary JSON (JavaScript Object Notation) Parquet Feather Native Binary Data Serialization and Deserialization Understanding Serialization Using Serde for Serialization Deserialization in Rust Custom Serialization and Deserialization Summary Chapter 3: Linear Regression by Example
📄 Page 11
Introduction to Linear Regression Overview Linear Regression: Problem Statement Definition Variable Selection and Feature Engineering Data Splitting Feature Scaling Target Variable Popular Linear Regression Strategies Exploratory Data Analysis (EDA) Hypothesis Testing Model Selection Feature Interaction Terms Model Training and Validation Iterative Refinement Interpreting Results and Making Decisions Implement Linear Regression Model Model Training Interpreting Coefficients Model Prediction and Validation Iterative Refinement Other Linear Regression Libraries Rustlearn Smartcore Alumina Evaluate Linear Regression Performance Root Mean Square Error (RMSE) Coefficient of Determination (R-squared) Mean Absolute Error (MAE) Residual Plots Save and Reload Model Serialization using Serde Writing and Reading Files Deserialization and Model Loading
📄 Page 12
Linear Regression Model Deployment Packaging the Model Creating a Web Service Deploying to Server Monitoring and Logging Versioning and Rollback Summary Chapter 4: Logistic Regression for Classification Overview Introduction to Logistic Regression Implement Logistic Regression Problem Statement and Data Splitting Model Training Making Predictions Evaluation Metrics Hyperparameter Tuning Performance Metrics Deep Dive Understanding Accuracy Precision and Recall F1 Score and Confusion Matrix ROC Curve and AUC-ROC Comparing Metrics Model Hyperparameter Tuning Process Grid Search Methodology Random Search Methodology Cross-Validation in Tuning Fine-Tuning and Iterative Process Final Model Training and Verification Sample Program: Hyperparameter Tuning Define Hyperparameter Space and Cross-Validation Grid Search Loop Train and Evaluate the Model Serialize and Deserialize the Model
📄 Page 13
Summary Chapter 5: Decision Trees in Action Introduction to Decision Trees Interpretable and Transparent Model Feature Importance and Selection Handling Categorical and Numerical Data Ensemble Methods and Random Forests Online Purchase Retail Dataset Data Processing for Decision Trees Reading the Excel File and Initial Exploration Handling Missing Values Encoding Categorical Variables Data Splitting Data Normalization Performing Feature Extraction Creating Customer Lifetime Value Temporal Feature Engineering Average Purchase Value Seasonality Features Product Categories Geographical Features Initialize and Train Decision Trees Separate Features and Labels Initialize Decision Tree Model Training the Model Model Evaluation Making Predictions Batch Predictions Model Interpretation Summary Chapter 6: Mastering Random Forests Introduction to Random Forests
📄 Page 14
Random Forest Classifier Architecture Building Random Forest Model Up and Running with RustLearn Defining Random Forest Model Training and Predict Model RustLearn’s Model Evaluation Comparison with Decision Tree Model Creating Respective Models Evaluating Models Model Interpretability Computational Cost Overfitting Feature Importance Tuning Random Forests Hyperparameters Manual Grid Search Randomized Search Cross-Validation Errors and Troubleshooting #1 Overfitting Solution #2 Memory Exhaustion Solution #3 Imbalanced Data Solution #4 High Dimensionality Solution #5 Parallelization Errors Solution #6 Numerical Instabilities Solution #7 Non-Numerical Data Solution #8 Incomplete or Missing Data Solution
📄 Page 15
#9 Incorrect Evaluation Metrics Solution Summary Chapter 7: Support Vector Machines In Action Introduction to Support Vector Machines Types of Support Vector Machines Linear SVM Architecture of Linear SVM Kernel SVM Architecture of Kernel SVM Differences and Commonality SVM Modeling: Data Load, Preprocess and Model Build Coronavirus Tweets Dataset Loading Data with CSV Crate Using Rust's String Methods Using Bag-of-Words or TF-IDF SVM Model Building Perform Training and Predictions Splitting Data into Training and Test Sets Training the SVM Model Making Predictions Assessing Model Accuracy Predictions Evaluation and Hyperparameter Tuning Calculating Accuracy Calculating Precision and Recall Grid Search in Rust Dataset and Model Update Incremental Learning Data Retention Policies Versioning Models Automating Updates Model Rollbacks Model Versioning System
📄 Page 16
Metadata Storage Version Catalog Rollback and Testing Summary Chapter 8: Simplifying Naive Bayes and k-NN Naive Bayes and k-NN Overview Naive Bayes Classifier Architecture Building Naive Bayes Model Building k-NN Model Naive Bayes and k-NN Model Comparison Errors and Troubleshooting #1 Model not Converging Solution #2 File not Found during Serialization/Deserialization Solution #3 Memory Overflow Solution #4 Poor Generalization Solution #5 Inconsistent Data Types Solution #6 Data Imbalance for Classification Solution #7 Feature Scaling Solution #8 Concurrency Issues Solution #9 Incorrect Label Encoding Solution Summary Chapter 9: Crafting Neural Networks with Rust Introduction to Neural Networks
📄 Page 17
Genesis of Neural Networks Breakthroughs and Modern Applications Neural Networks in Today's World Components of Neural Networks Neurons Layers Weight and Biases Activation Functions Loss Function Optimizer Backpropagation NeuroFlow for Neural Networks Install NeuroFlow Adding NeuroFlow to Rust Project Creating Single-Layer Neural Network PyTorch for Neural Networks Core Features of PyTorch Dynamic computational graph Simplicity and Flexibility Strong GPU Acceleration Extensive Libraries TorchScript for Easy Deployment Creating a Neural Network in PyTorch Training a Model in PyTorch Using PyTorch in Rust Exporting PyTorch Model with TorchScript Using Model with tch-rs Setup LibTorch Download LibTorch Extract LibTorch Archive Set Environment Variables Install tch-rs Crate Verify Installation Building Multi-Layer Neural Networks or MLPs
📄 Page 18
Understanding Multi-Layer Neural Networks Using PyTorch to build Multi-Layer Neural Network Training a Multi-Layer Neural Network Using ndarray for MLP Up and Running with ndarray Defining MLP Structure Forward Propagation Convolutional Neural Networks (CNNs) Understanding Convolutions Differentiation from Traditional Neural Networks Convolutional Neural Network Architecture Convolutional Layers Activation Layers Pooling Layers Fully Connected Layers Dropout Layers Normalization Layers Application in Real World Building CNN using PyTorch Define CNN Architecture Initialize Model and Specify Loss Function/Optimizer Train the Model Summary Epilogue
📄 Page 19
GitforGits Prerequisites This book is for aspiring Rust programmers, newbies to machine learning, and to machine learning professionals who want to witness the possibilities of Rust in machine learning. The book just expects you to be eager to explore Rust in machine learning and no other thing is desired to pull this book. Codes Usage Are you in need of some helpful code examples to assist you in your programming and documentation? Look no further! Our book offers a wealth of supplemental material, including code examples and exercises. Not only is this book here to aid you in getting your job done, but you have our permission to use the example code in your programs and documentation. However, please note that if you are reproducing a significant portion of the code, we do require you to contact us for permission. But don't worry, using several chunks of code from this book in your program or answering a question by citing our book and quoting example code does not require permission. But if you do choose to give credit, an attribution typically includes the title, author, publisher, and ISBN. For example, "Machine Learning with Rust by Keiko Nakamura". If you are unsure whether your intended use of the code examples falls under fair use or the permissions outlined above, please do not hesitate to reach out to us at support@gitforgits.com . We are happy to assist and clarify any concerns.
📄 Page 20
CHAPTER 1: RUST BASICS FOR MACHINE LEARNING
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now
Back to List