Search

Guide to a Career in Data Science

Data Science is a buzzword in today’s world. Data engineers, data scientists, and data programmers often talk about data science. To put it in simple words, Data Science is an interdisciplinary field where we explore, research, and extract some knowledge out of the structured and unstructured data.  The process of exploration, research, and extraction involves a significant scientific method or principle, relative algorithms, and various statistical mathematics to perform on vast amounts of data to get meaningful insights from it. This data that is extracted and further used by companies or organizations to draw insights for their business goals or solutions.  Every organization today uses data science directly or indirectly, be it giant conglomerates across industries ranging from aerospace to banking and even government bodies.Applications of Data ScienceData Science Components  Statistics: Statistics is a field of Mathematics, which helps in quantifying a large amount of numerical data and helps in analyzing meaningful outcomes.  Visualization: Visualization is the graphical representation of data in a graphical format like Line chart, Pie chart, and many more so that it’s easy to understand the trends and patterns which are also used for the purpose of building predictive models.  Algorithms: There are many algorithms which support various business problems like predictions, classifications, segmentations, recommendations, object detection and image classifications.  Data engineering: Data engineering is a separate field, but the work of Data Engineers helps Data Scientists get structure and filtered data. Extraction, Load and Transformation (ETL) or Extractions, Transformation & Load (ETL) forms a key activity under data engineering.  Prerequisites to a career in Data ScienceThere are certain prerequisites required for an individual to start a career in Data Science which will be discussed below.Prerequisites to a career in Data ScienceAs denoted in the above graph, Data Science is the combination of multiple fields, however, few of them are very prominent and are required as prerequisites like Mathematics, Computer Science basic, and a certain knowledge on Domain expertise.  As Data Scientists deal with the analytics of both structured and unstructured records, in both numeric and alphabetic format, some need to have a basic understanding of statistics because most of the analytical work requires a statistical approach to solve the data science problem.  For implementing the solution while applying a statistical approach, one needs to have a basic understanding of programming languages like Python and R which are very prominent for Data Science. Domain expertise will help gather a deep understanding of certain businesses like banking and finance to solve related use cases. The first step in Data Science is data discovery on a specific data set, which in turn gives access to data on the specific domain or business. This data extracted is then used by the data scientist to project useful insights about the industry that helps business leaders take or make appropriate strategies to benefit the overall business.  Apart from this there are other fields like Machine Learning, which need an in-depth knowledge of core computer science topics like data structure and algorithms that are designed specially to mine the data, cluster the data, and perform other operations of Machine Learning, Deep Learning, and Artificial Intelligence.Artificial intelligence is one of the fields where one needs to have a good grasp of statistical mathematics and core computer science concepts. As a beginner, it can be quite challenging to gain expertise in each of these fields because Data Science is a very vast field.Data Science Life cycleData Science Life cycleBusiness Understanding  Having a business understanding is also one of the vital characteristics of data science. Data scientists need to understand the purpose of their role and also to ask the right questions.   For example, in the banking domain, if the leadership team wants to do the prediction and forecasting of their banking product, the data scientist needs to have a clear understanding of the banking business model and their relevant products, how this product works, and what kind of data or information is associated with this. They need to understand the accurate customer details to look for, how this data is classified, and how one can use the same to make a prediction. Similarly, many other examples can be applied to different domains or industries where business knowledge is required to predict and identify the right customers.Data CollectionData discovery is one of the crucial steps in Data Science and one needs to understand the source of data. This data source usually varies for different domains.   Let’s take the example of the banking business, here, the data is generally saved in a data warehouse or RDBMS or in a private cloud, and to gather this, one requires approval as it is highly classified data. Another example would be of the online retail business, the data for this is usually available on the web or online media using which one can understand consumer behavior and what kind of products they are interested in. In a nutshell, data scientists need to know how to gather data from different sources.Data PreparationData extraction, also called ETL, is how one extracts, transforms and loads the data. The correct data from the source needs to be extracted and standard transforms are performed. This includes data cleaning, which is the removal of unwanted records that do not have any relevance to data analytics; and data standardization, which is preparing the data according to the required format by various machine learning algorithms.Data ModelingIn data modeling, data scientists use a statistical approach to get trends, apply data mining, classification, clustering, and other advanced tools like machine learning, deep learning, and AI-based algorithms.One of the many things you might need to do in modeling is to reduce the dimensionality of your records set. Not all your features or values are important for predicting your model. What you want to do is to select the relevant ones that contribute to the prediction of results. There are a few duties we can perform in modeling. We can also teach models to perform classification of emails you obtained as “Inbox” and “Spam” using logistic regressions. We can also forecast values using linear regressions. We can use modeling of organization information to apprehend the logic behind those clusters. For example, as for an e-commerce institution to recognize the behavior of its users on its website, it needs to identify organizations of record points with clustering algorithms like k-way or hierarchical clustering.  Let’s take the example clustering algorithms, which are generally used to explore the trends and create an individual group from the huge volume of a dataset, these individual groups are formed based on clustering algorithms so that each group has individual trends which are analyzed by the Data scientist. An Machine Learning expert can go beyond that and perform more complex algorithms on the same and get a prediction beyond that. Generally, they use the predictive analysis algorithm and supervised learning algorithm which is performed on a high volume of historical data and perform the iterative train on the model, which is further used to build the prediction.   Interpreting Data Now we got the resultant dataset, so now the next step is how to interpret the resulting data, so that management can understand and take the executive decision accordingly. Generally, the interpretation happens by exploring it and constructing graphs. When you are dealing with massive volumes of statistics, visualization is the first-class way to explore and communicate your findings and is the next segment of your records analytics project. Now the big catch here is, how to communicate to the leadership or management team and effectively convey the result is one in all the most underrated abilities a data scientist can have. While several data scientists ought to have the ability to communicate with other teams and effectively translate their work for maximum impact. This set of skills is frequently called ‘information storytelling.’ You take the statistics on the present-day possibilities that the income crew is pursuing, run it through your model, and rank them in a spreadsheet within the order of most to least likely to convert. You provide the spreadsheet for your VP of Sales.   Practical In this session, we will talk about some of the prominent algorithms, which are implemented in most of the Data science projects. Linear regression Linear regression is one of the highly adaptable algorithms when it comes to the prediction, Linear regression is used in supervised learning, which comes under the Machine learning use case. This algorithm works on iterative approach where we are targeting the model values based on an independent dataset and calculate the closer, which thus forms the linear equation. In layman terms, this helps to form the relationship between input values and target output. As stated earlier, this algorithm helps to do the predictive analysis. Below is the equation for the same. Y= MX+C  Where, y= Dependent variable X= independent variable M= slope C= intercept. K-Means Clustering   K-means clustering, an unsupervised learning algorithm, is another prominent algorithm of machine learning, which generally performs clustering using the historical dataset. This algorithm is useful in instances when we have a data set of items to be categorized into groups. This method requires a good understanding of statistical mathematics.Application of Data Science Thanks to faster computing and cheaper storage, we can now predict outcomes in minutes that would take several human hours to process. In this section, we’ve rounded up seven examples of data science at work, across industries from gaming to healthcare. Image and Speech RecognitionImage reorganization is generally applied in social media when the algorithm helps the user match and find friends for any given suggestion. Speech recognition is mostly seen on mobile handsets like SIRI for the iPhone, where you get to give instructions to SIRI to perform a task.GamingMachine learning algorithms are used widely in gaming to capture and analyze the user experience and enrich features and gaming functionalities.Internet Search Internet search engines like Google, Bing, and Yahoo capture user behavior and refine the search data as per the keyword so that the most frequently visited page ranks on top.  Transport or Maps navigation system Google maps show many routes from point A (source) to point B (target). When a user finds a new way, Google map trains the model again, so that it can now add on a new route. The map navigation too detects the pattern of driving and calculates the time frame to reach the destination. Healthcare Healthcare has seen some of the most prominent implementations of Data Science. Drug discovery, tumor detection, breast cancer detection, medical image analysis, and many more key applications have demonstrated the importance of data science in this field. Recommendation Systems Recommendation systems are one of the more profitable systems, mostly used by online retail companies to analyze the user’s purchasing behavior. The data gathered helps the system come up with suggestions of relevant products that the customer may be interested to purchase. Banking and Finance The Banking and financial institutions predominately apply the Data science approach to calculate the credit score, while providing the loans to customers. This helps banks and financial institutions to minimize the risk of non-payment. A similar approach is adopted by credit card companies as well. Conclusion The Data Science field is one of the booming technologies, and as per Gartner prediction the scope of this field will be there till the next 10-15 years and many discoveries will be taking birth in the field. Data Science can be used to increase productivity in many fields and inventions in the manufacturing field and self-driving cars only stand to prove this right.  However, the negative consequence of this is that it will proportionally decrease human intervention which can cause great unemployment. Finding a balance between how much automation or artificial intelligence is required, can leverage both human and artificial intelligence to go hand-in-hand. With the way data science is growing presently, it is evident that there will always be a scope for a data scientist as every business is looking for growth.
Rated 4.0/5 based on 15 customer reviews

