Object Segmentation Unit 4
Object Segmentation Unit 4
Segmentation refers to the act of segmenting data according to your company's needs in order
to refine your analyses based on a defined context, using a tool for cross-calculating analyses.
A segment enables you to filter your analyses based on certain elements (single or
combined).
The purpose of segmentation is to better understand your visitors, and to obtain actionable
data in order to improve your website or mobile app.
Segmentation can be done on elements related to a visit, as well as on elements related to
multiple visits during a studied period.
A few examples of possible segments:
Visits originating only from direct traffic, and made using the Firefox browser ;
The precise population of visitors who generate high (or low) revenue ;
Visits which started out on your site’s home page
Visitors who remained on your site for longer than 2 minutes.
Segmentation models provide the exact outline of the object within an image. That is, pixel
by pixel details are provided for a given object, as opposed to Classification models, where
the model identifies what is in an image, and Detection models, which places a bounding box
around specific objects
Supervised machine learning occurs when a model is trained on existing data that is correctly
labeled. The key difference between classification and regression is
that classification predicts a discrete label, while regression predicts a continuous quantity
or value.
Demographic segmentation refers to the categorization of the target market based on specific
variables like age, education, and gender. It is a type of market segmentation that helps businesses to
understand their consumers better and meet their needs, effectively.
Behavioral segmentation is a form of marketing segmentation that divides people into different
groups who have a specific behavioral pattern in common. Users may share the same lifecycle stage,
previously purchased particular products, or have similar reactions to your messages.
Regression is a statistical method used in finance, investing, and other disciplines that
attempts to determine the strength and character of the relationship between one dependent
variable (usually denoted by Y) and a series of other variables (known as independent
variables)
Regression analysis is a form of predictive modelling technique which investigates the
relationship between a dependent (target) and independent variable (s) (predictor). This
technique is used for forecasting, time series modelling and finding the causal effect
relationship between the variables.
Supervised Learning: Supervised learning is the learning of the model where with
input variable (x) and an output variable (Y) and an algorithm to map the input to the
output.
That is, Y = f(X)
The basic aim is to approximate the mapping function so well that when there is a new
input data (x) then the corresponding output variable can be [Link] is called
supervised learning because the process of an learning(from the training dataset) can
be thought of as a teacher who is supervising the entire learning process. Thus, the
“learning algorithm” iteratively makes predictions on the training data and is corrected
by the “teacher”, and the learning stops when the algorithm achieves an acceptable
level of performance(or the desired accuracy).
Unsupervised Learning: Unsupervised learning is where only the input data (say, X)
is present and no corresponding output variable is there.
The main aim of Unsupervised learning is to model the distribution in the data in
order to learn more about the data.
It is called so, because there is no correct answer and there is no such teacher(unlike
supervised learning). Algorithms are left to their own devises to discover and present
the interesting structure in the data.
Example of Unsupervised Learning
Again, Suppose there is a basket and it is filled with some fresh fruits. The task is to
arrange the same type of fruits at one place.
This time there is no information about those fruits beforehand, its the first time that
the fruits are being seen or discovered
So how to group similar fruits without any prior knowledge about those.
First, any physical characteristic of a particular fruit is selected. Suppose color.
Then the fruits are arranged on the basis of the color. The groups will be something as
shown below:
RED COLOR GROUP: apples & cherry fruits.
GREEN COLOR GROUP: bananas & grapes.
So now, take another physical character say, size, so now the groups will be
something like this.
RED COLOR AND BIG SIZE: apple.
RED COLOR AND SMALL SIZE: cherry fruits.
GREEN COLOR AND BIG SIZE: bananas.
GREEN COLOR AND SMALL SIZE: grapes.
Here, there is no need to know or learn anything beforehand. That means, no train data
and no response variable. This type of learning is known as Unsupervised Learning.
UNSUPERVISED
SUPERVISED LEARNING LEARNING
Classification
Classification means grouping things together on the basis of certain common features. It is
actually the method of putting similar things into one group. It makes study more easy and
systematic.
There are four types of classification.
They are
Geographical classification,
Chronological classification,
Qualitative classification,
Quantitative classification.
When the data classified according to geographical location or region (like states, cities,
regions, zones , areas etc) It is called a geographical classification.
When data are observed over a period of time and on the basis of its time of occurrence the
type of classification is known as chronological classification.
When Classification of the different units on the basis of qualitative characteristics called
Attributes Such as sex, literacy, employment etc. is known as qualitative classification.
When data is classified according to measurable characteristics such as height and weight it
is known as quantitative classification of data. Quantitative data are expressed in terms of
number.
For example, classification of data based on the height of students in a class.
Overfitting
Overfitting is a modeling error in statistics that occurs when a function is too closely aligned
to a limited set of data points. As a result, the model is useful in reference only to its
initial data set, and not to any other data sets.
The Role of Pruning in Decision Trees
Pruning is one of the techniques that is used to overcome the problem of Overfitting. Pruning,
in its literal sense, is a practice which involves the selective removal of certain parts of a
tree(or plant), such as branches, buds, or roots, to improve the tree’s structure, and promote
healthy growth. This is exactly what Pruning does to our Decision Trees as well. It makes it
versatile so that it can adapt if we feed any new kind of data to it, thereby fixing the problem
of overfitting.
It reduces the size of a Decision Tree which might slightly increase your training error but
drastically decrease your testing error, hence making it more adaptable.
Decision Tree
A decision tree has the following constituents :
Root Node: The factor of ‘temperature’ is considered as the root in this case.
Internal Node: The nodes with one incoming edge and 2 or more outgoing edges.
Leaf Node: This is the terminal node with no out-going edge.
As the decision tree is now constructed, starting from the root-node we check the test
condition and assign the control to one of the outgoing edges, and so the condition is again
tested and a node is assigned. The decision tree is said to be complete when all the test
conditions lead to a leaf node. The leaf node contains the class-labels, which vote in favor or
against the decision.
Now, you might think why did we start with the ‘temperature’ attribute at the root? If you
choose any other attribute, the decision tree constructed will be different.
Correct. For a particular set of attributes, there can be numerous different trees created. We
need to choose the optimal tree which is done by following an algorithmic approach. We will
now see ‘the greedy approach’ to create a perfect decision tree.
As the name goes, it uses a tree-like model of decisions. They can be used either to drive
informal discussion or to map out an algorithm that predicts the best choice mathematically.
A decision tree typically starts with a single node, which branches into possible outcomes.
Each of those outcomes leads to additional nodes, which branch off into other possibilities.
This gives it a tree-like shape.
This gives it a tree-like shape.
There are three different types of nodes: chance nodes, decision nodes, and end nodes. A
chance node, represented by a circle, shows the probabilities of certain results. A decision
node, represented by a square, shows a decision to be made, and an end node shows the final
outcome of a decision path.
Disadvantages
Decision trees are less appropriate for estimation tasks where the goal is to predict the value
of a continuous attribute.
Decision trees are prone to errors in classification problems with many class and a relatively
small number of training examples.
Decision trees can be computationally expensive to train. The process of growing a decision
tree is computationally expensive. At each node, each candidate splitting field must be sorted
before its best split can be found. In some algorithms, combinations of fields are used and a
search must be made for optimal combining weights. Pruning algorithms can also be
expensive since many candidate sub-trees must be formed and compared.
Let us create a decision tree to find out whether we have discovered a new habitat.
Classification Rules:
Classification rules are the cases in which all the scenarios are taken into consideration and a
class variable is assigned to each.
Class Variable:
Each leaf node is assigned a class-variable. A class-variable is the final output which leads to
our decision.
Let us derive the classification rules from the Decision Tree created:
2. If Temperature is between 273 to 373K, and water is not present, -> Survival Difficult
3. If Temperature is between 273 to 373K, water is present, and flora and fauna is not present
-> Survival Difficult
4. If Temperature is between 273 to 373K, water is present, flora and fauna is present, and a
stormy surface is not present -> Survival Probable
5. If Temperature is between 273 to 373K, water is present, flora and fauna is present, and a
stormy surface is present -> Survival Difficult
It reduces the size of a Decision Tree which might slightly increase your training error but
drastically decrease your testing error, hence making it more adaptable.
Bagging decision trees − These trees are used to build multiple decision trees by repeatedly
resampling training data with replacement, and voting the trees for a consensus prediction. This
algorithm has been called random forest.
A Decision Tree is an algorithm used for supervised learning problems such as classification
or regression. A decision tree or a classification tree is a tree in which each internal (nonleaf)
node is labeled with an input feature. The arcs coming from a node labeled with a feature are
labeled with each of the possible values of the feature. Each leaf of the tree is labeled with a
class or a probability distribution over the classes.
A tree can be "learned" by splitting the source set into subsets based on an attribute value
test. This process is repeated on each derived subset in a recursive manner called recursive
partitioning. The recursion is completed when the subset at a node has all the same value of
the target variable, or when splitting no longer adds value to the predictions. This process of
top-down induction of decision trees is an example of a greedy algorithm, and it is the most
common strategy for learning decision trees.
Decision trees used in data mining are of two main types −
Classification tree − when the response is a nominal variable, for example if an
email is spam or not.
Regression tree − when the predicted outcome can be considered a real number (e.g.
the salary of a worker).
Decision trees are a simple method, and as such has some problems. One of this issues is the
high variance in the resulting models that decision trees produce. In order to alleviate this
problem, ensemble methods of decision trees were developed. There are two groups of
ensemble methods currently used extensively −
Bagging decision trees − These trees are used to build multiple decision trees by
repeatedly resampling training data with replacement, and voting the trees for a
consensus prediction. This algorithm has been called random forest.
Boosting decision trees − Gradient boosting combines weak learners; in this case,
decision trees into a single strong learner, in an iterative fashion. It fits a weak tree to
the data and iteratively keeps fitting weak learners in order to correct the error of the
previous model.
There are two main types of decision trees that are based on the target variable, i.e.,
categorical variable decision trees and continuous variable decision trees.
Categorical variable decision tree. ...
Continuous variable decision tree. ...
Assessing prospective growth opportunities.
ARIMA
ARIMA, short for 'Auto Regressive Integrated Moving Average' is actually a class of models that
'explains' a given time series based on its own past values, that is, its own lags and the lagged forecast
errors, so that equation can be used to forecast future values
It's a model used in statistics and econometrics to measure events that happen over a period of time.
The model is used to understand past data or predict future data in a series.
A popular and widely used statistical method for time series forecasting is the ARIMA model. It is a
class of model that captures a suite of different standard temporal structures in time series data
ARIMA uses a number of lagged observations of time series to forecast observations. A weight is
applied to each of the past term and the weights can vary based on how recent they are. AR(x) means
x lagged error terms are going to be used in the ARIMA model. ARIMA relies on AutoRegression
To select the best ARIMA model the data split into two periods, viz. estimation period and
validation period. The model for which the values of criteria are smallest is considered as the best
model.
Time Series
Time series is a sequence of time-based data points collected at specific intervals
of a given phenomenon that undergoes changes over time. It is indexed according
to time.
Time series analysis is one of the most common data types encountered in daily
life. Most companies use time series forecasting to help them develop business
strategies. These methods have been used to monitor, clarify, and predict certain
‘cause and effect’ behaviours.
In a nutshell, time series analysis helps to understand how the past influences the
future. Today, Artificial Intelligence (AI) and Big Data have redefined business
forecasting methods. This article walks you through 5 specific time series methods.
Development:
Collect and check the quality of the date. Plot and try those models and regression conditions.
Consult experts.
Find the best models.
Maintenance:
Check if the parameters are stable.
Check if the coefficients are reasonable, if any variables are missing, and if the equation is usable for
prediction.
Check the model periodically using statistical techniques.
Seasonality
Seasonality is one of the main characteristics of time series data. It occurs when the
time series exhibits predictable yet regular patterns at time intervals that are
smaller than a year. The best example of a time series data with seasonality is
retail sales that increase between September to December and decrease between
January and February.
Structural breaks
Most often, time-series data shows a sudden change in behaviour at a certain point
in time. Such sudden changes are referred to as structural breaks. They can cause
instability in the parameters of a model, which in turn can diminish the reliability
and validity of that model. Time series plots can help identify structural breaks in
data.
Reliability: Time series forecasting is most reliable, especially when the data represents a
broad time period such as large numbers of observations for longer time periods. Information
can be extracted by measuring data at various intervals.
Seasonal patterns: Data points variances measured can reveal seasonal fluctuation patterns
that serve as the basis for forecasts. Such information is of particular importance to markets
whose products fluctuate seasonally because it helps them plan for production and delivery
requirements.
Trend estimation: Time series method can also be used to identify trends because data
tendencies from it can be useful to managers when measurements show a decrease or an
increase in sales for a particular product.
Growth: Time series method is useful to measure both endogenous and financial growth.
Endogenous growth is the development from within an organization’s internal human capital
that leads to economic growth. For example, the impact of policy variables can be evidenced
through time series analysis.
Standard Template Library (STL)
The Standard Template Library (STL) is a set of C++ template classes to provide
common programming data structures and functions such as lists, stacks, arrays, etc. It
is a library of container classes, algorithms, and iterators. It is a generalized library
and so, its components are parameterized.
STL has four components
Algorithms
Containers
Functions
Iterators
Algorithms
The header algorithm defines a collection of functions especially designed to be used
on ranges of [Link] act on containers and provide means for various
operations for the contents of the containers.
Containers
Containers or container classes store objects and data. There are in total seven
standard “first-class” container classes and three container adaptor classes and only
seven header files that provide access to these containers or container adaptors.
Sequence Containers: implement data structures which can be accessed in a
sequential manner.
Container Adaptors : provide a different interface for sequential containers.
Associative Containers : implement sorted data structures that can be quickly
searched (O(log n) complexity).
Unordered Associative Containers : implement unordered data structures that can
be quickly searched
Functions
The STL includes classes that overload the function call operator. Instances of such
classes are called function objects or functors. Functors allow the working of the
associated function to be customized with the help of parameters to be passed.
Iterators
As the name suggests, iterators are used for working upon a sequence of values.
They are the major feature that allow generality in STL.
With predictive analytics, organizations can find and exploit patterns contained within data in
order to detect risks and opportunities. Models can be designed, for instance, to discover
relationships between various behavior factors. Such models enable the assessment of either
the promise or risk presented by a particular set of conditions, guiding informed decision-
making across various categories of supply chain and procurement events.
Predictive analytics can also be used to detect and halt various types of criminal behavior
before any serious damage is inflected. By using predictive analytics to study user behaviors
and actions, an organization can detect activities that are out of the ordinary, ranging from
credit card fraud to corporate spying to cyberattacks.
Here are a few examples of how organizations are making use of predictive analytics:
Aerospace: Predict the impact of specific maintenance operations on aircraft reliability, fuel use,
availability and uptime.
Automotive: Incorporate records of component sturdiness and failure into upcoming vehicle
manufacturing plans. Study driver behavior to develop better driver assistance technologies and,
eventually, autonomous vehicles.
Energy: Forecast long-term price and demand ratios. Determine the impact of weather events,
equipment failure, regulations and other variables on service costs.
Financial services: Develop credit risk models. Forecast financial market trends. Predict the impact
of new policies, laws and regulations on businesses and markets.
Manufacturing: Predict the location and rate of machine failures. Optimize raw material deliveries
based on projected future demands.
Law enforcement: Use crime trend data to define neighborhoods that may need additional protection
at certain times of the year.
Virtually all predictive analytics adopters use tools provided by one or more external
developers. Many such tools are tailored to meet the needs of specific enterprises and
departments. Major predictive analytics software and service providers include:
Customer Lifetime Value Model: Pinpoint customers who are most likely to invest more in products
and services.
Customer Segmentation Model: Group customers based on similar characteristics and purchasing
behaviors
Predictive Maintenance Model: Forecast the chances of essential equipment breaking down.
Quality Assurance Model: Spot and prevent defects to avoid disappointments and extra costs when
providing products or services to customers.
Decision trees, one of the most popular techniques, rely on a schematic, tree-shaped diagram
that's used to determine a course of action or to show a statistical probability. The branching
method can also show every possible outcome of a particular decision and how one choice
may lead to the next.
Regression techniques are often used in banking, investing and other finance-oriented
models. Regression helps users forecast asset values and comprehend the relationships
between variables, such as commodities and stock prices.
On the cutting edge of predictive analytics techniques are neural networks — algorithms
designed to identify underlying relationships within a data set by mimicking the way a human
mind functions.
Clustering algorithms, for example, are well suited for customer segmentation, community
detection and other social-related tasks. To improve customer retention, or to develop a
recommendation system, classification algorithms are typically used. A regression algorithm
is typically selected to create a credit scoring system or to predict the outcome of many time-
driven events.
The study also revealed that most healthcare executives (89 percent) belong to organizations
that are either now using predictive analytics or planning to do so within the next five years.
An impressive 93 percent of healthcare executives stated that predictive analytics is important
to their business’ future.
In the end, the reduction of the data helps to build the model with less machine’s
efforts and also increase the speed of learning and generalization steps in
the machine learning process.
Machines see any images in the form of a matrix of numbers. The size of this
matrix actually depends on the number of pixels of the input image.
What is pixel?
The Pixel Values for each of the pixels stands for or describe how bright that pixel
is, and what color it should be. So In the simplest case of the binary images, the
pixel value is a 1-bit number indicating either foreground or background.
So pixels are the numbers, or the pixel values which denote the intensity or
brightness of the pixel.
Smaller numbers which is closer to zero helps to represent black, and the larger
numbers which is closer to 255 denote white.
So this is the concept of pixels and how machine sees the images without eyes
through the numbers.
The dimensions of the image 28 x 28. And if you want to check then by
counting the number of pixels you can verify.
But, for the case of a coloured image, we have three Matrices or the channels
1. Red,
2. Green
3. and Blue.
So in these three matrices, each of the matrix has values between 0-255 which
represents the intensity of the colour of that pixel.
If you have a coloured image like the dog image we have in the above image on
the left. so being a human you have eyes so you can see and can say it is a dog
coloured image. But how computer can understand it is coloured or black and
white image?
So you can see we also have a three matrices which represents the channel of RGB
– (for the three color channels – Red, Green, and Blue) On the right, we have three
matrices. These three channels are superimposed and used to form a coloured
image. So this is how a computer can differentiate between the images.