You are on page 1of 17

Machine Learning

With Python
What is ML
• Field of study that gives computers the ability to learn without
being explicitly programmed.
• A machine is said to be learning from past experiences (data
feed in) wrt some class of tasks, if it’s performance in a given
task improves with the experience.
• Three Categories :-
– Supervised Learning
– Unsupervised Learning
– Reinforcement Learning
Examples of ML
• Web search engine use ML to rank websites.
• Facebook uses ML to recognize faces in the photo.
• E-mail System uses ML to filter spam massages.
• Finding shortest paths from A to B.
• Data Mining
• Medical Industry to understand disease better.
• Autonomous automobiles.
• Handwriting Recognition.
• Natural Language Processing.
• Computer Vision.
• Business Problems.
Supervised Learning
• Supervised learning is when the model is getting trained on a
labeled dataset. Labeled dataset is one which have both input
and output parameters.
• Two types of Supervised Learning :-
– Classification :- Task where output is having defined labels
(discrete value).
• Binary Classification
• Multiclass Classification
– Regression :- Task where output is having continuous value
(Real value).
Supervised Learning Example

Regression Problem
Supervised Learning Example

Classification Problem
Supervised Learning Algorithms
• Regression Algorithms :-
– Univariate Linear Regression
– Multivariate Linear Regression
– Polynomial Linear Regression
• Classification Algorithms :-
– Logistic Regression
– Kernel Nearest Neighbors
– Support Vector Machine
– Decision Trees
– Random Forest
– Naïve Bayes
Unsupervised Learning
• Training of machine using information that is neither classified
nor labeled and allowing the algorithm to act on that
information without guidance.
• Two types of Unsupervised Learning :-
– Clustering :- Here we want to discover the inherent
groupings in the data.
– Association :- An association rule learning problem is
where we want to discover rules that describe large
portions of our data.
Unsupervised Learning Example

Clustering Problem
Unsupervised Learning Example

Association Problem
Unsupervised Learning Algorithms
• Clustering Algorithms :-
– K-means
– Hierarchical
• Association Algorithms :-
– Apriori
– PCA
Reinforcement Learning
• Reinforcement learning is about taking suitable action to
maximize reward in a particular situation. In absence of
training dataset, it is bound to learn from its experience.
• Two types of Reinforcement Learning :-
– Positive :- When an event, occurs due to a particular
behavior, increases the strength and the frequency of the
behavior i.e., has a positive effect on the behavior.
– Negative :- Strengthening of a behavior because a negative
condition is stopped or avoided.
Reinforcement Learning Example

• Here the Agent is supposed to find the best possible path to reach
the reward.
• The Agent learns by trying all the possible paths and then choosing
the path which gives him the reward with the least hurdles.
• Each right step will give Agent a reward, each wrong step will
subtract the reward of the Agent.
Data Preprocessing
• Preprocessing refers to the transformations applied to our
data before feeding it to the algorithm.
• Data preprocessing is used to convert the raw data into a
clean data set. Because the data gathered from different
sources is in raw format which is not feasible for analysis.

Exploratory Insight,
Raw Structured Data Data Reports,
Data Data Preprocessing Analysis Visual
(EDA) Graphs
Data Preprocessing Rescaling Data
• When our data is comprised of attributes with varying scales,
many ML algos can benefit from rescaling the attributes to all
have the same scale.

from sklearn.preprocessing improt MinMaxScaler


scaler = MinMaxScaler(feature_range=(0, 1))
x = scaler.fit_transform(x)
Data Preprocessing Binarize Data
• We can transform our data using a binary threshold. All values
above the threshold are marked 1 and all equal to or below
are marked 0.
• It can be useful when we have probabilities that we want to
make crisp values.

from sklearn.preprocessing import Binarizer


bn = Binarizer(threshold=0.0).fit(x)
x = bn.transform(x)
Data Preprocessing Standardize Data
• Standardization is a useful transform attributes with a
Gaussian distribution and differing means and std to a
standard Gaussian distribution with a mean of 0 and a std of
1.

from sklearn.preprocessing import StandardScaler


sc = StandardScaler().fit(x)
x = sc.transform(x)

You might also like