Guide to a Career in Data Science

9K
Guide to a Career in Data Science

Data Science is a buzzword in today’s world. Data engineers, data scientists, and data programmers often talk about data science. To put it in simple words, Data Science is an interdisciplinary field where we explore, research, and extract some knowledge out of the structured and unstructured data.  

The process of exploration, research, and extraction involves a significant scientific method or principle, relative algorithms, and various statistical mathematics to perform on vast amounts of data to get meaningful insights from it. This data that is extracted and further used by companies or organizations to draw insights for their business goals or solutions.  

Every organization today uses data science directly or indirectly, be it giant conglomerates across industries ranging from aerospace to banking and even government bodies.

Applications of Data Science

Applications of Data Science

Data Science Components  

  • Statistics: Statistics is field of Mathematics, which helps in quantifying large amount of numerical data and helps in analyzing meaningful outcomes.  
  • Visualization: Visualization is the graphical representation of data in graphical format like Line chart, Pie chart, and many more so that it’s easy to understand the trends and patterns which are also used for the purpose of building predictive models.  
  • AlgorithmsThere are many algorithms which support various business problems like predictions, classifications, segmentations, recommendations, object detection and image classifications.  
  • Data engineering: Data engineering is a separate field, but the work of Data Engineers helps Data Scientists get structure and filtered data. Extraction, Load and Transformation (ETL) or Extractions, Transformation & Load (ETL) forms a key activity under data engineering.  

Prerequisites to a career in Data Science

There are certain prerequisites required for an individual to start a career in Data Science which will be discussed below.

Prerequisites to a career in Data Science

Prerequisites to a career in Data Science

As denoted in the above graph, Data Science is the combination of multiple fields, however, few of them are very prominent and are required as prerequisites like Mathematics, Computer Science basic, and certain knowledge on Domain expertise.  

As Data Scientists deal with the analytics of both structured and unstructured records, in both numeric and alphabetic format, some need to have basic understanding of statistics because most of the analytical work requires statistical approach to solve the data science problem.  

For implementing the solution while applying a statistical approach, one needs to have a basic understanding of programming languages like Python and R which are very prominent for Data Science. 

Domain expertise will help gather a deep understanding of certain businesses like banking and finance to solve related use cases. The first step in Data Science is data discovery on a specific data set, which in turn gives access to data on the specific domain or business. This data extracted is then used by the data scientist to project useful insights about the industry that helps business leaders take or make appropriate strategies to benefit the overall business.  

Apart from this there are other fields like Machine Learning, which need an in-depth knowledge of core computer science topics like data structure and algorithms that are designed specially to mine the data, cluster the data, and perform other operations of Machine Learning, Deep Learning, and Artificial Intelligence.

Artificial intelligence is one of the fields where one needs to have a good grasp of statistical mathematics and core computer science concepts. As a beginner, it can be quite challenging to gain expertise in each of these fields because Data Science is a very vast field.

Data Science Life cycle

Data Science Life cycleData Science Life cycle

Business Understanding  

Having a business understanding is also one of the vital characteristics of data science. Data scientists need to understand the purpose of their role and also to ask the right questions.  

For example, in the banking domain, if the leadership team wants to do the prediction and forecasting of their banking product, the data scientist needs to have a clear understanding of the banking business model and their relevant products, how this product works, and what kind of data or information is associated with this. They need to understand the accurate customer details to look for, how this data is classified, and how one can use the same to make a prediction. Similarly, many other examples can be applied to different domains or industries where business knowledge is required to predict and identify the right customers.

Data Collection

Data discovery is one of the crucial steps in Data Science and one needs to understand the source of data. This data source usually varies for different domains.  

Let’s take the example of the banking business, here, the data is generally saved in a data warehouse or RDBMS or in a private cloud, and to gather this, one requires approval as it is highly classified data. Another example would be of the online retail business, the data for this is usually available on the web or online media using which one can understand consumer behavior and what kind of products they are interested in. In a nutshell, data scientists need to know how to gather data from different sources.

Data Preparation

Data extraction, also called ETL, is how one extracts, transforms and loads the data. The correct data from the source needs to be extracted and standard transforms are performed. This includes data cleaning, which is the removal of unwanted records that do not have any relevance to data analytics; and data standardization, which is preparing the data according to the required format by various machine learning algorithms.

Data Modeling

In data modeling, data scientists use a statistical approach to get trends, apply data mining, classification, clustering, and other advanced tools like machine learning, deep learning, and AI-based algorithms.

One of the many things you might need to do in modeling is to reduce the dimensionality of your records set. Not all your features or values are important for predicting your model. What you want to do is to select the relevant ones that contribute to the prediction of results. There are a few duties we can perform in modeling. We can also teach models to perform classification of emails you obtained as “Inbox” and “Spam” using logistic regressions. We can also forecast values using linear regressions. We can use modeling of organization information to apprehend the logic behind those clusters. For example, as for an e-commerce institution to recognize the behavior of its users on its website, it needs to identify organizations of record points with clustering algorithms like k-way or hierarchical clustering.  

Let’s take the example clustering algorithms, which are generally used to explore the trends and create an individual group from the huge volume of dataset, these individual groups are formed based on clustering algorithms so that each group has individual trends which are analyzed by the Data scientist. An Machine Learning expert can go beyond that and perform more complex algorithms on the same and get a prediction beyond that. Generally, they use the predictive analysis algorithm and supervised learning algorithm which is performed on high volume of historical data and perform the iterative train on the model, which is further used to build the prediction.   

Interpreting Data 

