Build a strong foundation of machine learning algorithms in 7 days Key Features Use Python and its wide array of machine learning libraries to build predictive models Learn the basics of the 7 most widely used machine learning algorithms within a week Know when and where to apply data science algorithms using this guide Book Description Machine learning applications are highly automated and self-modifying, and continue to improve over time with minimal human intervention, as they learn from the trained data. To address the complex nature of various real-world data problems, specialized machine learning algorithms have been developed. Through algorithmic and statistical analysis, these models can be leveraged to gain new knowledge from existing data as well. Data Science Algorithms in a Week addresses all problems related to accurate and efficient data classification and prediction. Over the course of seven days, you will be introduced to seven algorithms, along with exercises that will help you understand different aspects of machine learning. You will see how to pre-cluster your data to optimize and classify it for large datasets. This book also guides you in predicting data based on existing trends in your dataset. This book covers algorithms such as k-nearest neighbors, Naive Bayes, decision trees, random forest, k-means, regression, and time-series analysis. By the end of this book, you will understand how to choose machine learning algorithms for clustering, classification, and regression and know which is best suited for your problem What you will learn Understand how to identify a data science problem correctly Implement well-known machine learning algorithms efficiently using Python Classify your datasets using Naive Bayes, decision trees, and random forest with accuracy Devise an appropriate prediction solution using regression Work with time series data to identify relevant data events and trends Cluster your data using the k-means algorithm Who this book is for This book is for aspiring data science professionals who are familiar with Python and have a little background in statistics. You'll also find this book useful if you're currently working with data science algorithms in some capacity and want to expand your skill set Table of Contents Classification using K Nearest Neighbors Naive Bayes Decision Trees Random Forests Clustering into K clusters Regression Time Series Analysis Python Reference Statistics Glossary of Algorithms and Methods in Data Science Title Page Copyright and Credits Packt Upsell Contributors Table of Contents Preface Classification Using K-Nearest Neighbors Mary and her temperature preferences Implementation of the k-nearest neighbors algorithm Map of Italy example – choosing the value of k Analysis House ownership – data rescaling Analysis Text classification – using non-Euclidean distances Analysis Text classification – k-NN in higher dimensions Analysis Summary Problems Mary and her temperature preference problems Map of Italy – choosing the value of k House ownership Analysis Naive Bayes Medical tests – basic application of Bayes' theorem Analysis Bayes' theorem and its extension Bayes' theorem Proof Extended Bayes' theorem Proof Playing chess – independent events Analysis Implementation of a Naive Bayes classifier Playing chess – dependent events Analysis Gender classification – Bayes for continuous random variables Analysis Summary Problems Analysis Decision Trees Swim preference – representing data using a decision tree Information theory Information entropy Coin flipping Definition of information entropy Information gain Swim preference – information gain calculation ID3 algorithm – decision tree construction Swim preference – decision tree construction by the ID3 algorithm Implementation Classifying with a decision tree Classifying a data sample with the swimming preference decision tree Playing chess – analysis with a decision tree Analysis Classification Going shopping – dealing with data inconsistencies Analysis Summary Problems Analysis Random Forests Introduction to the random forest algorithm Overview of random forest construction Swim preference – analysis involving a random forest Analysis Random forest construction Construction of random decision tree number 0 Construction of random decision tree number 1 Constructed random forest Classification using random forest Implementation of the random forest algorithm Playing chess example Analysis Random forest construction Classification Going shopping – overcoming data inconsistencies with randomness and measuring the level of confidence Analysis Summary Problems Analysis Clustering into K Clusters Household incomes – clustering into k clusters K-means clustering algorithm Picking the initial k-centroids Computing a centroid of a given cluster Using the k-means clustering algorithm on the household income example Gender classification – clustering to classify Analysis Implementation of the k-means clustering algorithm Input data from gender classification Program output for gender classification data House ownership – choosing the number of clusters Analysis Document clustering – understanding the number of k clusters in a semantic context Analysis Summary Problems Analysis Regression Fahrenheit and Celsius conversion – linear regression on perfect data Analysis from first principles Least squares method for linear regression Analysis using the least squares method in Python Visualization Weight prediction from height – linear regression on real-world data Analysis Gradient descent algorithm and its implementation Gradient descent algorithm Implementation Visualization – comparison of the least squares method and the gradient descent algorithm Flight time duration prediction based on distance Analysis Ballistic flight analysis – non-linear model Analysis Analysis by using the least squares method in Python Summary Problems Analysis Time Series Analysis Business profits – analyzing trends Analysis Analyzing trends using the least squares method in Python Visualization Conclusion Electronics shop's sales – analyzing seasonality Analysis Analyzing trends using the least squares method in Python Visualization Analyzing seasonality Conclusion Summary Problems Analysis Python Reference Introduction Python Hello World example Comments Data types int float String Tuple List Set Dictionary Flow control Conditionals For loop For loop on range For loop on list Break and continue Functions Input and output Program arguments Reading and writing a file Statistics Basic concepts Bayesian inference Distributions Normal distribution Cross-validation K-fold cross-validation A/B testing Glossary of Algorithms and Methods in Data Science Other Books You May Enjoy Index Choosing the right algorithm is often a key differentiator in the success or failure of a data model and its optimal performance. This book introduces you to 7 key machine learning algorithms which you can easily grasp within a week and includes exercises that will help you learn different aspects of machine learning without any hassle.