0% found this document useful (0 votes)
18 views43 pages

Machine Learning Ess - Week 1-4week

Uploaded by

ravinyse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views43 pages

Machine Learning Ess - Week 1-4week

Uploaded by

ravinyse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Essential Ingredients

Week 1-4

Written by Abhishek kaushik (Abhi)

~ Material is for educational purpose for the


specific audience. Distribution in any form is
not allowed.
Table of content
1-4 Weeks (Python Practical hand)
1. Crash Course on python (Saturday) (P)
2. Essential Terminology of Machine learning (D)
3. Understand Your Data With Descriptive Statistics (T+P)
4. Visualize your Data to understand (P)
5. Data preparations (T+P)
6. First Project on Linear regression (T+P)

T stands for Theory, P stand for Pythonic and D stand for Discussion
Please make notes while discussions.
Note : Source of all images with open License from the Internet
Short Quiz
Define list?

Difference between Dataframe and Multi-Dimensional array?

Define Pandas.

Define Numpy.

What is Scikit learn used for?

Define visualization?
Essential Terminology of Machine learning (Discussion) (1)

1. Data
a. Information
b. Data Science
2. AI
a. Machine learning
b. Types of learning
Essential Terminology of Machine learning (Discussion) (2)

1. Statistical testing
a. Sample
b. Population
2. Evaluation
a. Testing Data
b. Training Data
c. Accuracy
d. Precision
Essential Terminology of Machine learning (Discussion) (3)

1. Supervised learning
a. Classification
b. Regression
2. Unsupervised
a. Clustering
b. Associations
3. Reinforcement learning
Essential Terminology of Machine learning (Discussion) (1)

1. Application
a. Stock Market
b. Sentiment Analysis
c. Questions and Answering System
2. Deep learning
a. MLP
b. CNN
c. RNN
d. LSTM
Understand Your Data With Descriptive Statistics
7 steps For Descriptive Data (Week 2-3)
● Quick Glance at (Data)
● Review Dimensions
● Review data types
● Summarize the distribution
● Summarize data description
● Understanding the relationship
● Review the skew
Time for pythonic (1)
Please visit first Pdf (Descriptive Analysis)

Quick Glance Discussions

Dimensions

1. Too Many Rows


2. Too Many features
Time for pythonic (2)
Why to Know the Data type?

● Strings need to converted to floating point values


● Integers to be calculated Categorical and integers
Time for pythonic (3)
Descriptive Statistics! Why? (Irregular distribution or
surprising factors)

Covers 8 properties

● Count
● Mean
● Standard Deviations
● Minimum Value
● Maximum Value
● 25th percentile
● 50th percentile
● 75th percentile
Time for pythonic (4)
Class distribution

● Why?
● Data imbalance! Do you agree ?

Correlations Between Attributes

Result of High Correlations~ poor performance in linear and


logistic Regression
Time for pythonic (5)
Skew checking?

Skew refer to distribution

that is assumed to be

Gaussian (Normal or Bell Curve)

1. It could be shifted or squashed in one directions or


another
2. Machine learning assume to have a gaussian distribution
Understand your Data with Visualization
DatA Explorations
● Data Explorations
○ Univariate plot (Among one)
■ Histograms
■ Density plots
■ Box and Whisker
○ Multivariate plot (Among others)
■ Correlation Matrix plot
■ Scatter Plot Matrix plot
Using the Library matplotlib

Histograms

data.hist()

Select the bins

Helps us understand the data is skew, Gaussian and


exponential distribution

Also help us to see the possible outliner


Time for pythonic (7)
1. Box and Whisker plot
2. Review the Distribution of
each Attribute
3. Boxplot Summarize the
distribution of each
attribute ,drawing a line
for the median (Middle
value) and box around the
15th and 75th percentile
Time for pythonic (8)
1. Gives an idea of data spread
2. Dots outside the whiskers show candidate outlier values
3. Important links to Read:
a. https://www.wellbeingatschool.org.nz/information-sheet/understanding-
and-interpreting-box-plots
b. https://flowingdata.com/2008/02/15/how-to-read-and-use-a-box-and-whis
ker-plot/
c. https://towardsdatascience.com/understanding-boxplots-5e2df7bcbd51
Time for pythonic (9)
● Density Plots
● As known as Kernel Density Plots, Density
Trace Graph.
● A Density Plot visualises the distribution of
data over a continuous interval or time
period. This chart is a variation of a
Histogram that uses kernel smoothing to
plot values, allowing for smoother
distributions by smoothing out the noise.
Time for pythonic (10)
The peaks of a Density Plot help display
where values are concentrated over the
interval.