Now we got the resultant dataset, so now the next step is how to interpret the resulting data, so that management can understand and take the executive decision accordingly. Generally, the interpretation happens by exploring it and constructing graphs. When you are dealing with massive volumes of statistics, visualization is the first-class way to explore and communicate your findings and is the next segment of your records analytics project. Now the big catch here is, how to communicate to the leadership or management team and effectively convey the result is one in all the most underrated abilities a data scientist can have. While several data scientists ought to have the ability to communicate with other teams and effectively translate their work for maximum impact. This set of skills is frequently called ‘information storytelling.’ You take the statistics on the present-day possibilities that the income crew is pursuing, run it through your model, and rank them in a spreadsheet within the order of most to least likely to convert. You provide the spreadsheet for your VP of Sales.   

Practical 

In this session, we will talk about some of the prominent algorithms, which are implemented in most of the Data science projects. 

Linear regression 

Linear regression is one of the highly adaptable algorithms when it comes to the prediction, Linear regression is used in supervised learning, which comes under the Machine learning use case. 

This algorithm works on iterative approach where we are targeting the model values based on an independent dataset and calculate the closer, which thus forms the linear equation. In layman terms, this helps to form the relationship between input values and target output. As stated earlier, this algorithm helps to do the predictive analysis. Below is the equation for the same. 

Y= MX+C  

Where, y= Dependent variable 

X= independent variable 

M= slope 

C= intercept. 

Graph

K-Means Clustering  

 K-means clustering, an unsupervised learning algorithm, is another prominent algorithm of machine learning, which generally performs clustering using the historical dataset. This algorithm is useful in instances when we have a data set of items to be categorized into groups. This method requires a good understanding of statistical mathematics.

Application of Data Science 

Thanks to faster computing and cheaper storage, we can now predict outcomes in minutes that would take several human hours to process. In this section, we’ve rounded up seven examples of data science at work, across industries from gaming to healthcare. 

  • Image and Speech Recognition

Image reorganization is generally applied in social media when the algorithm helps the user match and find friends for any given suggestion. Speech recognition is mostly seen on mobile handsets like SIRI for the iPhone, where you get to give instructions to SIRI to perform a task.

  • Gaming

Machine learning algorithms are used widely in gaming to capture and analyze the user experience and enrich features and gaming functionalities.

  • Internet Search 

Internet search engines like Google, Bing, and Yahoo capture user behavior and refine the search data as per the keyword so that the most frequently visited page ranks on top.  

  • Transport or Maps navigation system 

Google maps show many routes from point A (source) to point B (target). When a user finds a new way, Google map trains the model again, so that it can now add on a new route. The map navigation too detects the pattern of driving and calculates the time frame to reach the destination. 

  • Healthcare 

Healthcare has seen some othe most prominent implementations of Data Science. Drug discovery, tumor detection, breast cancer detection, medical image analysis, and many more key applications have demonstrated the importance of data science in this field. 

  • Recommendation Systems 

Recommendation systems are one of the more profitable systems, mostly used by online retail companies to analyze the user’s purchasing behaviorThe data gathered helps the system come up with suggestions of relevant products that the customer may be interested to purchase. 

  • Banking and Finance 

The Banking and financial institutions predominately apply the Data science approach to calculate the credit score, while providing the loans to customers. This helps banks and financial institutions to minimize the risk of non-paymentA similar approach is adopted by credit card companies as well. 

Conclusion 

The Data Science field is one of the booming technologies, and as per Gartner prediction the scope of this field will be there till the next 10-15 years and many discoveries will be taking birth in the field. Data Science can be used to increase productivity in many fields and inventions in the manufacturing field and self-driving cars only stand to prove this right.  

However, the negative consequence of this is that it will proportionally decrease human intervention which can cause great unemployment. Finding a balance between how much automation or artificial intelligence is requiredcan leverage both human and artificial intelligence to go hand-in-hand. With the way data science is growing presently, it is evident that there will always be a scope for a data scientist as every business is looking for growth.

KnowledgeHut

KnowledgeHut

Author

KnowledgeHut is an outcome-focused global ed-tech company. We help organizations and professionals unlock excellence through skills development. We offer training solutions under the people and process, data science, full-stack development, cybersecurity, future technologies and digital transformation verticals.
Website : https://www.knowledgehut.com

Join the Discussion

Your email address will not be published. Required fields are marked *

Suggested Blogs

Role of Statistics in Data Science

Takeaways from this article In this article, we understand why data is important, and talk about the importance of statistics in data analysis and data science. We also understand some basic statistics concepts and terminologies. We see how statistics and machine learning work in sync to give deep insights into data.  We understand the fundamentals behind Bayesian thinking and how Bayesian theorem works. Introduction Data plays a huge role in today’s tech world. All technologies are data-driven, and humongous amounts of data are produced on a daily basis. A data scientist is a professional who is able to analyse data sources, clean and process the data, understand why and how such data has been generated, take insights from it, and make changes such that they profit the organization. These days, everything revolves around data.  Data Cleaning: It deals with gathering the data and structuring it so that it becomes easy to pass this data as input to any machine learning algorithm. This way, redundant, irrelevant data and noise can also be eliminated.  Data Analysis: This deals with understanding more about the data, why the data has yielded certain results, and what can be done to improve it. It also helps calculate certain numerical values like mean, variance, the distributions, and the probability of a certain prediction.  How the basics of statistics will serve as a foundation to manipulate data in data scienceThe basics of statistics include terminologies, and methods of applying statistics in data science. In order to analyze the data, the important tool is statistics. The concepts involved in statistics help provide insights into the data to perform quantitative analysis on it. In addition to this, as a foundation, the basics and working of linear regression and classification algorithms must also be known to a data science aspirant.  Terminologies associated with statistics Population: It is an entire pool of data from where a statistical sample is extracted. It can be visualized as a complete data set of items that are similar in nature.  Sample: It is a subset of the population, i.e. it is an integral part of the population that has been collected for analysis.  Variable: A value whose characteristics such as quantity can be measured, it can also be addressed as a data point, or a data item.  Distribution: The sample data that is spread over a specific range of values.  Parameter: It is a value that is used to describe the attributes of a complete data set (also known as ‘population’). Example: Average, Percentage  Quantitative analysis: It deals with specific characteristics of data- summarizing some part of data, such as its mean, variance, and so on.  Qualitative analysis: This deals with generic information about the type of data, and how clean or structured it is.  How does analyzing data using statistics help gain deep insights into data? Statistics serve as a foundation while dealing with data and its analysis in data science. There are certain core concepts and basics which need to be thoroughly understood before jumping into advanced algorithms.  Not everyone understand the performance metrics of machine learning algorithms like f-score, recall, precision, accuracy, root mean squared error, and so on. Instead, visual representation of the data and the performance of the algorithm on the data serves as a good metric for the layperson to understand the same.  Also, visual representation helps identify outliers, specific trivial patterns, and certain metric summary such as mean, median, variance, that helps in understanding the middlemost value, and how the outlier affects the rest of the data.  Statistical Data Analysis Statistical data analysis deals with the usage of certain statistical tools that need knowledge of statistics. Software can also help with this, but without understanding why something is happening, it is impossible to get considerable work done in statistics and data science.  Statistics deals with data variables that are either univariate or multivariate. Univariate, as the name suggests deals with single data values, whereas multivariate data deals with the multiple number of values. Discriminant data analysis, factor data analysis can be performed on multivariate data. On the other hand, univariate data analysis, Z-test, F-test can be performed if we are dealing with univariate data.  Data associated with statistics is of many types. Some of them have been discussed below. Categorical data represents characteristics of people, such as marital status, gender, food they like, and so on. It is also known as ‘qualitative data’ or ‘yes/no data’. It takes numerical values like ‘1’, ‘2’, where these numbers indicate one or other type of characteristics. These numbers are not mathematically significant, which means it can’t be associated with each other. Continuous data deals with data that is immeasurable, and can’t be counted, which basically continual forms of values are. Predictions from a linear regression are continuous in nature. It is a continuous distribution that is also known as probability density function. On the other hand, discrete values can be measured, counted, and are discontinuous. Predictions from logistic regression are considered to be discrete in nature. Discrete data is non-continuous, and density concept doesn’t come into the picture here. The distribution is known as probability mass function. The Best way to Learn Statistics for Data Science The best way to learn anything is by implementing it, by working on it, by making mistakes and again learning from it.  It is important to understand the concepts, either by going through standard books or well-known websites, before implementing them.  Before jumping into data science, the core statistics concepts like such as regression, maximum likelihood, distributions, priors, posteriors, conditional probability, Bayesian theorem and basics of machine learning have to be understood clearly. Core statistics concepts Descriptive statistics: As the name suggests, it uses the data to give out more information about every aspect of the data with the help of graphs, plots, or numbers. It organizes the data into a structure, and helps think about the attributes that highlight the important parts of the data. Inferential statistics: It deals with drawing inferences/conclusions on the sample data set which is obtained from the population (entire data set) based on the relationship identified between data points in the data set. It helps in generalizing the relationship to the entire dataset. It is important to remember that the dataset drawn from the population is relevant and represents the population accurately. Regression: The term ‘regression’ which is a part of statistics and machine learning, talks about how data can be fit to a line, and how every point from the straight line gives some insights. In terms of machine learning, it can be understood as tasks that can be solved without explicitly being programmed. They discuss how a line can be fit to a given set of data points, and how it can be further extrapolated for the predictions to be done.  Maximum likelihood: It is a method that helps in finding values of parameters for a specific model. The values of the parameters have to be such that the likelihood of the predictions that occur have to be maximum in comparison to the data values that were actually observed. This means the difference between the actual and predicted value has to be less, thereby reducing the error and increasing the accuracy of the predictions.  Note: This concept is generally used with Logistic regression when we are trying to find the output as 0 or 1, yes or no, wherein the maximum likelihood tells about how likely a data point is near to 0 or 1.  Bayesian thinking Bayesian thinking deals with using probability to model the process of sampling, and being able to quantify the uncertainty associated with the data that would be collected.  This is known as prior probability- which means the level of uncertainty that is associated with the data before it is collected to be analysed.  Posterior probability deals with the uncertainty that occurs after the data has been collected.  Machine learning algorithms are usually focussed on giving the best predictions as output with minimal errors, exact probabilities of specific events occurring and so on. Bayes theorem is a way of calculating the probability of a hypothesis (a situation, which might not have occurred in reality) based on our previous experiences and the knowledge we have gained by it. This is considered as a basic concept that needs to be known.  Bayes theorem can be stated as follows: P(hypo | data) = (P(data | hypo) * P(hypo)) / P(data)In the above equation,   P(hypo | data) is the probability of a hypothesis ‘hypo’ when data ‘data’ is given, which is also known as posterior probability.   P(data | hypo) is the probability of data ‘data’ when the specific hypothesis ‘hypo’ is known to be true.   P(hypo) is the probability of a hypothesis ‘hypo’ being true (irrespective of the data in hand), which is also known as prior probability of ‘hypo’.   P(data) is the probability of the data (irrespective of the hypothesis). The idea here is to get the value of the posterior probability, given other data. The posterior probability for a variety of different hypotheses has to be found out, and the probability that has the highest value is selected. This is known as the maximum probable hypothesis, and is also known as the maximum a posteriori (MAP) hypothesis.MAP(hypo) = max(P(hypo | data))If the value of P(hypo | data) is replaced with the value we saw before, the equation would become:MAP(hypo) = max((P(data | hypo) * P(hypo)) / P(data))P(data) is considered as a normalizing term that helps in determining the probability. This value can be safely ignored when required, since it is a constant value. Naïve Bayes classifier   It is an algorithm that can be used with binary or multi-class classification problems. It is a simple algorithm wherein the probability for every hypothesis is simplified.   This is done in order to make the data more traceable. Instead of calculating value of every attribute like P(data1, data2,..,datan|hypo), we assume that every data point is independent of every other data point in the data set when the respective output is given.   This way, the equation becomes:P(data1 | hypo) * P(data2 |hypo) * … * P(data-n| hypo).This way, the attributes would be independent of each other. This classifier performs quite well even in the real world with real data when the assumption of data points being independent of each other doesn’t hold good.  Once a Naïve Bayes classifier has learnt from the data, it stores a list of probabilities in a data structure. Probabilities such as ‘class probability’ and ‘condition probability’ are stored. Training such a model is quick since the probability of every class and its associated value needs to be determined, and this doesn’t involve any optimization processes or changing of coefficient to give better predictions.   Class probability: It tells about the probability of every class that is present in the training dataset. It can be calculated by finding the frequency of values that belongs to each class divided by the total number of values.  Class probability = (number of classes/(number of classes of group 0 + number of classes of group 1)) Conditional probability: It talks about the conditional probability of every input that is associated with a class value. It can be calculated by finding the frequency of every data attribute in the data for a given class, and this can be determined by the number of data values that have that data label/class value.  Conditional probability P(condition | result ) = number of ((values with that condition and values with that result)/ (number of values with that result)) Not just the concept, once the user understands the way in which a data scientist needs to think, they will be able to focus on getting cleaner data, with better insights that would lead to performing better analysis, which in turn would give great results.  Introduction to Statistical Machine Learning The methods used in statistics are important to train and test the data that is used as input to the machine learning model. Some of these include outlier/anomaly detection, sampling of data, data scaling, variable encoding, dealing with missing values, and so on.  Statistics is also essential to evaluate the model that has been used, i.e. see how well the machine learning model performs on a test dataset, or on data that it has never seen before.  Statistics is essential in selecting the final and appropriate model to deal with that specific data in a predictive modelling situation.  It is also needed to show how well the model has performed, by taking various metrics and showing how the model has fared.  Metrics used in Statistics Most of the data can be fit to a common pattern that is known as Gaussian distribution or normal distribution. It is a bell-shaped curve that can be used to summarize the data with the below mentioned two parameters:  Mean: It is understood as the central most value when the data points are arranged in a descending or ascending order, or the most likely value.Mode: It can be understood as the data point that occurs the greatest number of times, i.e. The frequency of the value in the dataset would be very high.  Median: It is a measure of central tendency of the data set. It is the middle number, that can be found by sorting all the data points in a dataset and picking the middle-most element. If the number of data points in a dataset is odd, one single middle value is picked up, whereas two middle values are picked and their mean is calculated if the number of data points in a dataset is even. Range: It refers to the value that is calculated by finding the difference between the largest and the smallest value in a dataset. Quartile: As the name suggests, quartiles are values that divide the data points in a dataset into quarters. It is calculated by sorting the elements in order and then dividing the dataset into 4 equal parts. Three quartiles are identified: The first quartile that is the 25th percentile, the second quartile which is the 50th percentile and the third quartile that is the 75th percentile. Each of these quartiles tells about the percentage of data that is smaller or larger in comparison to other percentiles of data. Example: 25th percentile suggests that 25 percent of the data set is smaller than the remaining 75 percent of the data set. Quartile helps understand how the data is distributed around the median (which is the 50th percentile/second quartile). There are other distributions as well, and it depends on the type of data we have and the insights we need from that data, but Gaussian is considered as one of the basic distributions. Variance: The average of the difference between every value and the mean of that specific distribution.  Standard deviation: It can be understood as the measure that indicates the dispersion that occurs in the data points of the input data.  Conclusion In this post, we understood why and how statistics is important to understand and work with data science. We saw a few terminologies of statistics that are essential in understanding the insights which statistics would end up giving to data scientist. We also saw a few basic algorithms that every data scientist needs to know, in order to learn other advanced algorithms.  
Rated 4.0/5 based on 11 customer reviews
5426
Role of Statistics in Data Science