An advantage Density Plots have over


Histograms is that they're better at
determining the distribution shape because
they're not affected by the number of bins
used (each bar used in a typical histogram).

Change kind=”Density”
Multivariate PLots (1)
● Correlations Matrix
plot
○ Correlation is an
indication of how
related the changes are
between variables.
■ Inversely
proportional
■ Directly
proportional
■ Poor performance in
linear and logistic
regression
Multivariate PLots (2)
● Scatter Plot Matrix
○ A scatter plot shows the
relationship between two variables
as dots in dimensions, one xix for
each attribute
○ Attributes with structured
relationships may also be correlated
and good candidates for removal from
your dataset
Time for pythonic (11)
For Correlation matrix

○ fig = pyplot.figure()
○ ax = fig.add_subplot(111)
○ cax = ax.matshow(correlations, vmin=-1, vmax=1)
○ fig.colorbar(cax)

For Scatter matrix

○ M=pd.Scatter_matrix(data)
Prepare Data For machine learning
Data Preparations (D)
● Rescaling Data
● Standardize Data
● Normalize Data
● Binarize Data

Why????????
Time for pythonic (10)
Rescaling Data

● Rescaling all the attributes to all the same scale.


● Often people refer as normalize if the scale were
between 0 and 1.
● Useful for the optimization algorithms used in the
core of machine learning algorithms like Gradient
descent.
● Also useful for algorithms regression, neural networks
and distance algorithm K-NN. We use MinMAxscaler class
for the same.
Time for pythonic (11)
Standardize Data

● Useful Techniques to transform attributes with Gaussian


distributions.
● Differ the mean and standard Deviations to a standard
Gaus. distributions with a mean of 0 and a standard
deviations of 1.
● Most suitable techniques for those algorithm that assume
Gauss. distribution as a variable input work better with
rescaled techniques like linear and logistic regression
and LDA
Time for pythonic (12)
Normalize data
● The example of normalizing the document is explained in the class.
● This method is very useful in the case of sparse. matrix and distance algos.
● Can be implemented by using the Normalizer class.

Binarize Data
● Can convert data using the binary threshold.
● All the values above the threshold will be 1.
● All the values below the threshold will be 0.
● Can be implemented by using the Binarizer class.
Small Project on Linear Regression
Types of Probabilistic Models
Types of Regression Models
Linear Regression
Time for pythonic (13)
● Relationship between one dependent variable and
explanatory variable(s)
● Use equation to set up relationship
● Numerical Dependent (Response) Variable
● 1 or More Numerical or Categorical Independent
(Explanatory) Variables
● Used Mainly for Prediction & Estimation
Regression Modeling steps
● Hypothesize Deterministic Component
○ Estimate Unknown Parameters
● Specify Probability Distribution of Random Error Term
○ Estimate Standard Deviation of Error
● Evaluate the fitted Model
● Use Model for Prediction & Estimation
Linear Equations
Linear Regression Model
Y=B_constant+Bx_variable+e

Observed Value
e=Random
Error

Y=B_constant+
BX_variable
Evaluation Techniques (1)
● Mean Absolute Error

● Mean Squared Error or RMSE


Evaluation Techniques (2)
● R Square or coefficient of determination, denoted R2 or r2
y is actual value and f is predicted value
Homework
What are the advantage and disadvantage of all evaluation
methods in Regression discussed in the class?

(200 Words)
Time for pythonic (14)
Ten baseline variables, age, sex, body mass index, average
blood pressure, and six blood serum measurements were
obtained for each of n = 442 diabetes patients, as well as
the response of interest, a quantitative measure of disease
progression one year after baseline.

Please refer to code


Time for pythonic (15)
Try of your own (Home work)

Ridge Regression

Lasso Regression

Elastic Regression

Explain your experience in 300 words with the code.


Revision
1. Essential Terminology of Machine learning (D)
2. Understand Your Data With Descriptive Statistics (T+P)
3. Visualize your Data to understand (P)
4. Data preparations (T+P)
5. First Project on Linear regression (T+P)
Thank you

You might also like