Takeaways from this article In this article, we u... Read More

Getting Started With Machine Learning With Python: Step by Step Guide

Takeaways from the article This article helps you understand the cases wherein Machine learning can be used, and where it is relevant (and where it is not). It discusses the basic steps involved in a machine learning problem, along with code in Python. It discusses how the data involved in a Machine Learning problem can be visualized using certain Python packages.  Introduction  Machine Learning has remained a hot topic since many years. Many know how to make sense of it, and where it can actually be used. It is not a universal solution to all the challenging problems out there (that are difficult to be solved) in the universe. It can only be used when certain conditions are satisfied. Only then does a problem qualify to be solved using a Machine Learning algorithm. In general, Python is the most preferred language to work with algorithms that involve Machine Learning.  Introduction to Machine Learning Machine Learning, also known as ML in short, is a sub-topic that falls under Artificial Intelligence (AI), to achieve specific goals. ML is the art of understanding or designing an algorithm that can be used to process large or small amounts of data. This algorithm will not explicitly define or set the rules for the machine to learn from the data. The machine learns from the data on its own. There are no ‘if’ or ‘else’ statements to guide the machine.    This is very much similar to how humans learn from their experiences in day-to-day life, how a child learns to ride a bike, how a child learns to read letters, then words, then sentences, and conversations.  Getting started with Machine learning in Python Python has been used to implement machine learning algorithms, since it is open-source, extremely popular and has gained immense support from the community as well. In addition to this, there are loads of packages in Python, and they support usage of machine learning algorithms for a variety of version of Python application.  These algorithms can be implemented in python by calling simple functions and these functions are placed inside classes. In turn, these classes are encapsulated in a module as a package.  The ‘scikit-learn’ package for Python is one of the most popular and has most of the machine learning algorithms pre-implemented, and housed inside packages. To implement an algorithm, the package can be imported (or a specific class from the package can be imported) and it can be bound with the variable or the class object using a dot operator and accessed. In general, to begin implementing any machine learning algorithm, the following steps can serve as a blue-print: Define your problem, and confirm that it can be solved using machine learning (so that it is not a trivial “set of rules” related problem) Prepare the data: In this step, the data needed for this model is collected from various resources. Another way is to generate data using the innumerable functions that are present in Python. In either case, the data has to be cleaned, structured, analysed, and the outliers have to be identified. Also, the data has to be pre-processed so that it is easy for the algorithm to build a model based on the data. Certain irrelevant columns maybe removed, and missing data should be handled.  The data needs to be trained and hyperparameters need to be tuned so as to get better prediction accuracy.  Note: It is understood that the users have Python 3.5 or a higher stable version installed on their workstations before beginning to execute the code in the upcoming sections. Other packages can be installed as and when required.  Where Machine Learning can be used?The simplest place is when there is no prediction or complex data insight needed, it need not be used.  Machine Learning algorithm are built by humans to help understand data better, make predictions etc. When we try to solve a problem, there are certain principles that we hold as a foundation (when dealing with physics- gravity, newton’s law) but algorithms don’t. They are stochastic (random) in nature.  Not all problems that have a large amount of data is suited to work with Machine Learning algorithms. It is important to understand the deterministic nature of problems, and try to avoid solving such problems using Machine Learning.  Machine Learning in PythonLet us jump into a simple problem of linear regression using Machine learning, Linear regression is a simple algorithm that predicts the value of a variable, based on certain other values. There are many variations to Linear Regression that includes Multi-variate regression, etc.   Before jumping into the algorithm, let us understand what linear regression means. ‘Linear’ basically means a straight line, and ‘regression’ which is a part of machine learning, talks about how tasks can be solved without explicitly being programmed.   There are various machine learning algorithms, and Linear Regression is just the beginning to it. This includes supervised learning, unsupervised learning, semi-supervised learning and reinforcement learning.Why should Machine Learning be used? Certain task needs intricate detailing, and patterns might not be fully unveiled if manual or simple methods are used to extract patterns. Machine learning, on the other hand, will be able to extract all important, hidden patterns, and work well even when the amount of data increases exponentially. It also becomes easy to improve pattern recognition. It will also be possible to deliver results in a time manner, get deeper and better insights into the data in hand.   The results computed using a Machine Learning algorithm would be more accurate in comparison to traditional methods, and the models build can serve as a foundation for other data as well. There are different classifications in machine learning, depending on various types. The 4 basic classifications are:Supervised learning algorithms Semi-supervised learning algorithms Unsupervised learning algorithms  Reinforcement learning algorithmsMachine learning algorithms can also be classified based on how they learn- on the fly or incrementally, into 2 types:Online learning Batch learningMachine learning algorithms can also be classified based on how they detect patterns- whether they detect patterns in data or compare new data values with previously seen data values:Model-based learning  Instance-based learning Supervised LearningMost popular Easy to understand Easier to implement Gives decent results Expensive, since human intervention is requiredSupervised learning involves human supervision. In real-time, supervision is present in the form of labelled features, feedback loop to the data (insights on whether the machine predicted correctly, and if not, what the correct prediction has to be) and so on.  Once the algorithm is trained on such data, it can predict good outputs with a high accuracy for never-before-seen inputs. Applications of supervised learning:Spam classification: Classifying emails as spam or important.  Face recognition: Detecting faces, mapping them to a specific face in a database of faces. Supervised algorithms can further be classified into two types:Classification algorithms: They classify the given data into one of the given classes or group of data. This basically deals with data grouping/data mapping into specific classes.   Regression algorithms: This deals with fitting the data to a given model, predicting continuous or discrete values.   Semi-supervised LearningIn between the supervised and unsupervised learning algorithms.   Created to bridge the gap between dealing with fully structured and fully unstructured data.   Comes between supervised and unsupervised algorithms.   Input is a combination of unlabelled (more) and labelled (less) data.Applications of semi-supervised learning algorithms:Speech analysis, sentiment analysis Content classificationUnsupervised LearningNo data labelling No human intervention May not be very accurate Can’t be applied to a broad variety of situations Algorithm has to figure out how and what to learn from the data Similar to real-world unstructured data Can’t be applied to a broad variety of situationsApplications of unsupervised learning:Clustering Anomaly detectionUnsupervised data can be classified into two categories:Clustering algorithms Association algorithmsReinforcement LearningIt is a ‘punish and reward’ mechanism. Learns from surrounding and experience. An agent decides the next relevant step to arrive at the desired result.   If algorithm learns correctly, then it is rewarded indicating that it is on the right path. If the algorithm made a mistake, it is punished to indicate the mistake and to learn from it.Supervised learning algorithm is different from reinforcement, since the former has a comparable value, whereas the latter has to decide the next action and take it and bear the result and learn from it.Applications of reinforcement learning:Robotics in automation   Machine learning and data processingOther types of learning algorithmsOnline learning Batch learning: It has two different categories: Model-based learning, and instance-based learningOnline LearningAlso known as incremental/out of the core learning. Assumption is that the learning environment changes constantly.Machine learning models that are trained consistently and constantly on new data to predict output. On the other hand, during this period, the model is getting trained on new data in real time. Whenever the model sees a new example, it quickly has to learn from it and adapt to it. This way, even the newly learnt example will be a part of the trained model, and will be a part of giving the prediction/output.Batch LearningThis is also known as data learning in a group.  Data is grouped/classified into different batches.  There batches are used to extract different patterns since every batch would be considerably different from the other one. These patterns are learned by the model in time.  Model-based learningThe specifications associated with a problem in a domain is converted into a model-format. When this model sees new data, it detects patterns from it, and these patterns are used to make predictions on the newly seen data.   Instance-based learningIt is the simplest form of clustering and regression algorithms.They either result in grouping the algorithm into different classes (due to classification) or give continuous or discrete values as output (due to linear or logistic regression).Classification and regression is based on how similar or different the queries are, with respect to the values in the data.Linear RegressionIn this algorithm, we will understand the problems with two different variables in hand- one is an independent variable, and the other one- a dependant variable. We will take a basic problem of finding prices of a house when its area is given. Assume that we have the below dataset:Price of house (independent value)Area of the house (dependant value)356500 sq m5781000 sq m8901500 sq m13002000 sq m18002500 sq m?3000 sq mWhen the above data is given, and the price of house is asked to be found (see last row), given the area of the house, simple linear regression (that gives a decent amount of accuracy) can be used. Below is how the data will look when plotted on a graph. It yields an almost straight line, which means the dependant value depends on the independent value, i.e the area of the house matters when the price of the house is being fixed.The basic steps involved in a machine learning problem-  Identify the problem: see if it qualifies to be solved using a Machine Learning algorithm.  Gather the data: The data required can either be collected from a single source or various source, or it could be generated randomly (if it is for a specific purpose) using certain formulas and methods.  Data cleaning: The data gathered may not be clean or structured, make sure it is cleaned, and in a structured or at least semi-structured format.  Package installation: Install the packages that are required to work with the data.  Data loading: Load the data into the Python environment using any IDE (Usually, Spyder is preferred). This is done so that the machine learning algorithm can access the data and perform the operations.  Data cleaning: Data can be cleaned after it has been placed in the Python environment using certain packages and methods, or it can be cleaned before (manually or by applying some logic).  Summarize the data: Understand the terms we are looking at, perform some operations on them, get the type of value, mean, median, variance, and standard deviation, which are insights into the data. This can be done easily by importing packages that have these functions. Data training: In this step, the input dataset is trained by passing it as parameter to the respective algorithm. This is done so that it can predict the output for the not-ever-seen data also known as testing dataset.  Linear Regression application: Apply the Linear Regression algorithm to this data. Data visualization: The data that has interacted with the linear regression algorithm is visualized using many Python packages. Prediction: The predictions are made with the help of the data trained, and are then displayed on the console. Code for Linear Regression using Python Code to implement linear regression using Python  import numpy as np  import matplotlib.pyplot as plt  from sklearn.metrics import mean_squared_error, r2_score  from sklearn.linear_model import LinearRegression    #Random data set generated  np.random.seed(0)  x_dep = np.random.rand(100, 1)  y_indep = 5.89 + (2.45)* x_dep + np.random.rand(100, 1)    #The model is initialized using LinearRegression that is present in the scikit-learn package  model_of_regression = LinearRegression()    #The data is fit on the model, with the help of training  model_of_regression.fit(x_dep, y_indep)    #The output is predicted   predicted_y_val = model_of_regression.predict(x_dep)    #The model built is evaluated using mean squared error parameter  rmse = mean_squared_error(y_indep, predicted_y_val)    r2 = r2_score(y_indep, predicted_y_val)    print("The value of slope is: ", model_of_regression.coef_)  print("The intercept value is: ", model_of_regression.intercept_)  print("The Root Mean Squared Error value (RMSE) is: ", rmse)    #The data is visualized usign the matplotlib library  plt.scatter(x_dep, y_indep, s=8)  plt.xlabel('X-axis')  plt.ylabel('Y-axis')    #The values are predicted and plotted on a graph and displayed on the screen  plt.plot(x_dep, predicted_y_val, color='r')  plt.show() Output:Code review-Explanation of every step  The required packages are imported using the ‘import’ keyword.  Make sure that ‘scikit-learn’ package is installed before working on this code.  Instead of using precooked data, we are generating data here, using the ‘random’ function.  A seed is defined, and a formula is created that assumes random values for variables and generates random data.  The ‘LinearRegression’ function, present in the ‘scikit-learn’ package is initiated so as to create a model, and one of the functions inside the LinearRegression package-namely ‘fit’ is called by passing the dependant and the independent values.  The ‘predict’ function from the LinearRegression is used to predict the value that is not known for a given independent value. After the model is built with the data, it is important to see how it has fared.  Hence, an attribute named RMSE (Root Mean Squared Error) is used to see the difference between the value that had to actually be predicted and the value that was predicted.  Next, the data is visualized on the screen using a package named ‘matplotlib’.  Conclusion In all, Machine Learning is a game changer when it comes to identifying its use cases, and applying the right kind of algorithm in the right place, with the right amount of data, and right computational resources and power. Linear Regression is just a simple algorithm of where Machine Learning begins to show its aspects. Usually, the Python language is used to implement Machine Learning algorithms, but other new languages could also be used.  
Rated 4.0/5 based on 16 customer reviews
Getting Started With Machine Learning With Python:...

Takeaways from the article This article helps y... Read More

Types of Classification in Machine Learning

Takeaways from this article In this post, we understand the concept of classification, regression, classification predictive modelling, and the different types of classification and regression.  We understand why and how classification is important. We also see a few classification algorithms and their implementations in Python.  We understand logistic regression, decision trees, random forests, support vector machines, k nearest neighbour and neural networks. We understand their inner workings and their prominence. IntroductionClassification refers to the process of classifying the given data set into different classes or groups. The classification algorithm is placed under predictive modelling problem, wherein every class of the dataset is given a label, to indicate that it is different from other classes. Some examples include email classification as spam or not, recognition of a handwritten character as a specific character only, and not another character and so on.   Classification algorithms need data to be trained with many inputs and their respective output, with the help of which the model learns. It is important to understand that the training data must encompass all kinds of data (options) which could be encountered in the test data set or real world. ClassificationThe 4 different prominent types of classification include the following:Binary classification Multi-class classification Multi-label classification Imbalanced classification  Binary classificationAs the name suggests, it deals with the tasks in classification that only have two class labels. Some examples include: email classification as spam or not, whether the price of a stock will go up or go down (ignoring the fact that it could also remain as is), and so on. The value obtained after classifying the data would be either 0 or 1, yes or no, normal or abnormal.  The Bernoulli probability distribution is used as prediction to classify the data as 0 or 1. Bernoulli distribution is a discrete (discontinuous) distribution that gives a binary outcome -- a 0 or a 1. Algorithms that are used to perform binary classification include the following:Logistic regression Decision trees Support vector machine Naïve Bayes ‘k’nn (k nearest neighbors) Code to demonstrate a binary classification task:  from numpy import where  from collections import Counter  from sklearn.datasets import make_blobs  from matplotlib import pyplot  X, y = make_blobs(n_samples=560, centers=2, random_state=1)  print("Data has been generated ")  print("The number of rows and columns are ")  print(X.shape, y.shape)  my_counter = Counter(y)  print(my_counter)  for i in range(10):  print(X[i], y[i])  for my_label, _ in my_counter.items():  row_ix = where(y == my_label)[0]  pyplot.scatter(X[row_ix, 0], X[row_ix, 1], label=str(my_label))  pyplot.legend()  pyplot.show()Output: Data has been generated   The number of rows and columns are   (560, 2) (560,)  Counter({1: 280, 0: 280})  [-9.64384208 -4.14030356] 1  [-0.8821407  4.2877187] 0  … Code explanation The required packages are imported using the ‘import’ function.  The dataset is generated using the ‘make_blobs’ function and by specifying the number of rows and columns that need to be generated.  In addition, the number of classes into which the data points need to be labelled into is also defined. Here, it is 2. The number of rows and columns are displayed along with the summarization of class labelling.  A ‘for’ loop is used to print the first few classified values.  The entire dataset is then plotted on a graph in the form of a scatterplot using the ‘pyplot’ function and displayed on the screen.  Multi-class classificationIt is a type of classification wherein the input data set is classified/labelled into more than 2 classes. Some examples of multi-class classification include:Animal species classification Facial recognition/classification Text translation (special type of multi-class classification task) This is different from binary classification in that it doesn’t have just two classes like 0 or 1, but more, and they need not be 0 or 1. They could be names or other continuous or discontinuous numbers. The data points are classified into one among many different classes given.  The number of class labels may be too high, when trying to classify a given photo into that of a specific person. Text translation also deals with a similar issue, wherein the word placement may vary widely and there maybe thousands of combinations of the same number of words. Multinoulli probability distribution is a discrete/discontinuous probability distribution, where the output could be any value within a given range. Algorithms that are used for binary classification can also be used for multi-class classification.  Code to demonstrate the multi-class classification: from numpy import where  from collections import Counter  from sklearn.datasets import make_blobs  from matplotlib import pyplot    X, y = make_blobs(n_samples=670, centers=5, random_state=1)  print("The dataset has been generated")  print("The rows and columns are ")  print(X.shape, y.shape)  my_counter = Counter(y)  print(my_counter)  for i in range(10):  print(X[i], y[i])  for my_label, _ in my_counter.items():  row_ix = where(y == my_label)[0]  pyplot.scatter(X[row_ix, 0], X[row_ix, 1], label=str(my_label))  pyplot.legend()  pyplot.show() Output:  The dataset has been generated  The rows and columns are   (670, 2) (670,)  Counter({3: 134, 0: 134, 2: 134, 4: 134, 1: 134})  [-6.45785776 -3.30981436] 3  [-6.44623696 -2.90184841] 3  [-5.60217602 -0.65990849] 3 Code explanation: The required packages are imported using the ‘import’ function.  The dataset is generated using the ‘make_blobs’ function and by specifying the number of rows and columns that need to be generated.  In addition, the number of classes into which the data points need to be labelled into is also defined. Here, it is 5.  The number of rows and columns are displayed along with the summarization of class labelling.  A ‘for’ loop is used to print the first few classified values.  The entire dataset is then plotted on a graph in the form of a scatterplot using the ‘pyplot’ function and displayed on the screen. Multi-label classification   Multi-label classification refers to those classification problems that deal with more than one class being assigned to a single data point, i.e. every data point would belong or be labelled into more than one class/label. A simple example would be a photo that contains multiple people, not just one. This means one photo might be classified or labelled as more than one (in fact thousands) of persons. This is different from binary and multi-class classification, since the number of labels into which one data point is classified remains same, i.e one.Some multi-label classification algorithms include: Multi-label random forests Multi-label gradient boosting Code to demonstrate multi-label classification: from sklearn.datasets import make_multilabel_classification  X, y = make_multilabel_classification(n_samples=800, n_features=2, n_classes=5, n_labels=3, random_state=1)  print("The number of rows and columns are ")  print(X.shape, y.shape)  for i in range(8):  print(X[i], y[i]) Output: The number of rows and columns are   (800, 2) (800, 5)  [22. 24.] [1 0 0 1 1]  [12. 35.] [0 1 0 1 0]  [27. 30.] [1 1 0 0 1]  ..  Code explanation The required packages are imported using the ‘import’ function.  The dataset is generated using the ‘make_multilabel_classification’ function present in the scikit-learn package is used.  It is done by specifying the number of rows and columns that need to be generated.  The number of rows and columns are displayed along with the summarization of class labelling.  A ‘for’ loop is used to print the first few classified values.  The entire dataset is then plotted on a graph in the form of a scatterplot using the ‘pyplot’ function and displayed on the screen.  Imbalanced classification This is a type of classification wherein the number of data points of the dataset in every class is not distributed equally. This means imbalanced classification is basically a binary classification problem, which doesn’t have a uniform distribution of points, one class could contains an extremely large amount of data points, and the other class might contains a very small number of data points.  Examples of imbalanced classification problem include: Fraud detection in credit cards Anomaly detection in the given dataset There are specialized algorithms that are used to classify this data into the large data point group or small data point group. Some algorithms have been listed below: Cost sensitive decision trees Cost sensitive logistic regression Cost sensitive support vector machines Code to demonstrate imbalanced binary classification #An example of imbalanced binary classification task  from numpy import where  from collections import Counter  from sklearn.datasets import make_classification  from matplotlib import pyplot  #The dataset is defined  X, y = make_classification(n_samples=800, n_features=2, n_informative=2, n_redundant=0, n_classes=2, n_clusters_per_class=1, weights=[0.99,0.01], random_state=1)  #The shape of the dataset is summarized  print("The number of rows and columns ")  print(X.shape, y.shape)  #The labelled data is summarized  my_counter = Counter(y)  print(my_counter)  #A few data points are summarized  for i in range(10):  print(X[i], y[i])  #The dataset is plotted on a graph and displayed  for my_label, _ in my_counter.items():  row_ix = where(y == my_label)[0]  pyplot.scatter(X[row_ix, 0], X[row_ix, 1], label=str(my_label))  pyplot.legend()  pyplot.show() Output: The number of rows and columns   (800, 2) (800,)  Counter({0: 785, 1: 15})  [0.28622882 0.38305399] 0  [1.17971415 0.48003249] 0  [1.32658794 0.71712275] 0  Code explanation The required packages are imported using the ‘import’ function.  The dataset is generated using the ‘make_classification’ function present in the scikit-learn package is used.  It is done by specifying the number of rows and columns that need to be generated.  The number of rows and columns are displayed along with the summarization of class labelling.  A ‘for’ loop is used to print the first few classified values.  The entire dataset is then plotted on a graph in the form of a scatterplot using the ‘pyplot’ function and displayed on the screen.  Logistic regression In this classification technique, instead of finding continuous values like that of linear regression, we are concerned with finding discrete values. It is simply a classification technique that classifies the given data points into one of the labelled classes. Usually, we are looking at a Boolean output, wherein the result is either 0 or 1, yes or no and so on. Some examples include: Classifying an email as spam or not Finding whether it would rain today or not Naïve Bayes classification Bayes theorem is way of calculating the probability of a hypothesis (situation, which might not have occurred in reality) based on our previous experiences and the knowledge we have gained by it.  Bayes theorem is stated as follows: P(hypo | data) = (P(data | hypo) * P(hypo)) / P(data)  In the above equation,  P(hypo | data) is the probability of a hypothesis ‘hypo’ when data ‘data’ is given, which is also known as posterior probability.  P(data | hypo) is the probability of data ‘data’ when the specific hypothesis ‘hypo’ is known to be true.  P(hypo) is the probability of a hypothesis ‘hypo’ being true (irrespective of the data in hand), which is also known as prior probability of ‘hypo’.  P(data) is the probability of the data (irrespective of the hypothesis). The idea here is to get the value of the posterior probability, given other data. The posterior probability for a variety of different hypotheses is found out, and the probability that has the highest value is selected. This is known as the maximum probable hypothesis, and is also known as maximum a posteriori (MAP) hypothesis.  MAP(hypo) = max(P(hypo | data))  If the value of P(hypo | data) is replaced with the value we saw before, the equation would become:  MAP(hypo) = max((P(data | hypo) * P(hypo)) / P(data))  P(data) is considered as a normalizing term that helps in determining the probability. This value can be ignored when required, since it is a constant value. Naïve Bayes classifier is an algorithm that can be used with binary or multi-class classification problems. Once a Naïve Bayes classifier has learnt from the data, it stores a list of probabilities. Probabilities such as ‘class probability’ and ‘condition probability’ is stored. Training such a model is quick since the probability of every class and its associated value needs to be determined, and this doesn’t involve any optimization processes or coefficient changing.  K-nearest neighbour (KNN)  The simplest way to understand k-nearest neighbour, is that the training data for the algorithm is all the data in its entirety. KNN doesn’t have a different model, other than the one that stores the entire dataset, which means there is no machine learning that is actually happening. This means KNN makes predictions and extracts patterns directly from the training dataset itself. When a new data point is encountered, the corresponding value for that can be found using KNN by navigating through the entire training dataset, by looking at the ‘k’ number of very similar neighbours. Once the ‘k’ neighbours have been identified, they are summarized and the output for every instance is found. In case of regression, the mean of this output is the result, and in case of classification, the mode of this output is the result.  How to determine the ‘k’ neighbours? To find ‘k’ number of instances from the training dataset that are very similar to the new data point, we use a distance factor, and the most popular metric is the Euclidean distance.  Euclidean distance can be determined by finding the square root of the sum of the square of difference between the new point and an existing point in the data set, and this sum is from values in the range (a,b). Euclidean Distance: (a,b) = square root( sum( a – b) ^ 2))  Other distances that can be used include: Hamming distance Manhattan distance Minkowski Distance When the number of data points in the training set increases, the complexity of KNN also increases.  Support vector machines (SVM) The hyperplane present in linear SVM is learnt by performing simple transformations using linear algebra. The sum of the product of every pair of input data points is multiplied, and this is known as the inner product. The basic idea behind SVM is that the inner product of two vectors can be expressed as a sum of product of the first value of every vector.  To find inner product of two input vectors: [a,b] and [c,d], we do [a*c + b*d]  In order to predict new value, the dot product can be used, and the support vector can be calculated using the below equation: f(x) = coeff-1 + sum(coeff-2 * (a,b))   Here, ‘a’ and ‘b’ are input vectors and coeff-1 and coeff-2 are coefficients that are determined with the help of the training dataset and the learning algorithm. Stochastic gradient descent or sequential minimal optimization technique can be used. All these optimization techniques break down the main problem into sub-problems and every sub problem is solved by calculating the required value.  Decision trees It is a part of predictive modelling in machine learning that is considered as one of the most powerful algorithms. It is also known as CART, i.e. classification and regression trees since this can be used in the process of classification as well as regression tasks. Decision tree can be simply visualized as a binary tree that has a root and many branches from it and leaves. It is the same as the tree data structure. The root is a single input value, and the branches that lead to leaves are used in predicting the values for the given input.  The tree structure can be stored in the form of a graph structure or a set of rules. Once the data in the form of tree is available, it is simple to make predictions on it with the help of the leaf nodes. The specific branch and its leaf node is examined to reach the node.  Data is filtered from the root of the tree and goes and sits in the branch and the leaf that is relevant to it.  No data preparation or pre-processing is required while working with CART or decision trees.  Gradient boosting It is a method to build predictive models in machine learning. The idea behind boosting is to understand whether a weak learning algorithm can be made to learn better. This involves three attributes: A weak learning algorithm that makes prediction: Decision tree is considered to be a weak learner when it comes to gradient boosting. The best splits are chosen in decision trees, thereby minimizing the loss, hence they need to be improved so that they work well even when the split is random.  A loss function that needs to be optimized: This value depends on the situation in hand. Many different loss functions can be used, such as squared error, measure squared error, logarithmic loss function and so on. A new boosting algorithm won’t have to be figured out for every loss function.  An additive model that adds weak learner to minimize the loss function: The trees to the gradient boosting technique are added one at a time, so that the existing model trees don’t have changes. This way, the loss is minimized when new trees are added. Usually, gradient descent optimization technique is used to minimize the loss.  Random forest Random forest is an ensemble machine leaning algorithm that uses bootstrap aggregation or bagging. It is a statistical method that helps in estimating the quantity from a given data sample. It is done to reduce the variance for those algorithms that seem to have a high variance. Examples of algorithms that have high variance include CART, and decision trees. Decision trees are extremely sensitive to the data on which they are trained. If the training data changes, the resultant tree would also be completely different. A small change in the input makes a huge difference to the overall training and output.  An ensemble method is the one that combines the predictions that have come from many different machine learning algorithms, thereby making sure that the predictions are more accurate in comparison to dealing with an algorithm that gives a single prediction. It is like combining the best algorithms to give the best of best values.  Random forest makes sure that the every sub-tree that learns and trains on the data and makes the predictions is less correlated to the other sub-trees that do the same. The learning algorithm is limited to be able to look at a random sample of the data points, so that it doesn’t have the opportunity to look through all the variables, and select an optimal point to split upon (which is actually the case with CART). It is seen that for classification trees, a good value for the number of randomly selected columns from the dataset is square root (p) where p refers to the number of input variables. On the other hand, for regression trees, a good value for the number of randomly selected columns from the dataset is p/3.  Neural networks It is a part of deep learning that deals with artificial neural networks. In general, the word ‘neural’ or ‘neuro’ deals with the decision making branch of the human brain. The idea behind artificial neural network, also abbreviated as ANN, is that it takes decision similar to how the neurons in the brain function while performing a function or taking a decision.  It is called deep learning since these networks have various layers, and every layer has a large number of nodes. Every layer processes some part of the data and passes on the computed data to the next layer. The input data to one layer is the output data of the previous layer. Usually, the input layer’s nodes are large in number, and the output layer has just one node indicating that the data was processed, and the output has been obtained.  Conclusion In this post, we understood how classification works, the different types of classification and regression, their working, implementations by generating simple dataset and working through it using Python and other relevant machine learning related packages. 
Rated 4.0/5 based on 15 customer reviews
8178
Types of Classification in Machine Learning

Takeaways from this article In this post, we und... Read More