├── 00 Statistics
├── 1.gif
├── 1.png
├── 1.svg
├── 2.jpg
├── 2.png
├── 2.svg
├── 3.jpg
├── 3.png
├── 3.svg
├── 4.png
├── 4.svg
├── 5.jpg
├── 5.png
├── 5.svg
├── 6.jpg
├── 6.png
├── 7.jpg
├── Basic Stats.ipynb
├── Descriptive Stas.ipynb
├── Descriptive Statistics.ipynb
├── PDF.ipynb
├── Probability Density Function.pdf
├── Untitled.ipynb
├── Use Of Central tendency.ipynb
├── kurtosis.ipynb
├── stats 2.pdf
├── stats 4.pdf
├── stats link.txt
├── stats.txt
├── stats1.pdf
├── stats3.pdf
└── stats5.pdf
├── 00 Supervised and Unsupervised learning.pdf
├── 000All_In_One
└── whole_Ml_PDF.pdf
├── 01 Simple Linear Regression.pdf
├── 01_Deep_Learning_PDF
├── 00.Introduction.pdf
├── 01. Nueral Netwrok.pdf
├── 02. Forward And Backward Prop.pdf
├── 03.Perceptron.pdf
├── 04. Activation_Function.pdf
├── 04.2.Vanishing and exploding gradient.pdf
├── 05. Activation_Function 2.pdf
├── 06.Activation_Function_3.pdf
├── 07. Loss Function.pdf
├── 08. When To Use.pdf
├── 09. Weight Initialize.pdf
├── 10. Optimization Techniques.pdf
├── 11. Optimization Techniques2.pdf
├── 13. Regularization Techniques.pdf
├── 14. ANN_Example.pdf
├── 15. Convolutional_Neural_Network.pdf
├── 16. Example_OF_CNN.pdf
├── 17.(a) LeNet.pdf
├── 17.(b) Alexnet.pdf
├── 17.(c) VGGNET.pdf
├── 17.(d) ResNet.pdf
├── 17.(e). Inception Network.pdf
├── 18. Recurrent Neural Network.pdf
├── 19. LSTM_GRU.pdf
└── ipynb
│ ├── 00.Introduction.ipynb
│ ├── 01. Nueral Netwrok.ipynb
│ ├── 03.Perceptron.ipynb
│ ├── 04. Activation_Function.ipynb
│ ├── 04.2.Vanishing gradient and exploding gradient.ipynb
│ ├── 05. Activation_Function 2.ipynb
│ ├── 06.Activation_Function_3.ipynb
│ ├── 07. Loss Function.ipynb
│ ├── 08. When To Use.ipynb
│ ├── 09. Weight Initialize.ipynb
│ ├── 10. Optimization Techniques.ipynb
│ ├── 11. Optimization Techniques2.ipynb
│ ├── 12. Comparison between various optimizers.ipynb
│ ├── 13. Regularization Techniques.ipynb
│ ├── 14. ANN_Example.ipynb
│ ├── 15. Convolutional_Neural_Network .ipynb
│ ├── 16. Example_OF_CNN.ipynb
│ ├── 17.(a) LeNet.ipynb
│ ├── 17.(b) Alexnet.ipynb
│ ├── 17.(c) VGGNET.ipynb
│ ├── 17.(d) ResNet-checkpoint.ipynb
│ ├── 17.(e). Inception Network.ipynb
│ ├── 18. Recurrent Neural Network.ipynb
│ └── 19. LSTM_GRU.ipynb
├── 02 Multicollinearity.pdf
├── 02_Time_series
├── 01.time_series.ipynb
├── 02.Handling a Non-Stationary Time Series.ipynb
├── 03. Time Series Smoothing Methods.ipynb
├── 04. Decomposition Time series.ipynb
├── 05. Value Of P,D,Q.ipynb
├── 1.jpg
├── 1.png
├── 10.png
├── 11.png
├── 12.png
├── 13.png
├── 2.png
├── 3.png
├── 4.png
├── 5.png
├── 6.png
├── 7.png
├── 8.png
├── 9.png
├── notes
│ ├── 01.time_series.pdf
│ ├── 02.Handling a Non-Stationary Time Series.pdf
│ └── 03. Time Series Smoothing Methods.pdf
└── shampoo Sale.csv
├── 03 Multiple Linear Regression.pdf
├── 03 a Polynomial Linear Regression.pdf
├── 03. b Ridge_And_Lasso_Regression.pdf
├── 03_NLP
├── 01.NLP_Intro.ipynb
├── 02.Preprocessing_1.ipynb
├── 03. POS.ipynb
├── 04. Text_Vectorizer.ipynb
├── 1.jpg
├── 1.png
├── 2.webp
├── 3.webp
├── 4.webp
├── 5.webp
├── 6.webp
├── 7.webp
├── 8.webp
├── Word2Vec.ipynb
└── notes
│ ├── 01.NLP_Intro.pdf
│ ├── 02.Preprocessing_1.pdf
│ └── 03. Text_Vectorizer.pdf
├── 04 KNN Implementation.pdf
├── 05 logistic_regression.pdf
├── 06 support_vector_machine.pdf
├── 07 naive_bayes.pdf
├── 08 decision_tree.pdf
├── 09 Ensemble_learning.pdf
├── 10 random_forest_algo.pdf
├── 11 Gradient_descent.pdf
├── 12 Bias-Variance_Underfit_overfit.pdf
├── 13 Cross_Validation.pdf
├── 14 classification_metric.pdf
├── 15 Regression_Mertic.pdf
├── 16 Missing_Value.pdf
├── 17 Outlier_detection_elimination.pdf
├── 18 Categorical_Variable_Encode.pdf
├── 19. Pandas_Profiling.pdf
├── 20. Hyperparameter_Tuning.pdf
├── 21. Dimensionality Reduction 1.pdf
├── 22 Dim Reduction Part-1.pdf
├── 23. Backward && Forward Feature Selection PART-2.pdf
├── 24. Feature Extraction Part-3.pdf
├── 25. Clustering.pdf
├── 26. K_means Clustering.pdf
├── 27. Hierarchical clustering.pdf
├── 28. DBSCAN.pdf
├── 29. Clustering Metric.pdf
├── 30. PCA N_component.pdf
├── 31. Pruning.pdf
├── Bias_Variance
├── 1.jpeg
├── 1.png
├── 2.jpeg
├── 2.png
├── 3.jpeg
├── 3.jpg
└── Bias-Variance_Underfit_overfit.ipynb
├── Cross Validation
├── 1.jfif
├── 2.jfif
└── Cross_Validation.ipynb
├── DT
├── 04.jpg
├── 1.png
├── 2.png
├── 3.png
├── 5.png
├── 6.png
├── 7.png
├── Social_Network_Ads.csv
└── decision_tree_classification.ipynb
├── Deep
├── 00.Introduction.ipynb
├── 01. Nueral Netwrok.ipynb
├── 03.Perceptron.ipynb
├── 04. Activation_Function.ipynb
└── 05. Activation_Function 2.ipynb
├── Ensemble
├── 1.png
├── 2.jpg
├── 2.png
├── 3.jpg
├── 4.png
├── 5.jpeg
└── Ensemble_learning.ipynb
├── Gradient Descent
├── 1.png
├── 2.jpg
├── 3.jpg
├── 3.png
├── 4.jpg
├── 6.jpg
├── Gradient_descent.ipynb
└── data.csv
├── KNN Model
├── 1.png
├── 2.png
├── 3.png
├── 4.png
├── 5.png
├── Image 1.png
├── KNN Implementation.ipynb
├── data_cleaned.csv
└── train_cleaned.csv
├── Linear Model
├── 1.png
├── 2.jpg
├── 3.png
├── 55.png
├── 66.png
├── Gradient Descent Algorithm.ipynb
├── Multicollinearity.ipynb
├── Multiple Linear Regression.ipynb
├── Polynomial Linear Regression.ipynb
├── Ridge_And_Lasso_Regression.ipynb
├── Simple Linear Regression.ipynb
└── data
│ ├── 50_Startups.csv
│ ├── Advertising.csv
│ ├── Position_Salaries.csv
│ └── Salary_Data.csv
├── Logistic
├── 05.jpg
├── 1.gif
├── 2.jpg
├── 3.png
├── 4.png
├── Social_Network_Ads.csv
└── logistic_regression.ipynb
├── Metrics
├── 1.gif
├── 1.jpeg
├── 1.jpg
├── 1.png
├── 12.png
├── 13.png
├── 14.png
├── 15.png
├── 16.png
├── 17.png
├── 2.jpeg
├── 2.png
├── 3.jpeg
├── 3.png
├── 4.jpeg
├── 4.png
├── 5.jpeg
├── 5.png
├── 6.jpeg
├── 6.png
├── 7.png
├── 8.png
├── Classification Metrics Roc_Auc.ipynb
├── Evaluation metric.ipynb
├── Regression_Mertic.ipynb
├── all-in-one.jpg
└── metric.jpg
├── Naive Bayes
├── 03.jpg
├── 1.jpeg
├── 2.jpg
├── Social_Network_Ads.csv
└── naive_bayes.ipynb
├── README.md
├── Random_forest
├── 1.png
├── Social_Network_Ads.csv
└── random_forest_classification.ipynb
├── SVM
├── 01.png
├── 02.png
├── 03.png
├── 4.png
├── 5.png
├── 6.png
├── 7.jpg
├── 8.jpg
├── Social_Network_Ads.csv
└── support_vector_machine.ipynb
└── img
└── 1.png
/00 Statistics/1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/1.gif
--------------------------------------------------------------------------------
/00 Statistics/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/1.png
--------------------------------------------------------------------------------
/00 Statistics/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/2.jpg
--------------------------------------------------------------------------------
/00 Statistics/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/2.png
--------------------------------------------------------------------------------
/00 Statistics/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/3.jpg
--------------------------------------------------------------------------------
/00 Statistics/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/3.png
--------------------------------------------------------------------------------
/00 Statistics/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/4.png
--------------------------------------------------------------------------------
/00 Statistics/4.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
--------------------------------------------------------------------------------
/00 Statistics/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/5.jpg
--------------------------------------------------------------------------------
/00 Statistics/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/5.png
--------------------------------------------------------------------------------
/00 Statistics/6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/6.jpg
--------------------------------------------------------------------------------
/00 Statistics/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/6.png
--------------------------------------------------------------------------------
/00 Statistics/7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/7.jpg
--------------------------------------------------------------------------------
/00 Statistics/Basic Stats.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# 1. Introduction OF Statistics\n",
8 | "\n",
9 | "- Statistics is the branch of mathematics dealing with the collection, analysis, interpretation, and presentation of masses of numerical data.\n",
10 | "\n",
11 | "### Before Going 1st we have to know types of Data\n",
12 | " \n",
13 | " - Actually There Are Mainly Two types of data\n",
14 | " 1. Numerical\n",
15 | " 2. Categorical \n",
16 | " \n",
17 | "### 1. In Numerical it divided further two types :\n",
18 | "\n",
19 | " a. Discrete (Use in classification) \n",
20 | " b. Continuous (Use In Regression)\n",
21 | " \n",
22 | " a. Discrete Data Type:\n",
23 | " - The Value Which Counted As Whole or fixed value.\n",
24 | " \n",
25 | " ex. 1,45,73 but not 23.42,36.54\n",
26 | " \n",
27 | " - integer value is discrete value.\n",
28 | " \n",
29 | " ex. age,no. of vechile\n",
30 | " \n",
31 | " b. Continous Data Type:\n",
32 | " - Here Value Contain Range,Measurement \n",
33 | " \n",
34 | " eg. 1.3,1.5,1.6 but not 1,5,6\n",
35 | " \n",
36 | " - it is floating type value\n",
37 | " \n",
38 | " Eg. weight in kg, House price\n",
39 | " \n",
40 | "### 2. Categorical Also Divided Two types :\n",
41 | "\n",
42 | " a. Ordinal \n",
43 | " b. Nominal\n",
44 | " \n",
45 | " a. Ordinal :\n",
46 | " - These are meaningfully ordered\n",
47 | " \n",
48 | " Eg.Rating Of Product, Grade Of Mark\n",
49 | " \n",
50 | " - Here the Quality Increase Lower to Higher and Higher to Lower in order.\n",
51 | " \n",
52 | " b. Nominal :\n",
53 | " - Here No Intrinsic order of the label\n",
54 | " \n",
55 | " - all label are not in order.\n",
56 | " \n",
57 | " Eg. Color - as in color there are many color like Red,green,black etc but can you find any order between them , Ans is no so these type are nominal .\n",
58 | " \n",
59 | "- Basically Categorical are in String (Object) Format\n",
60 | "\n",
61 | "- Numerical are Float or int Format in dataset."
62 | ]
63 | },
64 | {
65 | "cell_type": "markdown",
66 | "metadata": {},
67 | "source": [
68 | "### Now You Learn About Statistics\n",
69 | "\n",
70 | "### Types Of Statistics\n",
71 | "\n",
72 | "Mainly Two Types:\n",
73 | " 1. Descriptive\n",
74 | " 2. Inferential\n",
75 | " \n",
76 | "### 1. Descriptive Statistics\n",
77 | "\n",
78 | "- This is used to describe things, frequently group of peoples.\n",
79 | "\n",
80 | "Eg. Mean,Median,Mode,Variance,Standard Deviation\n",
81 | "\n",
82 | "### 1. Inferential Statistics\n",
83 | "\n",
84 | "- This is used to make inference and draw conclusions.\n",
85 | "\n",
86 | "Eg. T-Tset,Chi-Square,Anova Test\n",
87 | "\n",
88 | "\n",
89 | "### In Upcoming Day's I am Going To Cover all this topic With Python Implementation So Stay Tuned With Me."
90 | ]
91 | },
92 | {
93 | "cell_type": "markdown",
94 | "metadata": {},
95 | "source": [
96 | ""
97 | ]
98 | }
99 | ],
100 | "metadata": {
101 | "kernelspec": {
102 | "display_name": "Python 3",
103 | "language": "python",
104 | "name": "python3"
105 | },
106 | "language_info": {
107 | "codemirror_mode": {
108 | "name": "ipython",
109 | "version": 3
110 | },
111 | "file_extension": ".py",
112 | "mimetype": "text/x-python",
113 | "name": "python",
114 | "nbconvert_exporter": "python",
115 | "pygments_lexer": "ipython3",
116 | "version": "3.7.6"
117 | }
118 | },
119 | "nbformat": 4,
120 | "nbformat_minor": 4
121 | }
122 |
--------------------------------------------------------------------------------
/00 Statistics/Probability Density Function.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/Probability Density Function.pdf
--------------------------------------------------------------------------------
/00 Statistics/stats 2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/stats 2.pdf
--------------------------------------------------------------------------------
/00 Statistics/stats 4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/stats 4.pdf
--------------------------------------------------------------------------------
/00 Statistics/stats link.txt:
--------------------------------------------------------------------------------
1 | https://towardsdatascience.com/40-statistics-interview-problems-and-answers-for-data-scientists-6971a02b7eee
2 | https://www.wisdomjobs.com/e-university/statistics-interview-questions.html
--------------------------------------------------------------------------------
/00 Statistics/stats.txt:
--------------------------------------------------------------------------------
1 | Statistics
2 |
3 | How to Learn Statistics for Data Science As A Self Starter
4 |
5 | Basics Stats
6 | --------------------------------
7 | Probability
8 | 1. Introduction to Basic Terms
9 | 2. Variables
10 | 3. Random Variables
11 | 4. Population,Sample,Population Mean,
12 | Sample Mean
13 | 5. Population Distribution, Sample Distribution
14 | and Sampling Distribution
15 | 6. Mean, Median ,Mode
16 | 7. Range
17 | 8. Measure Of Dispersion
18 | 9. Variance
19 | 10.Standard Deviation
20 | 11.Gaussian/Normal Distribution
21 |
22 | Intermediate Stats
23 | --------------------------------------
24 |
25 | 12. Standard Normal Distribution
26 | 13. Z score
27 | 14. Probability Density Function
28 | 15. Cumulative distribution function
29 | 16. Hypothesis Testing
30 | 17. Many different plotting graphs
31 | 18. Kernel Density Estimation
32 | 19. Central Limit Theorem
33 | 20. Skewness of Data
34 | Covariance
35 | Pearson Correlation Coefficient
36 | Spearman Rank Correlation Coefficient
37 | Importance of Correlation
38 | Hypothesis Testing
39 | Null Hypothesis
40 | Alternative Hypothesis
41 | Understanding Hypothesis testing
42 | (T-test,Chi square test, p values)
43 |
44 | Advanced Stats
45 | -------------------------------------
46 | 21. Q-Q plot
47 | 22. Chebyshev’s inequality
48 | 23. Discrete And Continuous Distribution
49 | 24. Bernoulli And Binomial Distribution
50 | 25. Log Normal Distribution
51 | 26. Power Law Distribution
52 | 27. Box Cox Tranform
53 | 28. Poisson Disstribution
54 | 29. Application Of Non Gaussian Distribution
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/00 Statistics/stats1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/stats1.pdf
--------------------------------------------------------------------------------
/00 Statistics/stats3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/stats3.pdf
--------------------------------------------------------------------------------
/00 Statistics/stats5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Statistics/stats5.pdf
--------------------------------------------------------------------------------
/00 Supervised and Unsupervised learning.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/00 Supervised and Unsupervised learning.pdf
--------------------------------------------------------------------------------
/000All_In_One/whole_Ml_PDF.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/000All_In_One/whole_Ml_PDF.pdf
--------------------------------------------------------------------------------
/01 Simple Linear Regression.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01 Simple Linear Regression.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/00.Introduction.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/00.Introduction.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/01. Nueral Netwrok.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/01. Nueral Netwrok.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/02. Forward And Backward Prop.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/02. Forward And Backward Prop.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/03.Perceptron.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/03.Perceptron.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/04. Activation_Function.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/04. Activation_Function.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/04.2.Vanishing and exploding gradient.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/04.2.Vanishing and exploding gradient.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/05. Activation_Function 2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/05. Activation_Function 2.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/06.Activation_Function_3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/06.Activation_Function_3.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/07. Loss Function.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/07. Loss Function.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/08. When To Use.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/08. When To Use.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/09. Weight Initialize.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/09. Weight Initialize.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/10. Optimization Techniques.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/10. Optimization Techniques.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/11. Optimization Techniques2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/11. Optimization Techniques2.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/13. Regularization Techniques.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/13. Regularization Techniques.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/14. ANN_Example.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/14. ANN_Example.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/15. Convolutional_Neural_Network.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/15. Convolutional_Neural_Network.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/16. Example_OF_CNN.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/16. Example_OF_CNN.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/17.(a) LeNet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/17.(a) LeNet.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/17.(b) Alexnet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/17.(b) Alexnet.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/17.(c) VGGNET.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/17.(c) VGGNET.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/17.(d) ResNet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/17.(d) ResNet.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/17.(e). Inception Network.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/17.(e). Inception Network.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/18. Recurrent Neural Network.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/18. Recurrent Neural Network.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/19. LSTM_GRU.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/01_Deep_Learning_PDF/19. LSTM_GRU.pdf
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/00.Introduction.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | ""
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "
Deep Learning Introduction
"
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "- Deep learning is a branch of machine learning which is completely based on artificial neural networks, as neural network is going to mimic the human brain so deep learning is also a kind of mimic of human brain.\n",
22 | "- it is an artificial intelligence (AI) function that imitates the workings of the human brain in processing data and creating patterns for use in decision making."
23 | ]
24 | },
25 | {
26 | "cell_type": "markdown",
27 | "metadata": {},
28 | "source": [
29 | "### KEY TAKEAWAYS\n",
30 | "* Deep learning is an AI function that mimics the workings of the human brain in processing data for use in detecting objects, recognizing speech, translating languages, and making decisions.\n",
31 | "* Deep learning AI is able to learn without human supervision, drawing from data that is both unstructured and unlabeled.\n",
32 | "* Deep learning, a form of machine learning, can be used to help detect fraud or money laundering, among other functions."
33 | ]
34 | },
35 | {
36 | "cell_type": "markdown",
37 | "metadata": {},
38 | "source": [
39 | "## Key Difference between Machine Learning and Deep Learning :"
40 | ]
41 | },
42 | {
43 | "cell_type": "markdown",
44 | "metadata": {},
45 | "source": [
46 | ""
47 | ]
48 | },
49 | {
50 | "cell_type": "markdown",
51 | "metadata": {},
52 | "source": [
53 | "### Types of Deep Learning Algorithms That I Coverd In Notebook\n",
54 | "1. Multilayer Perceptrons (MLPs)\n",
55 | "2. Convolutional Neural Networks (CNNs)\n",
56 | "3. Recurrent Neural Networks (RNNs)\n",
57 | "4. Long Short Term Memory Networks (LSTMs)\n",
58 | "5. Generative Adversarial Networks (GANs)\n",
59 | "6. Restricted Boltzmann Machines( RBMs)\n",
60 | "7. Autoencoders\n",
61 | "8. Self Organizing Maps (SOMs)\n",
62 | "\n",
63 | "There are so many techniques but in my note book i will focus on this 8 topic."
64 | ]
65 | }
66 | ],
67 | "metadata": {
68 | "kernelspec": {
69 | "display_name": "Python 3",
70 | "language": "python",
71 | "name": "python3"
72 | },
73 | "language_info": {
74 | "codemirror_mode": {
75 | "name": "ipython",
76 | "version": 3
77 | },
78 | "file_extension": ".py",
79 | "mimetype": "text/x-python",
80 | "name": "python",
81 | "nbconvert_exporter": "python",
82 | "pygments_lexer": "ipython3",
83 | "version": "3.7.6"
84 | }
85 | },
86 | "nbformat": 4,
87 | "nbformat_minor": 4
88 | }
89 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/01. Nueral Netwrok.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Neural Networks"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "- Before Deep Dive in to deep learning first see some important terminology regarding this"
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "## Q1. What are Neural networks?\n",
22 | "\n",
23 | "- Neural networks are set of algorithms inspired by the functioning of human brian. Generally when you open your eyes, what you see is called data and is processed by the Nuerons(data processing cells) in your brain, and recognises what is around you. That’s how similar the Neural Networks works. They takes a large set of data, process the data(draws out the patterns from data), and outputs what it is.
\n",
24 | "\n",
25 | "- A neural network is composed of layers, which is a collection of neurons, with connections between different layers. These layers transform data by first calculating the weighted sum of inputs and then normalizing it using the activation functions assigned to the neurons.\n",
26 | "\n",
27 | "\n",
28 | "\n",
29 | "- The leftmost layer in a Neural Network is called the input layer, and the rightmost layer is called the output layer. The layers between the input and the output, are called the hidden layers. Any Neural Network has 1 input layer and 1 output layer. \n",
30 | "\n",
31 | "- The number of hidden layers differ between different networks depending on the complexity of the problem. Also, each hidden layer can have its own activation function.\n",
32 | "\n",
33 | "
\n",
34 | "- Here 3 terms Comes in picture 1. Neuron , 2. Weights , 3. Bias , 4. Actiation_Function"
35 | ]
36 | },
37 | {
38 | "cell_type": "markdown",
39 | "metadata": {},
40 | "source": [
41 | "### 1. Neuron"
42 | ]
43 | },
44 | {
45 | "cell_type": "markdown",
46 | "metadata": {},
47 | "source": [
48 | "- Like in a human brain, the basic building block of a Neural Network is a Neuron. Its functionality is similar to a human brain, i.e, it takes in some inputs and fires an output. Each neuron is a small computing unit that takes a set of real valued numbers as input, performs some computation on them, and produces a single output value.\n",
49 | "\n",
50 | "- The basic unit of computation in a neural network is the neuron, often called as a node or unit. It receives input from some other nodes, or from an external source and computes an output. Each input has an associated weight (w), which is assigned on the basis of its relative importance to other inputs. The node applies a activation function f (defined below) to the weighted sum of its inputs as in figure below.\n",
51 | "\n",
52 | "\n",
53 | "\n",
54 | "##### The above network have: \n",
55 | "- numerical inputs X1 and X2 \n",
56 | "- weights w1 and w2 associated with those inputs\n",
57 | "- b (called the Bias) associated with it.\n",
58 | "\n",
59 | "The Left side Picture is Neuron Of Human Brain ,The Right Side is Artificial Neuron \n",
60 | "\n",
61 | "#### Biological Neuron Work:\n",
62 | "* Information from other neurons, in the form of electrical impulses, enters the dendrites at connection points called synapses. The information flows from the dendrites to the cell where it is processed. The output signal, a train of impulses, is then sent down the axon to the synapse of other neurons.
\n",
63 | "\n",
64 | "#### Artificial Neuron Work:\n",
65 | "* The arrangements and connections of the neurons made up the network and have three layers. \n",
66 | "* The first layer is called the input layer and is the only layer exposed to external signals.\n",
67 | "* The input layer transmits signals to the neurons in the next layer, which is called a hidden layer. The hidden layer extracts relevant features or patterns from the received signals. \n",
68 | "* Those features or patterns that are considered important are then directed to the output layer, which is the final layer of the network."
69 | ]
70 | },
71 | {
72 | "cell_type": "markdown",
73 | "metadata": {},
74 | "source": [
75 | ""
76 | ]
77 | },
78 | {
79 | "cell_type": "markdown",
80 | "metadata": {},
81 | "source": [
82 | "### Single Layers And Multi Layer Netwrok\n",
83 | "\n",
84 | "\n",
85 | "- In Multi Layer net there are many number of hidden layer in between input and output layer,but in single only one or not hidden layer."
86 | ]
87 | },
88 | {
89 | "cell_type": "markdown",
90 | "metadata": {},
91 | "source": [
92 | "### Weight:\n",
93 | "\n",
94 | "* Every input(x) to a neuron has an associated weight(w), which is assigned on the basis of its relative importance to other inputs.\n",
95 | "* The way a neuron works is, if the weighted sum of inputs is greater than a specific threshold, it would give an output 1, otherwise an output 0. This is the mathematical model of a neuron, also known as the Perceptron.\n",
96 | "* Every neural unit takes in a weighted sum of its inputs, with an additional term in the sum called a Bias."
97 | ]
98 | },
99 | {
100 | "cell_type": "markdown",
101 | "metadata": {},
102 | "source": [
103 | "### Bias:\n",
104 | "\n",
105 | "* Bias is a constant which is used to adjust the output along with the weighted sum of inputs, so that the model can best fit for the given data.\n",
106 | "
z=w.x+b
\n",
107 | "\n",
108 | "I defined \n",
109 | "- weighted sum z \n",
110 | "- weight vector w\n",
111 | "- input vector x \n",
112 | "- bias value b.\n",
113 | "\n",
114 | "\n",
115 | "
y=a=f(z)
\n",
116 | "\n",
117 | "- The output(y) of the neuron is a function f of the weighted sum of inputs z. The function f is non linear and is called the Activation Function."
118 | ]
119 | },
120 | {
121 | "cell_type": "markdown",
122 | "metadata": {},
123 | "source": [
124 | "### Activation Function: \n",
125 | "- The purpose of activation function is to introduce non-linearity into the output of neuron. It takes a single number, and performs some mathematical operation on it. There are several activation functions used in practice:\n",
126 | "\n",
127 | " 1. Sigmoid\n",
128 | " 2. Tanh\n",
129 | " 3. ReLU\n",
130 | " 4. Leaky relu\n",
131 | " 5. Softmax function\n",
132 | "- These Are most widly use activation function that i covered in subsequent notebook."
133 | ]
134 | }
135 | ],
136 | "metadata": {
137 | "kernelspec": {
138 | "display_name": "Python 3",
139 | "language": "python",
140 | "name": "python3"
141 | },
142 | "language_info": {
143 | "codemirror_mode": {
144 | "name": "ipython",
145 | "version": 3
146 | },
147 | "file_extension": ".py",
148 | "mimetype": "text/x-python",
149 | "name": "python",
150 | "nbconvert_exporter": "python",
151 | "pygments_lexer": "ipython3",
152 | "version": "3.7.6"
153 | }
154 | },
155 | "nbformat": 4,
156 | "nbformat_minor": 4
157 | }
158 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/03.Perceptron.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# What is Perceptron?"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "
Perceptron is a single layer neural network and a multi-layer perceptron is called Neural Networks.
\n",
15 | "1. Single-layered perceptron model \n",
16 | "2. Multi-layered perceptron model."
17 | ]
18 | },
19 | {
20 | "cell_type": "markdown",
21 | "metadata": {},
22 | "source": [
23 | "### 1. Single-layered perceptron model\n",
24 | "\n",
25 | "\n",
26 | "\n",
27 | "- If you talk about the functioning of the single-layered perceptron model, its algorithm doesn’t have previous information, so initially, weights are allocated inconstantly, then the algorithm adds up all the weighted inputs, \n",
28 | "- if the added value is more than some pre-determined value( or, threshold value) then single-layered perceptron is stated as activated and delivered output as +1.\n",
29 | "- In simple words, multiple input values feed up to the perceptron model, model executes with input values, and if the estimated value is the same as the required output, then the model performance is found out to be satisfied, therefore weights demand no changes. In fact, if the model doesn’t meet the required result then few changes are made up in weights to minimize errors."
30 | ]
31 | },
32 | {
33 | "cell_type": "markdown",
34 | "metadata": {},
35 | "source": [
36 | "### 2. Multi-layered perceptron model\n",
37 | "\n",
38 | "\n",
39 | "- In the forward stage, activation functions are originated from the input layer to the output layer, and in the backward stage, the error between the actual observed value and demanded given value is originated backward in the output layer for modifying weights and bias values.\n",
40 | "- In simple terms, multi-layered perceptron can be treated as a network of numerous artificial neurons overhead varied layers, the activation function is no longer linear, instead, non-linear activation functions such as Sigmoid functions, TanH, ReLU activation Functions, etc are deployed for execution."
41 | ]
42 | },
43 | {
44 | "cell_type": "code",
45 | "execution_count": null,
46 | "metadata": {},
47 | "outputs": [],
48 | "source": []
49 | }
50 | ],
51 | "metadata": {
52 | "kernelspec": {
53 | "display_name": "Python 3",
54 | "language": "python",
55 | "name": "python3"
56 | },
57 | "language_info": {
58 | "codemirror_mode": {
59 | "name": "ipython",
60 | "version": 3
61 | },
62 | "file_extension": ".py",
63 | "mimetype": "text/x-python",
64 | "name": "python",
65 | "nbconvert_exporter": "python",
66 | "pygments_lexer": "ipython3",
67 | "version": "3.7.6"
68 | }
69 | },
70 | "nbformat": 4,
71 | "nbformat_minor": 4
72 | }
73 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/04. Activation_Function.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Activation Function\n",
8 | "\n",
9 | "- Activation function decides, whether a neuron should be activated or not by calculating weighted sum and further adding bias with it. The purpose of the activation function is to introduce non-linearity into the output of a neuron.\n",
10 | "\n",
11 | "### Explanation :-\n",
12 | "We know, neural network has neurons that work in correspondence of weight, bias and their respective activation function. In a neural network, we would update the weights and biases of the neurons on the basis of the error at the output. This process is known as back-propagation. Activation functions make the back-propagation possible since the gradients are supplied along with the error to update the weights and biases. \n",
13 | "Why do we need Non-linear activation functions :- \n",
14 | "A neural network without an activation function is essentially just a linear regression model. The activation function does the non-linear transformation to the input making it capable to learn and perform more complex tasks.\n",
15 | "\n",
16 | "There are several type of Activation But here i dicuss some of them:\n",
17 | " 1. Sigmoid (Binary Classification)\n",
18 | " 2. Tanh\n",
19 | " 3. Relu\n",
20 | " 4. Leaky Relu\n",
21 | " 5. Linear\n",
22 | " 6. Softmax (Use Multiclass Classification)"
23 | ]
24 | },
25 | {
26 | "cell_type": "markdown",
27 | "metadata": {},
28 | "source": [
29 | "### 1. Sigmoid\n",
30 | "\n",
31 | "- The Sigmoid Function curve looks like a S-shape.\n",
32 | "\n",
33 | "\n",
34 | "- The main reason why we use sigmoid function is because it exists between (0 to 1). Therefore, it is especially used for models where we have to predict the probability as an output.Since probability of anything exists only between the range of 0 and 1, sigmoid is the right choice.\n",
35 | "\n",
36 | "#### Derivative Of Sigmoid Function\n",
37 | "\n",
38 | "\n",
39 | "- Sigmoid Function Derivative range from 0 to 0.25\n",
40 | "\n",
41 | "Uses : Usually used in output layer of a binary classification, where result is either 0 or 1, as value for sigmoid function lies between 0 and 1 only so, result can be predicted easily to be 1 if value is greater than 0.5 and 0 otherwise."
42 | ]
43 | },
44 | {
45 | "cell_type": "markdown",
46 | "metadata": {},
47 | "source": [
48 | "### 2. Tanh or hyperbolic tangent Activation Function\n",
49 | "\n",
50 | "- tanh is also like logistic sigmoid but better. The range of the tanh function is from (-1 to 1). tanh is also sigmoidal (s - shaped).\n",
51 | "\n",
52 | "\n",
53 | "- The advantage is that the negative inputs will be mapped strongly negative and the zero inputs will be mapped near zero in the tanh graph.\n",
54 | "- The activation that works almost always better than sigmoid function is Tanh function also knows as Tangent Hyperbolic function. It’s actually mathematically shifted version of the sigmoid function. Both are similar and can be derived from each other.\n",
55 | "\n",
56 | "#### Derivative Of Tanh Function:-\n",
57 | "\n",
58 | "\n",
59 | "\n",
60 | "Sigmoid Function Derivative range from 0 to 1\n",
61 | "\n",
62 | "Uses :- Usually used in hidden layers of a neural network as it’s values lies between -1 to 1 hence the mean for the hidden layer comes out be 0 or very close to it, hence helps in centering the data by bringing mean close to 0. This makes learning for the next layer much easier.\n",
63 | "\n",
64 | "\n",
65 | "\n",
66 | "\n",
67 | "#### Point :-\n",
68 | "1. tanh and logistic sigmoid are the most popular activation functions in 90’s but because of their Vanishing gradient problem and sometimes Exploding gradient problem (because of weights), they aren’t mostly used now.\n",
69 | "2. These days Relu activation function is widely used. Even though, it sometimes gets into vanishing gradient problem, variants of Relu help solving such cases.\n",
70 | "3. tanh is preferred to sigmoid for faster convergence BUT again, this might change based on data. Data will also play an important role in deciding which activation function is best to choose."
71 | ]
72 | }
73 | ],
74 | "metadata": {
75 | "kernelspec": {
76 | "display_name": "Python 3",
77 | "language": "python",
78 | "name": "python3"
79 | },
80 | "language_info": {
81 | "codemirror_mode": {
82 | "name": "ipython",
83 | "version": 3
84 | },
85 | "file_extension": ".py",
86 | "mimetype": "text/x-python",
87 | "name": "python",
88 | "nbconvert_exporter": "python",
89 | "pygments_lexer": "ipython3",
90 | "version": "3.7.6"
91 | }
92 | },
93 | "nbformat": 4,
94 | "nbformat_minor": 4
95 | }
96 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/04.2.Vanishing gradient and exploding gradient.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Vanishing Gradient Problem\n",
8 | "\n",
9 | "- Vanishing gradient problem is a common problem that we face while training deep neural networks.Gradients of neural networks are found during back propagation.\n",
10 | "- Generally, adding more hidden layers will make the network able to learn more complex arbitrary functions, and thus do a better job in predicting future outcomes. This is where Deep Learning is making a big difference.\n",
11 | "\n",
12 | "\n",
13 | "#### Now during back-propagation i.e moving backward in the Network and calculating gradients, it tends to get smaller and smaller as we keep on moving backward in the Network . Below is Just a simple demonstration of Vanishing Gradient Problem in single layer.\n",
14 | "\n",
15 | "\n",
16 | "\n",
17 | "- This Happen because of we use sigmoid and tanh activation function in hidden layer. As sigmoid and tanh deriative 0.25,1 respectively. so by calculating number of hidden layer the derivative becomes 0 so avoid it we use RELU activation function in hidden layer."
18 | ]
19 | },
20 | {
21 | "cell_type": "markdown",
22 | "metadata": {},
23 | "source": [
24 | "### Exploding gradient Problem\n",
25 | "\n",
26 | "- We have discussed about vanishing gradient problem.Now we will get in to exploding gradient problem.Earlier we discussed what happens when our gradient becomes very small.Now we will discuss what will happen if it gets large.\n",
27 | "\n",
28 | "- In deep networks or recurrent neural networks, error gradients can accumulate during an update and result in very large gradients. \n",
29 | "- These in turn result in large updates to the network weights, and in turn, an unstable network.The explosion occurs through exponential growth by repeatedly multiplying gradients through the network layers that have values larger than 1.0.This will ultimately led to an total unstable network.\n",
30 | "\n",
31 | ""
32 | ]
33 | }
34 | ],
35 | "metadata": {
36 | "kernelspec": {
37 | "display_name": "Python 3",
38 | "language": "python",
39 | "name": "python3"
40 | },
41 | "language_info": {
42 | "codemirror_mode": {
43 | "name": "ipython",
44 | "version": 3
45 | },
46 | "file_extension": ".py",
47 | "mimetype": "text/x-python",
48 | "name": "python",
49 | "nbconvert_exporter": "python",
50 | "pygments_lexer": "ipython3",
51 | "version": "3.7.6"
52 | }
53 | },
54 | "nbformat": 4,
55 | "nbformat_minor": 4
56 | }
57 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/05. Activation_Function 2.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### 3. Relu\n",
8 | "- By Using of Sigmoid And Tanh function there is vanishing gradient problem occure so the convergence rate slow down.\n",
9 | "- To overcome slighlty we use Relu Function. it not totally overcome this problem but here the convergence rate is faster than sigmoid and tanh.\n",
10 | "- Value Range :- [0, inf)\n",
11 | "- Its Nature non-linear, which means we can easily backpropagate the errors and have multiple layers of neurons being activated by the ReLU function.\n",
12 | "\n",
13 | "\n",
14 | "##### Point:\n",
15 | "1. Vanishing Gradient Problem occure due to multiple number of derivative.\n",
16 | "2. As sigmoid derivative 0 to 0.25 so by multiple by this sigmoid derivative the result might vanishing gradient as number of hidden layer increase.\n",
17 | "3. But in Relu here its derivative 0 to 1 so here no problem of any vanishing gradient problem as its derivative cant be 0.2,0.3 like. \n",
18 | "4. But as its derivative can be 0 so here a problem aries that called Dead_Activation\n",
19 | "\n",
20 | "Uses :- ReLu is less computationally expensive than tanh and sigmoid because it involves simpler mathematical operations. At a time only a few neurons are activated making the network sparse making it efficient and easy for computation.\n",
21 | "\n",
22 | "### What is Dead_Activation ?\n",
23 | "- When Derivative equal to 0 in Relu Then New Weight = Old Weight : \n",
24 | "\n",
25 | "which is not good for any model.Here Weight Cant be update. it occure when value of z is negative.This state called Dead Activation state. to overcome this we use Leaky Relu.\n",
26 | "\n",
27 | "- See here no updation happen the value remain same and ‘nan’ for validation loss is an unexpected very large or very small number. This is dead activation state to overcome this we use leaky relu"
28 | ]
29 | },
30 | {
31 | "cell_type": "markdown",
32 | "metadata": {},
33 | "source": [
34 | "### mplementing the ReLu function in NumPy is very straight forward:"
35 | ]
36 | },
37 | {
38 | "cell_type": "code",
39 | "execution_count": 1,
40 | "metadata": {},
41 | "outputs": [
42 | {
43 | "name": "stdout",
44 | "output_type": "stream",
45 | "text": [
46 | "[[1 2 3]\n",
47 | " [4 5 6]]\n"
48 | ]
49 | }
50 | ],
51 | "source": [
52 | "import numpy as np\n",
53 | "mmatrix= np.array([[1,2,3],[4,5,6]])\n",
54 | "print(mmatrix)"
55 | ]
56 | },
57 | {
58 | "cell_type": "code",
59 | "execution_count": 2,
60 | "metadata": {},
61 | "outputs": [
62 | {
63 | "data": {
64 | "text/plain": [
65 | "array([[1, 2, 3],\n",
66 | " [4, 5, 6]])"
67 | ]
68 | },
69 | "execution_count": 2,
70 | "metadata": {},
71 | "output_type": "execute_result"
72 | }
73 | ],
74 | "source": [
75 | "#ReLu function\n",
76 | "def relu(X):\n",
77 | " return np.maximum(0,X)\n",
78 | "#Example with mmatrix defined above\n",
79 | "relu(mmatrix)"
80 | ]
81 | },
82 | {
83 | "cell_type": "markdown",
84 | "metadata": {},
85 | "source": [
86 | "## 4. Leaky Relu\n",
87 | "- Leaky ReLU is an improved version of the ReLU function.\n",
88 | "- ReLU function, the gradient is 0 for x < 0(-ve), which made the neurons die for activations in that region.\n",
89 | "- Leaky ReLU is defined to address this problem. Instead of defining the Relu function as 0 for x less than 0, we define it as a small linear component of x. \n",
90 | "- Leaky ReLUs are one attempt to fix the Dying ReLU problem. Instead of the function being zero when x < 0, a leaky ReLU will instead have a small negative slope (of 0.01, or so). That is, the function computes:\n",
91 | "\n",
92 | ""
93 | ]
94 | },
95 | {
96 | "cell_type": "code",
97 | "execution_count": 3,
98 | "metadata": {},
99 | "outputs": [
100 | {
101 | "name": "stdout",
102 | "output_type": "stream",
103 | "text": [
104 | "[[ 0.87916693 0.18566813 -0.00252958 0.85384231 -0.01014912]]\n",
105 | "[[ 0.87916693 0.18566813 -0.00252958 0.85384231 -0.01014912]]\n"
106 | ]
107 | }
108 | ],
109 | "source": [
110 | "### Here are two approaches to implement leaky_relu:\n",
111 | "import numpy as np \n",
112 | "\n",
113 | "x = np.random.normal(size=[1, 5])\n",
114 | "\n",
115 | "# first approach \n",
116 | "leaky_way1 = np.where(x > 0, x, x * 0.01) \n",
117 | "\n",
118 | "# second approach \n",
119 | "y1 = ((x > 0) * x) \n",
120 | "y2 = ((x <= 0) * x * 0.01) \n",
121 | "leaky_way2 = y1 + y2 \n",
122 | "\n",
123 | "print(leaky_way1)\n",
124 | "print(leaky_way2)"
125 | ]
126 | },
127 | {
128 | "cell_type": "markdown",
129 | "metadata": {},
130 | "source": [
131 | "### Sigmoid,Tanh,Relu,Leaky Relu\n",
132 | "\n",
133 | ""
134 | ]
135 | }
136 | ],
137 | "metadata": {
138 | "kernelspec": {
139 | "display_name": "Python 3",
140 | "language": "python",
141 | "name": "python3"
142 | },
143 | "language_info": {
144 | "codemirror_mode": {
145 | "name": "ipython",
146 | "version": 3
147 | },
148 | "file_extension": ".py",
149 | "mimetype": "text/x-python",
150 | "name": "python",
151 | "nbconvert_exporter": "python",
152 | "pygments_lexer": "ipython3",
153 | "version": "3.7.6"
154 | }
155 | },
156 | "nbformat": 4,
157 | "nbformat_minor": 4
158 | }
159 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/07. Loss Function.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Loss Functions\n",
8 | "\n",
9 | "- The loss function is the function that computes the distance between the current output of the algorithm and the expected output. It’s a method to evaluate how your algorithm models the data. It can be categorized into two groups. One for classification (discrete values, 0,1,2…) and the other for regression (continuous values)."
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {},
15 | "source": [
16 | "### TYPES OF LOSS FUNCTION:\n",
17 | "\n",
18 | "1. Regression Loss Functions\n",
19 | "\n",
20 | " Mean Absolute Error\n",
21 | " Mean Squared Error\n",
22 | " Root Mean Square error (RMSE)\n",
23 | "\n",
24 | "2. Binary Classification Loss Functions\n",
25 | "\n",
26 | " Binary Cross-Entropy\n",
27 | " \n",
28 | "3. Multi-Class Classification Loss Functions\n",
29 | "\n",
30 | " Multi-Class Cross-Entropy Loss\n",
31 | " Sparse Multiclass Cross-Entropy Loss"
32 | ]
33 | },
34 | {
35 | "cell_type": "markdown",
36 | "metadata": {},
37 | "source": [
38 | "# Regression Losses"
39 | ]
40 | },
41 | {
42 | "cell_type": "markdown",
43 | "metadata": {},
44 | "source": [
45 | "#### We know all of this regression loss function but here i discuss a brief\n",
46 | "\n",
47 | "### Mean Absolute Error\n",
48 | "\n",
49 | "- Regression metric which measures the average magnitude of errors in a group of predictions, without considering their directions. In other words, it’s a mean of absolute differences among predictions and expected results where all individual deviations have even importance.\n",
50 | "\n",
51 | "\n",
52 | "\n",
53 | "where:\n",
54 | "\n",
55 | "i — index of sample,\n",
56 | "\n",
57 | "ŷ — predicted value,\n",
58 | "\n",
59 | "y — expected value,\n",
60 | "\n",
61 | "m — number of samples in dataset.\n",
62 | "\n",
63 | "Sometimes it is possible to see the form of formula with swapped predicted value and expected value, but it works the same."
64 | ]
65 | },
66 | {
67 | "cell_type": "markdown",
68 | "metadata": {},
69 | "source": [
70 | "### Mean Squared Error\n",
71 | "\n",
72 | "- One of the most commonly used and firstly explained regression metrics. Average squared difference between the predictions and expected results. In other words, an alteration of MAE where instead of taking the absolute value of differences, they are squared.\n",
73 | "\n",
74 | "- In MAE, the partial error values were equal to the distances between points in the coordinate system. Regarding MSE, each partial error is equivalent to the area of the square created out of the geometrical distance between the measured points. All region areas are summed up and averaged.\n",
75 | "\n",
76 | "\n",
77 | "\n",
78 | "Where\n",
79 | "\n",
80 | "i — index of sample,\n",
81 | "\n",
82 | "ŷ — predicted value,\n",
83 | "\n",
84 | "y — expected value,\n",
85 | "\n",
86 | "m — number of samples in dataset."
87 | ]
88 | },
89 | {
90 | "cell_type": "markdown",
91 | "metadata": {},
92 | "source": [
93 | "### Root Mean Square error (RMSE)\n",
94 | "\n",
95 | "- Root Mean Square error is the extension of MSE — measured as the average of square root of sum of squared differences between predictions and actual observations.\n",
96 | ""
97 | ]
98 | },
99 | {
100 | "cell_type": "markdown",
101 | "metadata": {},
102 | "source": [
103 | "# Classification Losses\n",
104 | "\n",
105 | "### Binary Classification Loss Functions\n",
106 | "\n",
107 | "### Binary Cross Entropy\n",
108 | "\n",
109 | "- Also called Sigmoid Cross-Entropy loss. It is a Sigmoid activation plus a Cross-Entropy loss. Unlike Softmax loss it is independent for each vector component (class), meaning that the loss computed for every CNN output vector component is not affected by other component values.\n",
110 | "\n",
111 | "- Binary cross entropy measures how far away from the true value (which is either 0 or 1) the prediction is for each of the classes and then averages these class-wise errors to obtain the final loss.\n",
112 | "\n",
113 | "- We can define cross entropy as the difference between two probability distributions p and q, where p is our true output and q is our estimate of this true output.\n",
114 | "\n",
115 | "- it Only use for binary classification problem\n",
116 | ""
117 | ]
118 | },
119 | {
120 | "cell_type": "markdown",
121 | "metadata": {},
122 | "source": [
123 | "## Multi-Class Classification Loss Functions\n",
124 | "\n",
125 | "### Categorical cross-entropy\n",
126 | "\n",
127 | "- Used binary and multiclass problem, the label needs to be encoded as categorical, one-hot encoding representation (for 3 classes: [0, 1, 0], [1,0,0]…)\n",
128 | "- It is a loss function that is used for single label categorization. This is when only one category is applicable for each data point. In other words, an example can belong to one class only.\n",
129 | "\n",
130 | "\n",
131 | "\n",
132 | "- Use categorical crossentropy in classification problems where only one result can be correct.\n",
133 | "- Example: In the MNIST problem where you have images of the numbers 0,1, 2, 3, 4, 5, 6, 7, 8, and 9. Categorical crossentropy gives the probability that an image of a number is, for example, a 4 or a 9.\n",
134 | "\n",
135 | "- Categorical cross-entropy will compare the distribution of the predictions (the activations in the output layer, one for each class) with the true distribution, where the probability of the true class is set to 1 and 0 for the other classes. To put it in a different way, the true class is represented as a one-hot encoded vector, and the closer the model’s outputs are to that vector, the lower the loss.\n",
136 | "\n",
137 | "### Sparse Categorical cross-entropy\n",
138 | "\n",
139 | "- Used binary and multiclass problem (the label is an integer — 0 or 1 or … n, depends on the number of labels)\n",
140 | "\n",
141 | ""
142 | ]
143 | },
144 | {
145 | "cell_type": "markdown",
146 | "metadata": {},
147 | "source": [
148 | "All Losses : https://keras.io/api/losses/\n",
149 | "### Summary\n",
150 | "\n",
151 | "There are three kinds of classification tasks:\n",
152 | "\n",
153 | " 1. Binary classification: two exclusive classes\n",
154 | " 2. Multi-class classification: more than two exclusive classes\n",
155 | " 3. Multi-label classification: just non-exclusive classes\n",
156 | " \n",
157 | "Here, we can say\n",
158 | "\n",
159 | " 1. In the case of (1), you need to use binary cross entropy.\n",
160 | " 2. In the case of (2), you need to use categorical cross entropy.\n",
161 | " 3.In the case of (3), you need to use binary cross entropy."
162 | ]
163 | }
164 | ],
165 | "metadata": {
166 | "kernelspec": {
167 | "display_name": "Python 3",
168 | "language": "python",
169 | "name": "python3"
170 | },
171 | "language_info": {
172 | "codemirror_mode": {
173 | "name": "ipython",
174 | "version": 3
175 | },
176 | "file_extension": ".py",
177 | "mimetype": "text/x-python",
178 | "name": "python",
179 | "nbconvert_exporter": "python",
180 | "pygments_lexer": "ipython3",
181 | "version": "3.7.6"
182 | }
183 | },
184 | "nbformat": 4,
185 | "nbformat_minor": 4
186 | }
187 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/08. When To Use.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Which Loss and Activation Functions should I use?\n",
8 | "\n",
9 | "- The motive of the blog is to give you some ideas on the usage of “Activation Function” & “Loss function” in different scenarios.\n",
10 | "- Choosing an activation function and loss function is directly dependent upon the output you want to predict. There are different cases and different outputs of a predictive model. Before I introduce you to such cases let see an introduction to the activation function and loss function.\n",
11 | "\n",
12 | "- The activation function activates the neuron that is required for the desired output, converts linear input to non-linear output. If you are not aware of the different activation functions I would recommend you visit my activation pdf to get an in-depth explanation of different activation functions click here : https://github.com/pratyusa98/ML_Algo_pdf/tree/main/01_Deep_Learning_PDF.\n",
13 | "\n",
14 | "- Loss function helps you figure out the performance of your model in prediction, how good the model is able to generalize. It computes the error for every training. You can read more about loss functions and how to reduce the loss https://github.com/pratyusa98/ML_Algo_pdf/tree/main/01_Deep_Learning_PDF.."
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "#### Let’s see the different cases: \n",
22 | "\n",
23 | "\n",
24 | "## CASE 1: When the output is a numerical value that you are trying to predict\n",
25 | "\n",
26 | "- Ex:- Consider predicting the prices of houses provided with different features of the house. A neural network structure where the final layer or the output later will consist of only one neuron that reverts the numerical value. For computing the accuracy score the predicted values are compared to true numeric values.\n",
27 | "\n",
28 | "\n",
29 | "\n",
30 | "- Activation Function to be used in Output layer such cases,\n",
31 | "\n",
32 | " * Linear Activation - it gives output in a numeric form that is the demand for this case. Or\n",
33 | " * ReLU Activation - This activation function gives you positive numeric outputs as a result. \n",
34 | "\n",
35 | "- Loss function to be used in such cases,\n",
36 | "\n",
37 | " * Mean Squared Error (MSE) - This loss function is responsible to compute the average squared difference between the true values and the predicted values."
38 | ]
39 | },
40 | {
41 | "cell_type": "markdown",
42 | "metadata": {},
43 | "source": [
44 | "## CASE 2: When the output you are trying to predict is Binary\n",
45 | "\n",
46 | "- Ex:- Consider a case where the aim is to predict whether a loan applicant will default or not. In these types of cases, the output layer consists of only one neuron that is responsible to result in a value that is between 0 and 1 that can be also called probabilistic scores. \n",
47 | "- For computing the accuracy of the prediction, it is again compared with the true labels. The true value is 1 if the data belongs to that class or else it is 0.\n",
48 | "\n",
49 | "\n",
50 | "\n",
51 | "- Activation Function to be used in Output layer such cases,\n",
52 | "\n",
53 | " * Sigmoid Activation - This activation function gives the output as 0 and 1.\n",
54 | "\n",
55 | "- Loss function to be used in such cases,\n",
56 | "\n",
57 | " * Binary Cross Entropy - The difference between the two probability distributions is given by binary cross-entropy. (p,1-p) is the model distribution predicted by the model, to compare it with true distribution, the binary cross-entropy is used."
58 | ]
59 | },
60 | {
61 | "cell_type": "markdown",
62 | "metadata": {},
63 | "source": [
64 | "## CASE 3: Predicting a single class from many classes\n",
65 | "\n",
66 | "- Ex:- Consider a case where you are predicting the name of the fruit amongst 5 different fruits. In the case, the output layer will consist of only one neuron for every class and it will revert a value between 0 and 1, the output is the probability distribution that results in 1 when all are added. \n",
67 | "\n",
68 | "- Each output is checked with its respective true value to get the accuracy. These values are one-hot-encoded which means if will be 1 for the correct class or else for others it would be zero.\n",
69 | "\n",
70 | "\n",
71 | "\n",
72 | "- Activation Function to be used in Output layer such cases,\n",
73 | "\n",
74 | " * Softmax Activation - This activation function gives the output between 0 and 1 that are the probability scores which if added gives the result as 1. \n",
75 | "\n",
76 | "- Loss function to be used in such cases,\n",
77 | "\n",
78 | " * Cross-Entropy - It computes the difference between two probability distributions. \n",
79 | " * (p1,p2,p3) is the model distribution that is predicted by the model where p1+p2+p3=1. This is compared with the true distribution using cross-entropy."
80 | ]
81 | },
82 | {
83 | "cell_type": "markdown",
84 | "metadata": {},
85 | "source": [
86 | "## CASE 4: Predicting multiple labels from multiple class\n",
87 | "\n",
88 | "- Ex:- Consider the case of predicting different objects in an image having multiple objects. This is termed as multiclass classification. In these types of cases, the output layer consists of only one neuron that is responsible to result in a value that is between 0 and 1 that can be also called probabilistic scores. \n",
89 | "\n",
90 | "- For computing the accuracy of the prediction, it is again compared with the true labels. The true value is 1 if the data belongs to that class or else it is 0.\n",
91 | "\n",
92 | "\n",
93 | "\n",
94 | "- Activation Function to be used in Output layer such cases,\n",
95 | "\n",
96 | " * Sigmoid Activation - This activation function gives the output as 0 and 1.\n",
97 | "\n",
98 | "- Loss function to be used in such cases,\n",
99 | "\n",
100 | " * Binary Cross Entropy - The difference between the two probability distributions is given by binary cross-entropy. (p,1-p) is the model distribution predicted by the model, to compare it with true distribution, the binary cross-entropy is used."
101 | ]
102 | },
103 | {
104 | "cell_type": "markdown",
105 | "metadata": {},
106 | "source": [
107 | "All Losses : https://keras.io/api/losses/ \n",
108 | "All Activation : https://keras.io/api/layers/activations/"
109 | ]
110 | },
111 | {
112 | "cell_type": "markdown",
113 | "metadata": {},
114 | "source": [
115 | "## Summary\n",
116 | "\n",
117 | "- This activation use only output layer and in hidden layer you can use Relu or Leaky Relu.\n",
118 | "- The following table summarizes the above information to allow you to quickly find the final layer activation function and loss function that is appropriate to your use-case\n",
119 | "\n",
120 | ""
121 | ]
122 | }
123 | ],
124 | "metadata": {
125 | "kernelspec": {
126 | "display_name": "Python 3",
127 | "language": "python",
128 | "name": "python3"
129 | },
130 | "language_info": {
131 | "codemirror_mode": {
132 | "name": "ipython",
133 | "version": 3
134 | },
135 | "file_extension": ".py",
136 | "mimetype": "text/x-python",
137 | "name": "python",
138 | "nbconvert_exporter": "python",
139 | "pygments_lexer": "ipython3",
140 | "version": "3.7.6"
141 | }
142 | },
143 | "nbformat": 4,
144 | "nbformat_minor": 4
145 | }
146 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/09. Weight Initialize.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Weight Initialization\n",
8 | "\n",
9 | "- The weight initialization technique you choose for your neural network can determine how quickly the network converges or whether it converges at all. Although the initial values of these weights are just one parameter among many to tune, they are incredibly important. Their distribution affects the gradients and, therefore, the effectiveness of training."
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {},
15 | "source": [
16 | "## Why is weight initialization important?\n",
17 | "\n",
18 | "- Improperly initialized weights can negatively affect the training process by contributing to the vanishing or exploding gradient problem.\n",
19 | "- With the vanishing gradient problem, the weight update is minor and results in slower convergence — this makes the optimization of the loss function slow and in a worst case scenario, may stop the network from converging altogether.\n",
20 | "- Conversely, initializing with weights that are too large may result in exploding gradient values during forward propagation or back-propagation."
21 | ]
22 | },
23 | {
24 | "cell_type": "markdown",
25 | "metadata": {},
26 | "source": [
27 | "### 1. Zero initialization :\n",
28 | "- If all the weights are initialized with 0, the derivative with respect to loss function is the same for every weight(w), thus all weights have the same value in subsequent iterations. \n",
29 | "- This makes hidden units symmetric and continues for all the n iterations i.e. setting weights to 0 does not make it better than a linear model. \n",
30 | "- An important thing to keep in mind is that biases have no effect what so ever when initialized with 0.\n",
31 | "- It also gives problems like vanishing gradient problem.\n",
32 | "\n",
33 | "\n",
34 | "### 2. initialization With -ve Number :\n",
35 | "\n",
36 | "- If all weigth can be negative then it affect Relu Activation Function.As in -ve Relu comes under dead activation problem. so we cant use this technique.\n",
37 | "- Weights can’t be too high as gives problems like exploding Gradient problem(weights of the model explode to infinity), which means that a large space is made available to search for global minima hence convergence becomes slow.\n",
38 | "\n",
39 | "##### To prevent the gradients of the network’s activations from vanishing or exploding, we need to have following rules:\n",
40 | " 1. The mean of the activations should be zero.\n",
41 | " 2. The variance of the activations should stay the same across every layer.\n"
42 | ]
43 | },
44 | {
45 | "cell_type": "markdown",
46 | "metadata": {},
47 | "source": [
48 | "## Idea 1 : Normal or Naïve Initialization:\n",
49 | "\n",
50 | "- In normal distribution weights can be a part of normal or gaussian distribution with mean as zero and a unit standard deviation.\n",
51 | "\n",
52 | "- Random initialization is done so that convergence is not to a false minima.\n",
53 | "- In Keras it can be simply written as hyperparameter as - kernel_initializer='random_normal'"
54 | ]
55 | },
56 | {
57 | "cell_type": "markdown",
58 | "metadata": {},
59 | "source": [
60 | "## Idea 2: Uniform Initialization:\n",
61 | "\n",
62 | "- In uniform initialization of weights , weights belong to a uniform distribution in range a,b with values of a and b as below:\n",
63 | "\n",
64 | "- Whenever sigmoid activation function is used as , Uniform works well.\n",
65 | "- In Keras it can be simply written as hyperparameter as - kernel_initializer='random_uniform'"
66 | ]
67 | },
68 | {
69 | "cell_type": "markdown",
70 | "metadata": {},
71 | "source": [
72 | "## Idea 3: Xavier/ Glorot Weight Initialization:\n",
73 | "\n",
74 | "- The variance of weights in the case normal distribution was not taken care of which resulted in too large or too small activation values which again led to exploding gradient and vanishing gradient problems respectively, when back propagation was done.\n",
75 | "- In order to overcome this problem Xavier Initialization was introduced. It keeps the variance the same across every layer. We will assume that our layer’s activations are normally distributed around zero.\n",
76 | "- Glorot or Xavier had a belief that if they maintain variance of activations in all the layers going forward and backward convergence will be fast as compared to using standard initialization where gap was larger.\n",
77 | "- It have Two Varient\n",
78 | "\n",
79 | " a. Normal Distribution - kernel_initializer='glorot_normal'\n",
80 | " b. Uniform Distribution - kernel_initializer='glorot_uniform'\n",
81 | " \n",
82 | "Point : Works well with tanh , sigmoid activation functions.\n",
83 | "\n",
84 | "### a. Normal Distribution:\n",
85 | "- In Normal Distribution, weights belong to normal distribution where mean is zero and standard deviation is as below:\n",
86 | "\n",
87 | "\n",
88 | "### b. Uniform Distribution:\n",
89 | "- Uniform Distribution , weights belong to uniform distribution in range of a and b defined as below:\n",
90 | "\n"
91 | ]
92 | },
93 | {
94 | "cell_type": "markdown",
95 | "metadata": {},
96 | "source": [
97 | "## Idea 4: He-Initialization:\n",
98 | "- When using activation functions that were zero centered and have output range between-1,1 for activation functions like tanh and softsign, activation outputs were having mean of 0 and standard deviation around 1 average wise.\n",
99 | "- But if ReLu is used instead of tanh, it was observed that on average it has standard deviation very close to square root of 2 divided by input connections.\n",
100 | " - It have Two Varient\n",
101 | "\n",
102 | " a. Normal Distribution - kernel_initializer='he_normal'\n",
103 | " b. Uniform Distribution - kernel_initializer='he_uniform'\n",
104 | "\n",
105 | "Point : Works well with Relu And Leaky Relu activation functions.\n",
106 | "### a. Normal Distribution:\n",
107 | "- In He-Normal initialization method, weights belong to normal distribution where mean is zero and standard deviation is as below:\n",
108 | "\n",
109 | "\n",
110 | "### b. Uniform Initialization :\n",
111 | "- In He Uniform Initialization weights belong to uniform distribution in range as shown below:\n",
112 | ""
113 | ]
114 | }
115 | ],
116 | "metadata": {
117 | "kernelspec": {
118 | "display_name": "Python 3",
119 | "language": "python",
120 | "name": "python3"
121 | },
122 | "language_info": {
123 | "codemirror_mode": {
124 | "name": "ipython",
125 | "version": 3
126 | },
127 | "file_extension": ".py",
128 | "mimetype": "text/x-python",
129 | "name": "python",
130 | "nbconvert_exporter": "python",
131 | "pygments_lexer": "ipython3",
132 | "version": "3.7.6"
133 | }
134 | },
135 | "nbformat": 4,
136 | "nbformat_minor": 4
137 | }
138 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/11. Optimization Techniques2.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## 6. Adaptive Gradient (AdaGrad)\n",
8 | "\n",
9 | "- Adaptive Gradient as the name suggests adopts the learning rate of parameters by updating it at each iteration depending on the position it is present, i.e- by adapting slower learning rates when features are occurring frequently and adapting higher learning rate when features are infrequent.\n",
10 | "- The motivation behind Adagrad is to have different learning rates for each neuron of each hidden layer for each iteration.\n",
11 | "\n",
12 | "##### But why do we need different learning rates?\n",
13 | "Data sets have two types of features:\n",
14 | "- Dense features, e.g. House Price Data set (Large number of non-zero valued features), where we should perform smaller updates on such features; and\n",
15 | "- Sparse Features, e.g. Bag of words (Large number of zero valued features), where we should perform larger updates on such features.\n",
16 | "\n",
17 | "It has been found that Adagrad greatly improved the robustness of SGD, and is used for training large-scale neural nets at Google.\n",
18 | "\n",
19 | "\n",
20 | "\n",
21 | "\n",
22 | "\n",
23 | "η : initial Learning rate\n",
24 | "\n",
25 | "ϵ : smoothing term that avoids division by zero\n",
26 | "\n",
27 | "w: Weight of parameters\n",
28 | "- In SGD learning Rate same for all weight but in Adagrad this is different for all.\n",
29 | "\n",
30 | "#### Advantage:\n",
31 | "- No need to update the learning rate manually as it changes adaptively with iterations.\n",
32 | "- If we have some Sparse and Dense feature it automatically takes out what learning rate is suitable.\n",
33 | "\n",
34 | "#### Disadvantage:\n",
35 | "- As the number of iteration becomes very large learning rate decreases to a very small number which leads to slow convergence.\n",
36 | "- Computationally expensive as a need to calculate the second order derivative.\n",
37 | "\n",
38 | "Adadelta, RMSProp, and adam tries to resolve Adagrad’s radically diminishing learning rates."
39 | ]
40 | },
41 | {
42 | "cell_type": "markdown",
43 | "metadata": {},
44 | "source": [
45 | "## 7. AdaDelta\n",
46 | "\n",
47 | "- It is simply an extension of AdaGrad that seeks to reduce its monotonically decreasing learning rate.\n",
48 | "- Instead of summing all the past gradients, AdaDelta restricts the no. of summation values to a limit (w).\n",
49 | "- In AdaDelta, the sum of past gradients (w) is defined as “Decaying Average of all past squared gradients”. The current average at the iteration then depends only on the previous average and current gradient.\n",
50 | "\n",
51 | "\n",
52 | "\n",
53 | "\n",
54 | "- Instead of inefficiently storing all previous squared gradients, we recursively define a decaying average of all past squared gradients. The running average at each time step then depends (as a fraction γ , similarly to the Momentum term) only on the previous average and the current gradient.\n",
55 | "\n",
56 | "#### Advantages:\n",
57 | "Now the learning rate does not decay and the training does not stop.\n",
58 | "#### Disadvantages:\n",
59 | "Computationally expensive."
60 | ]
61 | },
62 | {
63 | "cell_type": "markdown",
64 | "metadata": {},
65 | "source": [
66 | "## 8. RMSProp\n",
67 | "- RMSProp is Root Mean Square Propagation. It was devised by Geoffrey Hinton.\n",
68 | "- RMSProp tries to resolve Adagrad’s radically diminishing learning rates by using a moving average of the squared gradient. It utilizes the magnitude of the recent gradient descents to normalize the gradient.\n",
69 | "- In RMSProp learning rate gets adjusted automatically and it chooses a different learning rate for each parameter.\n",
70 | "- RMSProp divides the learning rate by the average of the exponential decay of squared gradients\n",
71 | "- Its cost function same as Adadelta"
72 | ]
73 | },
74 | {
75 | "cell_type": "markdown",
76 | "metadata": {},
77 | "source": [
78 | "## 9. Adam — Adaptive Moment Estimation\n",
79 | "\n",
80 | "- It is a combination of RMSProp and Momentum.\n",
81 | "- This method computes adaptive learning rate for each parameter.\n",
82 | "- In addition to storing the previous decaying average of squared gradients, it also holds the average of past gradient similar to Momentum. Thus, Adam behaves like a heavy ball with friction which prefers flat minima in error surface.\n",
83 | "- Another method that calculates the individual adaptive learning rate for each parameter from estimates of first (Momentum) and second (RMSProp) moments of the gradients.\n",
84 | "\n",
85 | "\n",
86 | "\n",
87 | "#### Advantages:\n",
88 | "- The method is too fast and converges rapidly.\n",
89 | "- Rectifies vanishing learning rate, high variance.\n",
90 | "#### Disadvantages:\n",
91 | "- Computationally costly."
92 | ]
93 | }
94 | ],
95 | "metadata": {
96 | "kernelspec": {
97 | "display_name": "Python 3",
98 | "language": "python",
99 | "name": "python3"
100 | },
101 | "language_info": {
102 | "codemirror_mode": {
103 | "name": "ipython",
104 | "version": 3
105 | },
106 | "file_extension": ".py",
107 | "mimetype": "text/x-python",
108 | "name": "python",
109 | "nbconvert_exporter": "python",
110 | "pygments_lexer": "ipython3",
111 | "version": "3.7.6"
112 | }
113 | },
114 | "nbformat": 4,
115 | "nbformat_minor": 4
116 | }
117 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/12. Comparison between various optimizers.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Comparison between various optimizers"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "\n",
15 | "\n",
16 | "- In the animation above it is observed that the SGD algorithm (red) is stuck at a saddle point. So SGD algorithm can only be used for small networks.\n",
17 | "- All the other algorithms except SGD finally converges one after the other, AdaDelta (yellow) being the fastest followed by momentum algorithms.\n",
18 | "- AdaGrad and AdaDelta algorithm can be used for sparse data.\n",
19 | "- Momentum and NAG work well for most cases but is slower.\n",
20 | "- Animation for Adam is not available but from the plot above it is observed that it is the fastest algorithm to converge to minima.\n",
21 | "- Adam is considered the best algorithm amongst all the algorithms discussed above."
22 | ]
23 | },
24 | {
25 | "cell_type": "markdown",
26 | "metadata": {},
27 | "source": []
28 | },
29 | {
30 | "cell_type": "markdown",
31 | "metadata": {},
32 | "source": []
33 | },
34 | {
35 | "cell_type": "markdown",
36 | "metadata": {},
37 | "source": []
38 | },
39 | {
40 | "cell_type": "markdown",
41 | "metadata": {},
42 | "source": []
43 | },
44 | {
45 | "cell_type": "markdown",
46 | "metadata": {},
47 | "source": [
48 | "## Difference Between All Gradient Descent Type"
49 | ]
50 | },
51 | {
52 | "cell_type": "markdown",
53 | "metadata": {},
54 | "source": [
55 | "\n",
56 | "\n",
57 | "\n",
58 | "- Adam is the best optimizers. If one wants to train the neural network in less time and more efficiently than Adam is the optimizer.\n",
59 | "- For sparse data use the optimizers with dynamic learning rate.\n",
60 | "- If, want to use gradient descent algorithm than min-batch gradient descent is the best option."
61 | ]
62 | }
63 | ],
64 | "metadata": {
65 | "kernelspec": {
66 | "display_name": "Python 3",
67 | "language": "python",
68 | "name": "python3"
69 | },
70 | "language_info": {
71 | "codemirror_mode": {
72 | "name": "ipython",
73 | "version": 3
74 | },
75 | "file_extension": ".py",
76 | "mimetype": "text/x-python",
77 | "name": "python",
78 | "nbconvert_exporter": "python",
79 | "pygments_lexer": "ipython3",
80 | "version": "3.7.6"
81 | }
82 | },
83 | "nbformat": 4,
84 | "nbformat_minor": 4
85 | }
86 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/15. Convolutional_Neural_Network .ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Convolutional neural networks (CNN) \n",
8 | "\n",
9 | "- Cnn are one of the most popular models used today. This neural network computational model uses a variation of multilayer perceptrons and contains one or more convolutional layers that can be either entirely connected or pooled. \n",
10 | "- These convolutional layers create feature maps that record a region of image which is ultimately broken into rectangles and sent out for nonlinear processing.\n",
11 | "\n",
12 | "\n",
13 | "\n",
14 | "- Let us suppose this in the input matrix of 5×5 and a filter of matrix 3X3, for those who don’t know what a filter is a set of weights in a matrix applied on an image or a matrix to obtain the required features, please search on convolution if this is your first time!\n",
15 | "\n",
16 | "#### Note: We always take the sum or average of all the values while doing a convolution."
17 | ]
18 | },
19 | {
20 | "cell_type": "markdown",
21 | "metadata": {},
22 | "source": [
23 | "### Steps Involve in CNN\n",
24 | ""
25 | ]
26 | },
27 | {
28 | "attachments": {},
29 | "cell_type": "markdown",
30 | "metadata": {},
31 | "source": [
32 | "### 1. Edge Detection (Convolution)\n",
33 | "- In the previous article, we saw that the early layers of a neural network detect edges from an image. Deeper layers might be able to detect the cause of the objects and even more deeper layers might detect the cause of complete objects (like a person’s face).\n",
34 | "\n",
35 | "In this section, we will focus on how the edges can be detected from an image. Suppose we are given the below image: As you can see, there are many vertical and horizontal edges in the image. The first thing to do is to detect these edges:\n",
36 | "\n",
37 | "\n",
38 | "\n",
39 | "\n",
40 | "\n",
41 | "- So, we take the first 3 X 3 matrix from the 6 X 6 image and multiply it with the filter. Now, the first element of the 4 X 4 output will be the sum of the element-wise product of these values, i.e. 0*0+0*0+1*0+1*0+0*1+0*0+0*0+1*0+1*0 =0. To calculate the second element of the 4 X 4 output, we will shift our filter one step towards the right and again get the sum of the element-wise product:"
42 | ]
43 | },
44 | {
45 | "attachments": {},
46 | "cell_type": "markdown",
47 | "metadata": {},
48 | "source": [
49 | "## 2. Pooling\n",
50 | "\n",
51 | "- A pooling layer is another building block of a CNN. Its function is to progressively reduce the spatial size of the representation to reduce the amount of parameters and computation in the network. Pooling layer operates on each feature map independently. The most common approach used in pooling is max pooling.\n",
52 | "\n",
53 | "#### Types of Pooling Layers :- \n",
54 | " 1. Max Pooling\n",
55 | "Max pooling is a pooling operation that selects the maximum element from the region of the feature map covered by the filter. Thus, the output after max-pooling layer would be a feature map containing the most prominent features of the previous feature map.\n",
56 | "\n",
57 | "\n",
58 | " 2. Average Pooling\n",
59 | "Average pooling computes the average of the elements present in the region of feature map covered by the filter. Thus, while max pooling gives the most prominent feature in a particular patch of the feature map, average pooling gives the average of features present in a patch.\n",
60 | "\n",
61 | "\n",
62 | "- More On Pooling https://www.geeksforgeeks.org/cnn-introduction-to-pooling-layer/\n",
63 | "\n",
64 | "#### Now Apply Pooling in our above Feature Map\n",
65 | "\n",
66 | ""
67 | ]
68 | },
69 | {
70 | "cell_type": "markdown",
71 | "metadata": {},
72 | "source": [
73 | "## Problem with Simple Convolution Layers\n",
74 | "\n",
75 | "- While applying convolutions we will not obtain the output dimensions the same as input we will lose data over borders so we append a border of zeros and recalculate the convolution covering all the input values.\n",
76 | "\n",
77 | " 1. Padding\n",
78 | " 2. Striding\n",
79 | "\n",
80 | "### 1. Padding\n",
81 | "\n",
82 | "\n",
83 | "\n",
84 | "* See In without padding our input is 6x6 but output image goes down into 4x4 . so by using padding we got the same result.Padding is simply a process of adding layers of zeros to our input images so as to avoid the problems mentioned above.\n",
85 | "\n",
86 | "\n",
87 | "* So padding prevents shrinking as, if p = number of layers of zeros added to the border of the image, then our (n x n) image becomes (n + 2p) x (n + 2p) image after padding. So, applying convolution-operation (with (f x f) filter) outputs (n + 2p – f + 1) x (n + 2p – f + 1) images. For example, adding one layer of padding to an (8 x 8) image and using a (3 x 3) filter we would get an (8 x 8) output after performing convolution operation.\n",
88 | "\n",
89 | "\n",
90 | "\n",
91 | "### 2. Strides\n",
92 | "\n",
93 | "- It uses to reduce the size of matrix. if we sfited by 1 then we called stride=1 and if we sfited by 2 means stride = 2 so on.\n",
94 | "\n",
95 | "\n",
96 | "\n",
97 | "\n",
98 | "\n",
99 | "### Padding,Stride Put in One Equation\n",
100 | ""
101 | ]
102 | },
103 | {
104 | "attachments": {},
105 | "cell_type": "markdown",
106 | "metadata": {},
107 | "source": [
108 | "## Step3 : Flattening\n",
109 | "\n",
110 | "- Flattening is converting the data into a 1-dimensional array for inputting it to the next layer. We flatten the output of the convolutional layers to create a single long feature vector. And it is connected to the final classification model, which is called a fully-connected layer.\n",
111 | "\n",
112 | ""
113 | ]
114 | },
115 | {
116 | "attachments": {},
117 | "cell_type": "markdown",
118 | "metadata": {},
119 | "source": [
120 | "## Step 4\n",
121 | "### Complete CNN in one View\n",
122 | "\n",
123 | "#### here in last step we use full connection network\n",
124 | ""
125 | ]
126 | }
127 | ],
128 | "metadata": {
129 | "kernelspec": {
130 | "display_name": "Python 3",
131 | "language": "python",
132 | "name": "python3"
133 | },
134 | "language_info": {
135 | "codemirror_mode": {
136 | "name": "ipython",
137 | "version": 3
138 | },
139 | "file_extension": ".py",
140 | "mimetype": "text/x-python",
141 | "name": "python",
142 | "nbconvert_exporter": "python",
143 | "pygments_lexer": "ipython3",
144 | "version": "3.7.6"
145 | }
146 | },
147 | "nbformat": 4,
148 | "nbformat_minor": 4
149 | }
150 |
--------------------------------------------------------------------------------
/01_Deep_Learning_PDF/ipynb/18. Recurrent Neural Network.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### Q. Why do we use an RNN instead of a simple neural network?"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "We use Recurrent Neural Networks mostly in sequential data.We use RNN over standard neural networks due to the following reasons :\n",
15 | "\n",
16 | "- In case of sequential data, the inputs and outputs can be of different lengths. For e.g. , in sentiment analysis, we map the input sentences to one number describing the sentiment of the text.\n",
17 | "- Standard neural network does not share features learnt across different positions of text. For e.g. , in named entity recognition(identifying names of person in sentences), suppose we identify Henry occurs in first position as name, we would want the algorithm to use this information in case Henry occurs later again in the sentence. We want things learnt in one part to generalize in others parts in sequence data.\n",
18 | "- The parameters required for handling text will be very large in case of Standard neural networks. RNN requires much less parameters to learn."
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "metadata": {},
24 | "source": [
25 | "## Recurrent Neural Network"
26 | ]
27 | },
28 | {
29 | "cell_type": "markdown",
30 | "metadata": {},
31 | "source": [
32 | "- Recurrent Neural Network(RNN) are a type of Neural Network where the output from previous step are fed as input to the current step. \n",
33 | "- In traditional neural networks, all the inputs and outputs are independent of each other, but in cases like when it is required to predict the next word of a sentence, the previous words are required and hence there is a need to remember the previous words.\n",
34 | "- Thus RNN came into existence, which solved this issue with the help of a Hidden Layer. The main and most important feature of RNN is Hidden state, which remembers some information about a sequence.\n",
35 | "- RNN have a “memory” which remembers all information about what has been calculated. It uses the same parameters for each input as it performs the same task on all the inputs or hidden layers to produce the output. \n",
36 | "- This reduces the complexity of parameters, unlike other neural networks.\n",
37 | "\n",
38 | ""
39 | ]
40 | },
41 | {
42 | "cell_type": "markdown",
43 | "metadata": {},
44 | "source": [
45 | "## Types of RNN"
46 | ]
47 | },
48 | {
49 | "cell_type": "markdown",
50 | "metadata": {},
51 | "source": [
52 | ""
53 | ]
54 | },
55 | {
56 | "cell_type": "markdown",
57 | "metadata": {},
58 | "source": [
59 | "#### One-to-one:\n",
60 | "This is also called Plain Neural networks. It deals with a fixed size of the input to the fixed size of output, where they are independent of previous information/output.\n",
61 | "\n",
62 | "Example: Image classification.\n",
63 | "\n",
64 | "#### One-to-Many:\n",
65 | "It deals with a fixed size of information as input that gives a sequence of data as output.\n",
66 | "\n",
67 | "Example: Image Captioning takes the image as input and outputs a sentence of words.\n",
68 | "\n",
69 | "#### Many-to-One:\n",
70 | "It takes a sequence of information as input and outputs a fixed size of the output.\n",
71 | "\n",
72 | "Example: sentiment analysis where any sentence is classified as expressing the positive or negative sentiment.\n",
73 | "\n",
74 | "#### Many-to-Many:\n",
75 | "It takes a Sequence of information as input and processes the recurrently outputs as a Sequence of data.\n",
76 | "\n",
77 | "Example: Machine Translation, where the RNN reads any sentence in English and then outputs the sentence in French.\n",
78 | "\n",
79 | "#### Bidirectional Many-to-Many:\n",
80 | "Synced sequence input and output. Notice that in every case are no pre-specified constraints on the lengths sequences because the recurrent transformation (green) is fixed and can be applied as many times as we like.\n",
81 | "\n",
82 | "Example: Video classification where we wish to label every frame of the video."
83 | ]
84 | },
85 | {
86 | "cell_type": "markdown",
87 | "metadata": {},
88 | "source": [
89 | "
\n",
90 | "
\n",
91 | "\t
S.no
\n",
92 | "\t
CNN
\n",
93 | "\t
RNN
\n",
94 | "
\n",
95 | "
\n",
96 | "\t
1
\n",
97 | "\t
CNN stands for Convolutional Neural Network.
\n",
98 | "\t
RNN stands for Recurrent Neural Network.
\n",
99 | "
\n",
100 | "
\n",
101 | "\t
2
\n",
102 | "\t
CNN is considered to be more potent than RNN.
\n",
103 | "\t
RNN includes less feature compatibility when compared to CNN.
\n",
104 | "
\n",
105 | "
\n",
106 | "\t
3
\n",
107 | "\t
CNN is ideal for images and video processing.
\n",
108 | "\t
RNN is ideal for text and speech Analysis.
\n",
109 | "
\n",
110 | "
\n",
111 | "\t
4
\n",
112 | "\t
It is suitable for spatial data like images.
\n",
113 | "\t
RNN is used for temporal data, also called sequential data.
\n",
114 | "
\n",
115 | "
\n",
116 | "\t
5
\n",
117 | "\t
The network takes fixed-size inputs and generates fixed size outputs.
\n",
118 | "\t
RNN can handle arbitrary input/ output lengths.
\n",
119 | "
\n",
120 | "
\n",
121 | "\t
6
\n",
122 | "\t
CNN is a type of feed-forward artificial neural network with variations of multilayer perceptron's designed to use minimal amounts of preprocessing.
\n",
123 | "\t
RNN, unlike feed-forward neural networks- can use their internal memory to process arbitrary sequences of inputs.
\n",
124 | "
\n",
125 | "
\n",
126 | "\t
7
\n",
127 | "\t
CNN's use of connectivity patterns between the neurons. CNN is affected by the organization of the animal visual cortex, whose individual neurons are arranged in such a way that they can respond to overlapping regions in the visual field.
\n",
128 | "\t
Recurrent neural networks use time-series information- what a user spoke last would impact what he will speak next.
\n",
129 | "
\n",
130 | "
"
131 | ]
132 | },
133 | {
134 | "cell_type": "code",
135 | "execution_count": null,
136 | "metadata": {},
137 | "outputs": [],
138 | "source": []
139 | }
140 | ],
141 | "metadata": {
142 | "kernelspec": {
143 | "display_name": "Python 3",
144 | "language": "python",
145 | "name": "python3"
146 | },
147 | "language_info": {
148 | "codemirror_mode": {
149 | "name": "ipython",
150 | "version": 3
151 | },
152 | "file_extension": ".py",
153 | "mimetype": "text/x-python",
154 | "name": "python",
155 | "nbconvert_exporter": "python",
156 | "pygments_lexer": "ipython3",
157 | "version": "3.7.6"
158 | }
159 | },
160 | "nbformat": 4,
161 | "nbformat_minor": 4
162 | }
163 |
--------------------------------------------------------------------------------
/02 Multicollinearity.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02 Multicollinearity.pdf
--------------------------------------------------------------------------------
/02_Time_series/01.time_series.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## What is a Time Series?\n",
8 | "- It is a series of observations taken at specified times basically at equal intervals.\n",
9 | "- It is used to predict future values based on past observed values. The components you might observe in the time-series analysis are Trend, Seasonal, Irregular, and Cyclicity.\n",
10 | "\n",
11 | "- Two Types Of Time Series Analysis\n",
12 | " 1. Univariate Time Series:- where only one variable is observed at each time\n",
13 | " 2. Multivariate Time Series :- two or more variables are observed at each time \n",
14 | " \n",
15 | ""
16 | ]
17 | },
18 | {
19 | "cell_type": "markdown",
20 | "metadata": {},
21 | "source": [
22 | "## 1. Trend\n",
23 | "- Two Types Up Trend And Down Trend.\n",
24 | "- The linear increasing or decreasing behavior of the series over time.\n",
25 | "\n",
26 | ""
27 | ]
28 | },
29 | {
30 | "cell_type": "markdown",
31 | "metadata": {},
32 | "source": [
33 | "## 2. Seasonality\n",
34 | "- Seasonality refers to periodic fluctuations. \n",
35 | "- For example, electricity consumption is high during the day and low during night, or online sales increase during Christmas before slowing down again.\n",
36 | "\n",
37 | "\n",
38 | "\n",
39 | "- As you can see above, there is a clear daily seasonality. Every day, you see a peak towards the evening, and the lowest points are the beginning and the end of each day."
40 | ]
41 | },
42 | {
43 | "cell_type": "markdown",
44 | "metadata": {},
45 | "source": [
46 | "## 3. Cyclic Variations\n",
47 | "- The variations in a time series which operate themselves over a span of more than one year are the cyclic variations. This oscillatory movement has a period of oscillation of more than a year. One complete period is a cycle. This cyclic movement is sometimes called the ‘Business Cycle’.\n",
48 | "\n",
49 | "\n",
50 | "## 4. Random or Irregular Movements\n",
51 | "- It causes the variation in the variable under study. This is not regular variations and are purely random or irregular. These fluctuations are unforeseen, uncontrollable, unpredictable, and are erratic. These forces are earthquakes, wars, flood, famines, and any other disasters.\n",
52 | "\n",
53 | "\n",
54 | ""
55 | ]
56 | },
57 | {
58 | "cell_type": "markdown",
59 | "metadata": {},
60 | "source": [
61 | "## 5. Stationarity\n",
62 | "\n",
63 | "- Stationarity is an important characteristic of time series. \n",
64 | "- A time series is said to be stationary if its statistical properties(mean,variance) do not change over time. In other words, it has constant mean and variance, and covariance is independent of time.\n",
65 | "\n",
66 | "\n",
67 | "\n",
68 | "- Looking again at the same plot, we see that the process above is stationary. The mean and variance do not vary over time."
69 | ]
70 | }
71 | ],
72 | "metadata": {
73 | "kernelspec": {
74 | "display_name": "Python 3",
75 | "language": "python",
76 | "name": "python3"
77 | },
78 | "language_info": {
79 | "codemirror_mode": {
80 | "name": "ipython",
81 | "version": 3
82 | },
83 | "file_extension": ".py",
84 | "mimetype": "text/x-python",
85 | "name": "python",
86 | "nbconvert_exporter": "python",
87 | "pygments_lexer": "ipython3",
88 | "version": "3.7.6"
89 | }
90 | },
91 | "nbformat": 4,
92 | "nbformat_minor": 4
93 | }
94 |
--------------------------------------------------------------------------------
/02_Time_series/02.Handling a Non-Stationary Time Series.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Handling a Non-Stationary Time Series\n",
8 | "\n",
9 | "- ‘Stationarity’ is one of the most important concepts you will come across when working with time series data. A stationary series is one in which the properties – mean, variance and covariance, do not vary with time.\n",
10 | "\n",
11 | "\n",
12 | "\n",
13 | "- In the first plot, we can clearly see that the mean varies (increases) with time which results in an upward trend. Thus, this is a non-stationary series. For a series to be classified as stationary, it should not exhibit a trend.\n",
14 | "- on to the second plot, we certainly do not see a trend in the series, but the variance of the series is a function of time. As mentioned previously, a stationary series must have a constant variance.\n",
15 | "- If you look at the third plot, the spread becomes closer as the time increases, which implies that the covariance is a function of time.\n",
16 | "- The three examples shown above represent non-stationary time series. Now look at stationary time-series\n",
17 | "\n",
18 | "- In this case, the mean, variance and covariance are constant with time. This is what a stationary time series looks like.\n",
19 | "- So to summarize, a stationary time series is the one for which the properties (namely mean, variance and covariance) do not depend on time. In the next section we will cover various methods to check if the given series is stationary or not."
20 | ]
21 | },
22 | {
23 | "cell_type": "markdown",
24 | "metadata": {},
25 | "source": [
26 | "## Methods to Check Stationarity\n",
27 | "\n",
28 | "#### 1. Visual test :- \n",
29 | "- Code train['feature_name'].plot() By run this it produce the graph like \n",
30 | "\n",
31 | "\n",
32 | "- Although its very clear that we have a trend (varying mean) in the above series, this visual approach might not always give accurate results. It is better to confirm the observations using some statistical tests.\n",
33 | "\n",
34 | "#### 2. Statistical test (ADF (Augmented Dickey Fuller) Test):- \n",
35 | "\n",
36 | "- The Dickey Fuller test is one of the most popular statistical tests. It can be used to determine the presence of unit root in the series, and hence help us understand if the series is stationary or not. The null and alternate hypothesis of this test are:\n",
37 | "\n",
38 | " - Null Hypothesis: The series has a unit root (value of a =1)(not stationary)\n",
39 | "\n",
40 | " - Alternate Hypothesis: The series has no unit root.(stationary)\n",
41 | "\n",
42 | "- If we fail to reject the null hypothesis, we can say that the series is non-stationary. This means that the series can be linear or difference stationary (we will understand more about difference stationary in the next section)."
43 | ]
44 | },
45 | {
46 | "cell_type": "raw",
47 | "metadata": {},
48 | "source": [
49 | "#Ho: It is non stationary\n",
50 | "#H1: It is stationary\n",
51 | "\n",
52 | "## Augmented Dickey Fuller) Test\n",
53 | "from statsmodels.tsa.stattools import adfuller\n",
54 | "def adfuller_test(sales):\n",
55 | " result=adfuller(sales)\n",
56 | " labels = ['ADF Test Statistic','p-value','#Lags Used','Number of Observations Used']\n",
57 | " for value,label in zip(result,labels):\n",
58 | " print(label+' : '+str(value) )\n",
59 | " if result[1] <= 0.05:\n",
60 | " print(\"strong evidence against the null hypothesis(Ho), reject the null hypothesis. Data has no unit root and is stationary\")\n",
61 | " else:\n",
62 | " print(\"weak evidence against null hypothesis, time series has a unit root, indicating it is non-stationary \")"
63 | ]
64 | },
65 | {
66 | "cell_type": "markdown",
67 | "metadata": {},
68 | "source": [
69 | "## Making a Time Series Stationary\n",
70 | "\n",
71 | "### 1. Differencing :-\n",
72 | "- In this method, we compute the difference of consecutive terms in the series. Differencing is typically performed to get rid of the varying mean. Mathematically, differencing can be written as:\n",
73 | "\n",
74 | " yt‘ = yt – y(t-1)\n",
75 | "\n",
76 | "- where yt is the value at a time t\n",
77 | "- Applying differencing on our series and plotting the results:"
78 | ]
79 | },
80 | {
81 | "cell_type": "raw",
82 | "metadata": {},
83 | "source": [
84 | "train['col_diff'] = train['col_name'] - train['col_name'].shift(1)\n",
85 | "train['col_diff'].dropna().plot()"
86 | ]
87 | },
88 | {
89 | "cell_type": "markdown",
90 | "metadata": {},
91 | "source": [
92 | "### 2. Seasonal Differencing :- \n",
93 | "- In seasonal differencing, instead of calculating the difference between consecutive values, we calculate the difference between an observation and a previous observation from the same season. \n",
94 | "- For example, an observation taken on a Monday will be subtracted from an observation taken on the previous Monday. Mathematically it can be written as:\n",
95 | "\n",
96 | " yt‘ = yt – y(t-n)"
97 | ]
98 | },
99 | {
100 | "cell_type": "raw",
101 | "metadata": {},
102 | "source": [
103 | "n=7\n",
104 | "train['Col_seasonal_diff'] = train['Col_name'] - train['col_name'].shift(n)"
105 | ]
106 | },
107 | {
108 | "cell_type": "markdown",
109 | "metadata": {},
110 | "source": [
111 | "### 3. Transformation\n",
112 | "- Transformations are used to stabilize the non-constant variance of a series. Common transformation methods include power transform, square root, and log transform. "
113 | ]
114 | },
115 | {
116 | "cell_type": "raw",
117 | "metadata": {},
118 | "source": [
119 | "train['col_log'] = np.log(train['col_name'])\n",
120 | "train['col_log_diff'] = train['col_log'] - train['col_log'].shift(1)\n",
121 | "train['col_log_diff'].dropna().plot()"
122 | ]
123 | },
124 | {
125 | "cell_type": "code",
126 | "execution_count": null,
127 | "metadata": {},
128 | "outputs": [],
129 | "source": []
130 | }
131 | ],
132 | "metadata": {
133 | "kernelspec": {
134 | "display_name": "Python 3",
135 | "language": "python",
136 | "name": "python3"
137 | },
138 | "language_info": {
139 | "codemirror_mode": {
140 | "name": "ipython",
141 | "version": 3
142 | },
143 | "file_extension": ".py",
144 | "mimetype": "text/x-python",
145 | "name": "python",
146 | "nbconvert_exporter": "python",
147 | "pygments_lexer": "ipython3",
148 | "version": "3.7.6"
149 | }
150 | },
151 | "nbformat": 4,
152 | "nbformat_minor": 4
153 | }
154 |
--------------------------------------------------------------------------------
/02_Time_series/03. Time Series Smoothing Methods.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Time Series Smoothing Methods\n",
8 | "- Smoothing techniques are kinds of data preprocessing techniques to remove noise from a data set. This allows important patterns to stand out.In market analysis, smoothed data is preferred because it generally identifies changes in the economy compared to unsmoothed data.\n",
9 | "- The idea behind data smoothing is that it can identify simplified changes to help predict different trends and patterns. It acts as an aid for statisticians or traders who need to look at a lot of data.\n",
10 | "\n",
11 | "- four major smoothing technique are\n",
12 | " 1. Moving average smoothing\n",
13 | " 2. Exponential smoothing\n",
14 | " 3. Double exponential smoothing\n",
15 | " 4. Triple exponential smoothing"
16 | ]
17 | },
18 | {
19 | "cell_type": "markdown",
20 | "metadata": {},
21 | "source": [
22 | "## 1. Moving average smoothing\n",
23 | "- It is a simple and common type of smoothing used in time series analysis and forecasting. Here time series derived from the average of last kth elements of the series.\n",
24 | ""
25 | ]
26 | },
27 | {
28 | "cell_type": "markdown",
29 | "metadata": {},
30 | "source": [
31 | "## 2. Exponential smoothing\n",
32 | "- Exponential smoothing is a weighted moving average technique. In the moving average smoothing the past observations are weighted equally, In this case smoothing is done by assigning exponentially decreasing weights to the past observations.\n",
33 | "\n",
34 | "\n",
35 | "\n",
36 | "- In the above equation, we can see that (1−α) is multiplied by the previously expected value St-1 which is derived using the same formula.\n",
37 | "- which makes the expression recursive and if you were to write it all out on paper you would quickly see that (1−α) is multiplied by itself again and again. And this is why this method is called exponential."
38 | ]
39 | },
40 | {
41 | "cell_type": "markdown",
42 | "metadata": {},
43 | "source": [
44 | "## 3. Double exponential smoothing\n",
45 | "- Single Smoothing does not excel in the data when there is a trend. This situation can be improved by the introduction of a second equation with a second constant β.\n",
46 | "- it is suitable to model the time series with the trend but without seasonality.\n",
47 | "\n",
48 | "\n",
49 | "\n",
50 | "Here it is seen that α is used for smoothing the level and β is used for smoothing the trend."
51 | ]
52 | },
53 | {
54 | "cell_type": "markdown",
55 | "metadata": {},
56 | "source": [
57 | "## 4. Triple exponential smoothing\n",
58 | "- It is also called as Holt-winters exponential smoothing .it is used to handle the time series data containing a seasonal component.\n",
59 | "- double smoothing will not work in case of data contain seasonality.so that for smoothing the seasonality a third equation is introduced.\n",
60 | "\n",
61 | "\n",
62 | "\n",
63 | "In the above ϕ is the damping constant. α, β, and γ must be estimated in such a way that the MSE(Mean Square Error) of the error is minimized."
64 | ]
65 | }
66 | ],
67 | "metadata": {
68 | "kernelspec": {
69 | "display_name": "Python 3",
70 | "language": "python",
71 | "name": "python3"
72 | },
73 | "language_info": {
74 | "codemirror_mode": {
75 | "name": "ipython",
76 | "version": 3
77 | },
78 | "file_extension": ".py",
79 | "mimetype": "text/x-python",
80 | "name": "python",
81 | "nbconvert_exporter": "python",
82 | "pygments_lexer": "ipython3",
83 | "version": "3.7.6"
84 | }
85 | },
86 | "nbformat": 4,
87 | "nbformat_minor": 4
88 | }
89 |
--------------------------------------------------------------------------------
/02_Time_series/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/1.jpg
--------------------------------------------------------------------------------
/02_Time_series/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/1.png
--------------------------------------------------------------------------------
/02_Time_series/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/10.png
--------------------------------------------------------------------------------
/02_Time_series/11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/11.png
--------------------------------------------------------------------------------
/02_Time_series/12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/12.png
--------------------------------------------------------------------------------
/02_Time_series/13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/13.png
--------------------------------------------------------------------------------
/02_Time_series/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/2.png
--------------------------------------------------------------------------------
/02_Time_series/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/3.png
--------------------------------------------------------------------------------
/02_Time_series/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/4.png
--------------------------------------------------------------------------------
/02_Time_series/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/5.png
--------------------------------------------------------------------------------
/02_Time_series/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/6.png
--------------------------------------------------------------------------------
/02_Time_series/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/7.png
--------------------------------------------------------------------------------
/02_Time_series/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/8.png
--------------------------------------------------------------------------------
/02_Time_series/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/9.png
--------------------------------------------------------------------------------
/02_Time_series/notes/01.time_series.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/notes/01.time_series.pdf
--------------------------------------------------------------------------------
/02_Time_series/notes/02.Handling a Non-Stationary Time Series.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/notes/02.Handling a Non-Stationary Time Series.pdf
--------------------------------------------------------------------------------
/02_Time_series/notes/03. Time Series Smoothing Methods.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/02_Time_series/notes/03. Time Series Smoothing Methods.pdf
--------------------------------------------------------------------------------
/02_Time_series/shampoo Sale.csv:
--------------------------------------------------------------------------------
1 | "Month","Sales of shampoo over a three year period"
2 | "1-01",266.0
3 | "1-02",145.9
4 | "1-03",183.1
5 | "1-04",119.3
6 | "1-05",180.3
7 | "1-06",168.5
8 | "1-07",231.8
9 | "1-08",224.5
10 | "1-09",192.8
11 | "1-10",122.9
12 | "1-11",336.5
13 | "1-12",185.9
14 | "2-01",194.3
15 | "2-02",149.5
16 | "2-03",210.1
17 | "2-04",273.3
18 | "2-05",191.4
19 | "2-06",287.0
20 | "2-07",226.0
21 | "2-08",303.6
22 | "2-09",289.9
23 | "2-10",421.6
24 | "2-11",264.5
25 | "2-12",342.3
26 | "3-01",339.7
27 | "3-02",440.4
28 | "3-03",315.9
29 | "3-04",439.3
30 | "3-05",401.3
31 | "3-06",437.4
32 | "3-07",575.5
33 | "3-08",407.6
34 | "3-09",682.0
35 | "3-10",475.3
36 | "3-11",581.3
37 | "3-12",646.9
38 |
39 | Sales of shampoo over a three year period
40 |
41 |
--------------------------------------------------------------------------------
/03 Multiple Linear Regression.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03 Multiple Linear Regression.pdf
--------------------------------------------------------------------------------
/03 a Polynomial Linear Regression.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03 a Polynomial Linear Regression.pdf
--------------------------------------------------------------------------------
/03. b Ridge_And_Lasso_Regression.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03. b Ridge_And_Lasso_Regression.pdf
--------------------------------------------------------------------------------
/03_NLP/01.NLP_Intro.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## NLP\n",
8 | "\n",
9 | "- Everything we express (either verbally or in written) carries huge amounts of information. The topic we choose, our tone, our selection of words, everything adds some type of information that can be interpreted and value extracted from it. In theory, we can understand and even predict human behaviour using that information.\n",
10 | "- But there is a problem: one person may generate hundreds or thousands of words in a declaration, each sentence with its corresponding complexity. If you want to scale and analyze several hundreds, thousands or millions of people or declarations in a given geography, then the situation is unmanageable.\n",
11 | "- Natural Language Processing or NLP is a field of Artificial Intelligence that gives the machines the ability to read, understand and derive meaning from human languages."
12 | ]
13 | },
14 | {
15 | "cell_type": "markdown",
16 | "metadata": {},
17 | "source": [
18 | "### Important Things In NLP\n",
19 | "\n",
20 | "Text Data Preprocess\n",
21 | "1. Tokenization\n",
22 | "2. Stemming And Lemmatization\n",
23 | "3. Stop Words\n",
24 | "\n",
25 | "Text Data Vectorization\n",
26 | "3. Bag_Of_Words(Count Vectorizer)\n",
27 | "4. TF-IDF\n",
28 | "5. Unigram,BiGram,n-Gram\n",
29 | "6. Word2vc and Average Word2vec"
30 | ]
31 | },
32 | {
33 | "cell_type": "markdown",
34 | "metadata": {},
35 | "source": [
36 | "## Apllication:\n",
37 | "1. Chatbots\n",
38 | "2. Text Classification\n",
39 | "3. Sentiment Analysis\n",
40 | "4. Machine Translation"
41 | ]
42 | }
43 | ],
44 | "metadata": {
45 | "kernelspec": {
46 | "display_name": "Python 3",
47 | "language": "python",
48 | "name": "python3"
49 | },
50 | "language_info": {
51 | "codemirror_mode": {
52 | "name": "ipython",
53 | "version": 3
54 | },
55 | "file_extension": ".py",
56 | "mimetype": "text/x-python",
57 | "name": "python",
58 | "nbconvert_exporter": "python",
59 | "pygments_lexer": "ipython3",
60 | "version": "3.7.6"
61 | }
62 | },
63 | "nbformat": 4,
64 | "nbformat_minor": 4
65 | }
66 |
--------------------------------------------------------------------------------
/03_NLP/03. POS.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### spaCy’s Statistical Models\n",
8 | "\n",
9 | "- These models are the power engines of spaCy. These models enable spaCy to perform several NLP related tasks, such as part-of-speech tagging, named entity recognition, and dependency parsing.\n",
10 | "\n",
11 | "- I’ve listed below the different statistical models in spaCy along with their specifications:\n",
12 | "\n",
13 | " en_core_web_sm: English multi-task CNN trained on OntoNotes. Size – 11 MB\n",
14 | " \n",
15 | " en_core_web_md: English multi-task CNN trained on OntoNotes, with GloVe vectors trained on Common Crawl. Size – 91 MB\n",
16 | " \n",
17 | " en_core_web_lg: English multi-task CNN trained on OntoNotes, with GloVe vectors trained on Common Crawl. Size – 789 MB"
18 | ]
19 | },
20 | {
21 | "cell_type": "code",
22 | "execution_count": 8,
23 | "metadata": {},
24 | "outputs": [],
25 | "source": [
26 | "import spacy\n",
27 | "# spacy.cli.download(\"en_core_web_sm\")\n",
28 | "nlp = spacy.load(\"en_core_web_sm\")"
29 | ]
30 | },
31 | {
32 | "cell_type": "markdown",
33 | "metadata": {},
34 | "source": [
35 | "#### spaCy’s Processing Pipeline\n",
36 | ""
37 | ]
38 | },
39 | {
40 | "cell_type": "code",
41 | "execution_count": 11,
42 | "metadata": {},
43 | "outputs": [
44 | {
45 | "data": {
46 | "text/plain": [
47 | "['tok2vec', 'tagger', 'parser', 'ner', 'attribute_ruler', 'lemmatizer']"
48 | ]
49 | },
50 | "execution_count": 11,
51 | "metadata": {},
52 | "output_type": "execute_result"
53 | }
54 | ],
55 | "source": [
56 | "# Create an nlp object\n",
57 | "doc = nlp(\"He went to play basketball\")\n",
58 | "\n",
59 | "## You can use the below code to figure out the active pipeline components:\n",
60 | "\n",
61 | "nlp.pipe_names\n",
62 | "\n",
63 | "##siable pipline\n",
64 | "# nlp.disable_pipes('tagger', 'parser')"
65 | ]
66 | },
67 | {
68 | "cell_type": "markdown",
69 | "metadata": {},
70 | "source": [
71 | "## 1. Part-of-Speech (POS) Tagging using spaCy"
72 | ]
73 | },
74 | {
75 | "cell_type": "code",
76 | "execution_count": 12,
77 | "metadata": {},
78 | "outputs": [
79 | {
80 | "name": "stdout",
81 | "output_type": "stream",
82 | "text": [
83 | "He --> PRON\n",
84 | "went --> VERB\n",
85 | "to --> PART\n",
86 | "play --> VERB\n",
87 | "basketball --> NOUN\n"
88 | ]
89 | }
90 | ],
91 | "source": [
92 | "import spacy \n",
93 | "nlp = spacy.load('en_core_web_sm')\n",
94 | "\n",
95 | "# Create an nlp object\n",
96 | "doc = nlp(\"He went to play basketball\")\n",
97 | " \n",
98 | "# Iterate over the tokens\n",
99 | "for token in doc:\n",
100 | " # Print the token and its part-of-speech tag\n",
101 | " print(token.text, \"-->\", token.pos_)"
102 | ]
103 | },
104 | {
105 | "cell_type": "code",
106 | "execution_count": 15,
107 | "metadata": {},
108 | "outputs": [
109 | {
110 | "data": {
111 | "text/plain": [
112 | "'particle'"
113 | ]
114 | },
115 | "execution_count": 15,
116 | "metadata": {},
117 | "output_type": "execute_result"
118 | }
119 | ],
120 | "source": [
121 | "# In case you are not sure about any of these tags, then you can simply use spacy.explain() to figure it out:\n",
122 | "spacy.explain(\"PART\")"
123 | ]
124 | },
125 | {
126 | "cell_type": "markdown",
127 | "metadata": {},
128 | "source": [
129 | "## 2. Dependency Parsing using spaCy\n",
130 | "\n",
131 | "- Every sentence has a grammatical structure to it and with the help of dependency parsing, we can extract this structure. It can also be thought of as a directed graph, where nodes correspond to the words in the sentence and the edges between the nodes are the corresponding dependencies between the word.\n",
132 | "\n",
133 | ""
134 | ]
135 | },
136 | {
137 | "cell_type": "code",
138 | "execution_count": 16,
139 | "metadata": {},
140 | "outputs": [
141 | {
142 | "name": "stdout",
143 | "output_type": "stream",
144 | "text": [
145 | "He --> nsubj\n",
146 | "went --> ROOT\n",
147 | "to --> aux\n",
148 | "play --> advcl\n",
149 | "basketball --> dobj\n"
150 | ]
151 | }
152 | ],
153 | "source": [
154 | "# dependency parsing\n",
155 | "for token in doc:\n",
156 | " print(token.text, \"-->\", token.dep_)"
157 | ]
158 | },
159 | {
160 | "cell_type": "markdown",
161 | "metadata": {},
162 | "source": [
163 | "The dependency tag ROOT denotes the main verb or action in the sentence. The other words are directly or indirectly connected to the ROOT word of the sentence. You can find out what other tags stand for by executing the code below:"
164 | ]
165 | },
166 | {
167 | "cell_type": "code",
168 | "execution_count": 17,
169 | "metadata": {},
170 | "outputs": [
171 | {
172 | "data": {
173 | "text/plain": [
174 | "('nominal subject',\n",
175 | " None,\n",
176 | " 'auxiliary',\n",
177 | " 'adverbial clause modifier',\n",
178 | " 'direct object')"
179 | ]
180 | },
181 | "execution_count": 17,
182 | "metadata": {},
183 | "output_type": "execute_result"
184 | }
185 | ],
186 | "source": [
187 | "spacy.explain(\"nsubj\"), spacy.explain(\"ROOT\"), spacy.explain(\"aux\"), spacy.explain(\"advcl\"), spacy.explain(\"dobj\")"
188 | ]
189 | },
190 | {
191 | "cell_type": "markdown",
192 | "metadata": {},
193 | "source": [
194 | "## 3. Named Entity Recognition using spaCy\n",
195 | "\n",
196 | "- Let’s first understand what entities are. Entities are the words or groups of words that represent information about common things such as persons, locations, organizations, etc. These entities have proper names.\n",
197 | "\n",
198 | "For example, consider the following sentence:\n",
199 | "\n",
200 | "\n",
201 | "In this sentence, the entities are “Donald Trump”, “Google”, and “New York City”.\n",
202 | "\n",
203 | "Let’s now see how spaCy recognizes named entities in a sentence."
204 | ]
205 | },
206 | {
207 | "cell_type": "code",
208 | "execution_count": 22,
209 | "metadata": {},
210 | "outputs": [
211 | {
212 | "name": "stdout",
213 | "output_type": "stream",
214 | "text": [
215 | "Apple ORG\n",
216 | "U.K. GPE\n",
217 | "$1 billion MONEY\n"
218 | ]
219 | }
220 | ],
221 | "source": [
222 | "doc = nlp(\"Apple is looking at buying U.K. startup for $1 billion\")\n",
223 | " \n",
224 | "for ent in doc.ents:\n",
225 | " print(ent.text, ent.label_)"
226 | ]
227 | },
228 | {
229 | "cell_type": "code",
230 | "execution_count": 25,
231 | "metadata": {},
232 | "outputs": [
233 | {
234 | "data": {
235 | "text/plain": [
236 | "'Countries, cities, states'"
237 | ]
238 | },
239 | "execution_count": 25,
240 | "metadata": {},
241 | "output_type": "execute_result"
242 | }
243 | ],
244 | "source": [
245 | "spacy.explain(\"GPE\")"
246 | ]
247 | },
248 | {
249 | "cell_type": "code",
250 | "execution_count": null,
251 | "metadata": {},
252 | "outputs": [],
253 | "source": []
254 | }
255 | ],
256 | "metadata": {
257 | "kernelspec": {
258 | "display_name": "Python 3",
259 | "language": "python",
260 | "name": "python3"
261 | },
262 | "language_info": {
263 | "codemirror_mode": {
264 | "name": "ipython",
265 | "version": 3
266 | },
267 | "file_extension": ".py",
268 | "mimetype": "text/x-python",
269 | "name": "python",
270 | "nbconvert_exporter": "python",
271 | "pygments_lexer": "ipython3",
272 | "version": "3.7.6"
273 | }
274 | },
275 | "nbformat": 4,
276 | "nbformat_minor": 4
277 | }
278 |
--------------------------------------------------------------------------------
/03_NLP/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/1.jpg
--------------------------------------------------------------------------------
/03_NLP/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/1.png
--------------------------------------------------------------------------------
/03_NLP/2.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/2.webp
--------------------------------------------------------------------------------
/03_NLP/3.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/3.webp
--------------------------------------------------------------------------------
/03_NLP/4.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/4.webp
--------------------------------------------------------------------------------
/03_NLP/5.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/5.webp
--------------------------------------------------------------------------------
/03_NLP/6.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/6.webp
--------------------------------------------------------------------------------
/03_NLP/7.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/7.webp
--------------------------------------------------------------------------------
/03_NLP/8.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/8.webp
--------------------------------------------------------------------------------
/03_NLP/Word2Vec.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## What is Word Embedding?\n",
8 | "- Humans have always excelled at understanding languages. It is easy for humans to understand the relationship between words but for computers, this task may not be simple. For example, we humans understand the words like king and queen, man and woman, tiger and tigress have a certain type of relation between them but how can a computer figure this out?\n",
9 | "\n",
10 | "- Word embeddings are basically a form of word representation that bridges the human understanding of language to that of a machine. They have learned representations of text in an n-dimensional space where words that have the same meaning have a similar representation. Meaning that two similar words are represented by almost similar vectors that are very closely placed in a vector space. These are essential for solving most Natural language processing problems."
11 | ]
12 | },
13 | {
14 | "cell_type": "markdown",
15 | "metadata": {},
16 | "source": [
17 | "#### Word2Vec is one of the most popular technique to learn word embeddings using shallow neural network. It was developed by Tomas Mikolov in 2013 at Google."
18 | ]
19 | },
20 | {
21 | "cell_type": "markdown",
22 | "metadata": {},
23 | "source": [
24 | "## What is word2Vec?\n",
25 | "\n",
26 | "- Word2vec is a method to efficiently create word embeddings by using a two-layer neural network. It was developed by Tomas Mikolov, et al. at Google in 2013 as a response to make the neural-network-based training of the embedding more efficient and since then has become the de facto standard for developing pre-trained word embedding.\n",
27 | "\n",
28 | "- The input of word2vec is a text corpus and its output is a set of vectors known as feature vectors that represent words in that corpus. While Word2vec is not a deep neural network, it turns text into a numerical form that deep neural networks can understand.\n",
29 | "\n",
30 | "- Word2vec is not a single algorithm but a combination of two techniques – CBOW(Continuous bag of words) and Skip-gram model. Both of these are shallow neural networks which map word(s) to the target variable which is also a word(s). Both of these techniques learn weights which act as word vector representations. \n",
31 | "\n",
32 | ""
33 | ]
34 | },
35 | {
36 | "cell_type": "markdown",
37 | "metadata": {},
38 | "source": [
39 | "### 1. Continuous Bag-of-Words model (CBOW)"
40 | ]
41 | },
42 | {
43 | "cell_type": "markdown",
44 | "metadata": {},
45 | "source": [
46 | "- CBOW predicts the probability of a word to occur given the words surrounding it. We can consider a single word or a group of words. But for simplicity, we will take a single context word and try to predict a single target word.\n",
47 | "- The English language contains almost 1.2 million words, making it impossible to include so many words in our example. So I ‘ll consider a small example in which we have only four words i.e. live, home, they and at. For simplicity, we will consider that the corpus contains only one sentence, that being, ‘They live at home’.\n",
48 | "\n",
49 | "\n",
50 | "\n",
51 | "- First, we convert each word into a one-hot encoding form. Also, we’ll not consider all the words in the sentence but ll only take certain words that are in a window. For example for a window size equal to three, we only consider three words in a sentence. The middle word is to be predicted and the surrounding two words are fed into the neural network as context. The window is then slid and the process is repeated again.\n",
52 | "\n",
53 | "- Finally, after training the network repeatedly by sliding the window a shown above, we get weights which we use to get the embeddings as shown below."
54 | ]
55 | },
56 | {
57 | "cell_type": "markdown",
58 | "metadata": {},
59 | "source": [
60 | "### 2. Skip-gram model\n",
61 | "- The Skip-gram model architecture usually tries to achieve the reverse of what the CBOW model does. It tries to predict the source context words (surrounding words) given a target word (the centre word)\n",
62 | "- The working of the skip-gram model is quite similar to the CBOW but there is just a difference in the architecture of its neural network and the way the weight matrix is generated as shown in the figure below:\n",
63 | "\n",
64 | "\n",
65 | "\n",
66 | "- After obtaining the weight matrix, the steps to get word embedding is same as CBOW.\n",
67 | "\n",
68 | "- So now which one of the two algorithms should we use for implementing word2vec? Turns out for large corpus with higher dimensions, it is better to use skip-gram but is slow to train. Whereas CBOW is better for small corpus and is faster to train too."
69 | ]
70 | },
71 | {
72 | "cell_type": "code",
73 | "execution_count": null,
74 | "metadata": {},
75 | "outputs": [],
76 | "source": []
77 | }
78 | ],
79 | "metadata": {
80 | "kernelspec": {
81 | "display_name": "Python 3",
82 | "language": "python",
83 | "name": "python3"
84 | },
85 | "language_info": {
86 | "codemirror_mode": {
87 | "name": "ipython",
88 | "version": 3
89 | },
90 | "file_extension": ".py",
91 | "mimetype": "text/x-python",
92 | "name": "python",
93 | "nbconvert_exporter": "python",
94 | "pygments_lexer": "ipython3",
95 | "version": "3.7.6"
96 | }
97 | },
98 | "nbformat": 4,
99 | "nbformat_minor": 4
100 | }
101 |
--------------------------------------------------------------------------------
/03_NLP/notes/01.NLP_Intro.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/notes/01.NLP_Intro.pdf
--------------------------------------------------------------------------------
/03_NLP/notes/02.Preprocessing_1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/notes/02.Preprocessing_1.pdf
--------------------------------------------------------------------------------
/03_NLP/notes/03. Text_Vectorizer.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/03_NLP/notes/03. Text_Vectorizer.pdf
--------------------------------------------------------------------------------
/04 KNN Implementation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/04 KNN Implementation.pdf
--------------------------------------------------------------------------------
/05 logistic_regression.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/05 logistic_regression.pdf
--------------------------------------------------------------------------------
/06 support_vector_machine.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/06 support_vector_machine.pdf
--------------------------------------------------------------------------------
/07 naive_bayes.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/07 naive_bayes.pdf
--------------------------------------------------------------------------------
/08 decision_tree.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/08 decision_tree.pdf
--------------------------------------------------------------------------------
/09 Ensemble_learning.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/09 Ensemble_learning.pdf
--------------------------------------------------------------------------------
/10 random_forest_algo.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/10 random_forest_algo.pdf
--------------------------------------------------------------------------------
/11 Gradient_descent.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/11 Gradient_descent.pdf
--------------------------------------------------------------------------------
/12 Bias-Variance_Underfit_overfit.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/12 Bias-Variance_Underfit_overfit.pdf
--------------------------------------------------------------------------------
/13 Cross_Validation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/13 Cross_Validation.pdf
--------------------------------------------------------------------------------
/14 classification_metric.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/14 classification_metric.pdf
--------------------------------------------------------------------------------
/15 Regression_Mertic.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/15 Regression_Mertic.pdf
--------------------------------------------------------------------------------
/16 Missing_Value.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/16 Missing_Value.pdf
--------------------------------------------------------------------------------
/17 Outlier_detection_elimination.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/17 Outlier_detection_elimination.pdf
--------------------------------------------------------------------------------
/18 Categorical_Variable_Encode.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/18 Categorical_Variable_Encode.pdf
--------------------------------------------------------------------------------
/19. Pandas_Profiling.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/19. Pandas_Profiling.pdf
--------------------------------------------------------------------------------
/20. Hyperparameter_Tuning.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/20. Hyperparameter_Tuning.pdf
--------------------------------------------------------------------------------
/21. Dimensionality Reduction 1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/21. Dimensionality Reduction 1.pdf
--------------------------------------------------------------------------------
/22 Dim Reduction Part-1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/22 Dim Reduction Part-1.pdf
--------------------------------------------------------------------------------
/23. Backward && Forward Feature Selection PART-2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/23. Backward && Forward Feature Selection PART-2.pdf
--------------------------------------------------------------------------------
/24. Feature Extraction Part-3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/24. Feature Extraction Part-3.pdf
--------------------------------------------------------------------------------
/25. Clustering.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/25. Clustering.pdf
--------------------------------------------------------------------------------
/26. K_means Clustering.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/26. K_means Clustering.pdf
--------------------------------------------------------------------------------
/27. Hierarchical clustering.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/27. Hierarchical clustering.pdf
--------------------------------------------------------------------------------
/28. DBSCAN.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/28. DBSCAN.pdf
--------------------------------------------------------------------------------
/29. Clustering Metric.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/29. Clustering Metric.pdf
--------------------------------------------------------------------------------
/30. PCA N_component.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/30. PCA N_component.pdf
--------------------------------------------------------------------------------
/31. Pruning.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/31. Pruning.pdf
--------------------------------------------------------------------------------
/Bias_Variance/1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Bias_Variance/1.jpeg
--------------------------------------------------------------------------------
/Bias_Variance/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Bias_Variance/1.png
--------------------------------------------------------------------------------
/Bias_Variance/2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Bias_Variance/2.jpeg
--------------------------------------------------------------------------------
/Bias_Variance/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Bias_Variance/2.png
--------------------------------------------------------------------------------
/Bias_Variance/3.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Bias_Variance/3.jpeg
--------------------------------------------------------------------------------
/Bias_Variance/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Bias_Variance/3.jpg
--------------------------------------------------------------------------------
/Bias_Variance/Bias-Variance_Underfit_overfit.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## What Is Bias ?\n",
8 | "\n",
9 | "- It is difference between Predicted Value and Actual Value.\n",
10 | "- Bias refers to the error introduced due to assumptions made to model a relatively complex real-life problem by an approximate simple model.\n",
11 | "\n",
12 | "\n",
13 | "\n",
14 | " - Low Bias: Predicting less assumption about Target Function(Predict Value >> Actual Value)\n",
15 | " - difference is Very Samll Between predcit and Actual Value\n",
16 | " \n",
17 | " - High Bias: Predicting more assumption about Target Function (Predict Value >>>>>> Actual Value)\n",
18 | " - difference is very much large between predcit and Actual Value\n",
19 | " \n",
20 | "\n",
21 | "Examples of low-bias machine learning algorithms include Decision Trees, k-Nearest Neighbors and Support Vector Machines.\n",
22 | "\n",
23 | "Examples of high-bias machine learning algorithms include Linear Regression, Linear Discriminant Analysis, and Logistic Regression."
24 | ]
25 | },
26 | {
27 | "cell_type": "markdown",
28 | "metadata": {},
29 | "source": [
30 | "## What Is Variance ?\n",
31 | "\n",
32 | "- Variance is the amount that the estimate of the target function will change if different training data was used.\n",
33 | "- It determine how spread of predcit value each other\n",
34 | "\n",
35 | "\n",
36 | "\n",
37 | "\n",
38 | " - Low Variance: Predicting small changes to the estimate of the target function with changes to the training dataset.\n",
39 | "\n",
40 | "\n",
41 | " - High Variance: Predicting large changes to the estimate of the target function with changes to the training dataset.\n",
42 | "\n",
43 | "\n",
44 | "\n",
45 | "\n",
46 | "\n",
47 | "- Examples of low-variance machine learning algorithms include Linear Regression, Linear Discriminant Analysis, and Logistic Regression.\n",
48 | "- Examples of high-variance machine learning algorithms include Decision Trees, k-Nearest Neighbors and Support Vector Machines."
49 | ]
50 | },
51 | {
52 | "cell_type": "markdown",
53 | "metadata": {},
54 | "source": [
55 | "### Till now we have some basic knowledge about Bias and Variance, now let's know some other important terminology used in Bias and Variance that are Underfitting and Overfitting."
56 | ]
57 | },
58 | {
59 | "cell_type": "markdown",
60 | "metadata": {},
61 | "source": [
62 | "# Overfit And Underfit :\n",
63 | "\n",
64 | "\n",
65 | "\n",
66 | "\n",
67 | "\n",
68 | "## Underfit :\n",
69 | "\n",
70 | "- These models usually have high bias and low variance. \n",
71 | "- underfitting happens when a model unable to capture the underlying pattern of the data. \n",
72 | "- It happens when we have very less amount of data to build an accurate model or when we try to build a linear model with a nonlinear data. Also, these kind of models are very simple to capture the complex patterns in data like Linear and logistic regression.\n",
73 | "\n",
74 | "- Here Training Accuracy is 50% But Testing Accuracy is around 49%. See there is less accuracy this tends to underfit.\n",
75 | "\n",
76 | "- Underfitting is when the model’s error on both the training and test sets (i.e. during training and testing) is very high.\n",
77 | "\n",
78 | "#### How to Oercome Underfitting :\n",
79 | "\n",
80 | "- In that case, there are 2 gold standard approaches:\n",
81 | "\n",
82 | " 1. Try another model\n",
83 | " 2. Increase the complexity of the current model\n",
84 | " \n",
85 | "Solution 1 is trivial. Concerning solution 2, an example an be the following: if someone is fitting a linear regression to some data, then increasing the complexity would mean to fit a polynomial model.\n",
86 | "\n",
87 | "\n",
88 | "## Overfit :\n",
89 | "\n",
90 | "- These models have low bias and high variance.\n",
91 | "- overfitting happens when our model captures the noise along with the underlying pattern in data.\n",
92 | "- It happens when we train our model a lot over the noisy dataset. \n",
93 | "- These models are very complex like Decision trees which are prone to overfitting.\n",
94 | "\n",
95 | "\n",
96 | "- - Here Training Accuracy is 99% But Testing Accuracy is around 50%. there is huge difference between training and testing score this tends to overfit\n",
97 | "\n",
98 | "- Overfitting is when the model’s error on the training set (i.e. during training) is very low but then, the model’s error on the test set (i.e. unseen samples) is large!\n",
99 | "\n",
100 | "\n",
101 | "#### How to overcome Overfitting :\n",
102 | "\n",
103 | "- The most common problem in the ML learning filed is overfitting.\n",
104 | "\n",
105 | "- Action that could (potentially) limit overfitting:\n",
106 | " \n",
107 | " 1. We can use a Cross-validation (CV) scheme.\n",
108 | " \n",
109 | " 2. Reduce the complexity of the model (make the model less complex).\n",
110 | "\n",
111 | "- When it comes to solution 1 i.e. the use of cross-validation, the most famous CV scheme is the KFolds cross-validation. Using a KFolds scheme, we train and test your model k-times on different subsets of the training data and estimate a performance metric using the test (unseen) data.\n",
112 | "\n",
113 | "- When it comes to solution 2 i.e. reducing the complexity of the model can help reduce the overfitting. For example, if someone is using an SVM model with RBF kernel then reducing the complexity would mean to use a linear kernel. In another case, if someone is fitting a polynomial to some data, then reducing the complexity would mean to fit a linear model instead (linear regression).\n",
114 | "\n",
115 | "\n",
116 | ""
117 | ]
118 | },
119 | {
120 | "cell_type": "markdown",
121 | "metadata": {},
122 | "source": [
123 | "## What is Bias-Variance Tradeoff ?\n",
124 | "\n",
125 | "- If our model is too simple and has very few parameters then it may have high bias and low variance. \n",
126 | "- On the other hand, if our model has a large number of parameters then it’s going to have high variance and low bias.\n",
127 | "- So we need to find the right/good balance without overfitting and underfitting the data.\n",
128 | "\n",
129 | "\n",
130 | "\n",
131 | "- There is no escaping the relationship between bias and variance in machine learning.\n",
132 | " * Increasing the bias will decrease the variance.\n",
133 | " * Increasing the variance will decrease the bias.\n",
134 | " \n",
135 | "- If the algorithm is too simple then it may be on high bias and low variance condition and thus is error-prone. If algorithms fit too complex then it may be on high variance and low bias. In the latter condition, the new entries will not perform well. Well, there is something between both of these conditions, known as Trade-off or Bias Variance Trade-off.\n",
136 | "\n",
137 | "- The error to complexity graph to show trade-off is given as –\n",
138 | "\n",
139 | ".\n",
140 | "\n",
141 | "\n",
142 | "The above picture shows that :\n",
143 | "\n",
144 | "- Bias initially decreases faster than variance.\n",
145 | "- After a point, variance increases significantly with an increase in flexibility with little impact on bias.\n",
146 | "\n",
147 | "This is referred to as the best point chosen for the training of the algorithm which gives low error in training as well as testing data."
148 | ]
149 | }
150 | ],
151 | "metadata": {
152 | "kernelspec": {
153 | "display_name": "Python 3",
154 | "language": "python",
155 | "name": "python3"
156 | },
157 | "language_info": {
158 | "codemirror_mode": {
159 | "name": "ipython",
160 | "version": 3
161 | },
162 | "file_extension": ".py",
163 | "mimetype": "text/x-python",
164 | "name": "python",
165 | "nbconvert_exporter": "python",
166 | "pygments_lexer": "ipython3",
167 | "version": "3.7.6"
168 | }
169 | },
170 | "nbformat": 4,
171 | "nbformat_minor": 4
172 | }
173 |
--------------------------------------------------------------------------------
/Cross Validation/1.jfif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Cross Validation/1.jfif
--------------------------------------------------------------------------------
/Cross Validation/2.jfif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Cross Validation/2.jfif
--------------------------------------------------------------------------------
/DT/04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/DT/04.jpg
--------------------------------------------------------------------------------
/DT/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/DT/1.png
--------------------------------------------------------------------------------
/DT/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/DT/2.png
--------------------------------------------------------------------------------
/DT/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/DT/3.png
--------------------------------------------------------------------------------
/DT/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/DT/5.png
--------------------------------------------------------------------------------
/DT/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/DT/6.png
--------------------------------------------------------------------------------
/DT/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/DT/7.png
--------------------------------------------------------------------------------
/Deep/00.Introduction.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | ""
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "
Deep Learning Introduction
"
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "- Deep learning is a branch of machine learning which is completely based on artificial neural networks, as neural network is going to mimic the human brain so deep learning is also a kind of mimic of human brain.\n",
22 | "- it is an artificial intelligence (AI) function that imitates the workings of the human brain in processing data and creating patterns for use in decision making."
23 | ]
24 | },
25 | {
26 | "cell_type": "markdown",
27 | "metadata": {},
28 | "source": [
29 | "### KEY TAKEAWAYS\n",
30 | "* Deep learning is an AI function that mimics the workings of the human brain in processing data for use in detecting objects, recognizing speech, translating languages, and making decisions.\n",
31 | "* Deep learning AI is able to learn without human supervision, drawing from data that is both unstructured and unlabeled.\n",
32 | "* Deep learning, a form of machine learning, can be used to help detect fraud or money laundering, among other functions."
33 | ]
34 | },
35 | {
36 | "cell_type": "markdown",
37 | "metadata": {},
38 | "source": [
39 | "## Key Difference between Machine Learning and Deep Learning :"
40 | ]
41 | },
42 | {
43 | "cell_type": "markdown",
44 | "metadata": {},
45 | "source": [
46 | ""
47 | ]
48 | },
49 | {
50 | "cell_type": "markdown",
51 | "metadata": {},
52 | "source": [
53 | "### Types of Deep Learning Algorithms That I Coverd In Notebook\n",
54 | "1. Multilayer Perceptrons (MLPs)\n",
55 | "2. Convolutional Neural Networks (CNNs)\n",
56 | "3. Recurrent Neural Networks (RNNs)\n",
57 | "4. Long Short Term Memory Networks (LSTMs)\n",
58 | "5. Generative Adversarial Networks (GANs)\n",
59 | "6. Restricted Boltzmann Machines( RBMs)\n",
60 | "7. Autoencoders\n",
61 | "8. Self Organizing Maps (SOMs)\n",
62 | "\n",
63 | "There are so many techniques but in my note book i will focus on this 8 topic."
64 | ]
65 | }
66 | ],
67 | "metadata": {
68 | "kernelspec": {
69 | "display_name": "Python 3",
70 | "language": "python",
71 | "name": "python3"
72 | },
73 | "language_info": {
74 | "codemirror_mode": {
75 | "name": "ipython",
76 | "version": 3
77 | },
78 | "file_extension": ".py",
79 | "mimetype": "text/x-python",
80 | "name": "python",
81 | "nbconvert_exporter": "python",
82 | "pygments_lexer": "ipython3",
83 | "version": "3.7.6"
84 | }
85 | },
86 | "nbformat": 4,
87 | "nbformat_minor": 4
88 | }
89 |
--------------------------------------------------------------------------------
/Deep/01. Nueral Netwrok.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Neural Networks"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "- Before Deep Dive in to deep learning first see some important terminology regarding this"
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "## Q1. What are Neural networks?\n",
22 | "\n",
23 | "- Neural networks are set of algorithms inspired by the functioning of human brian. Generally when you open your eyes, what you see is called data and is processed by the Nuerons(data processing cells) in your brain, and recognises what is around you. That’s how similar the Neural Networks works. They takes a large set of data, process the data(draws out the patterns from data), and outputs what it is.
\n",
24 | "\n",
25 | "- A neural network is composed of layers, which is a collection of neurons, with connections between different layers. These layers transform data by first calculating the weighted sum of inputs and then normalizing it using the activation functions assigned to the neurons.\n",
26 | "\n",
27 | "\n",
28 | "\n",
29 | "- The leftmost layer in a Neural Network is called the input layer, and the rightmost layer is called the output layer. The layers between the input and the output, are called the hidden layers. Any Neural Network has 1 input layer and 1 output layer. \n",
30 | "\n",
31 | "- The number of hidden layers differ between different networks depending on the complexity of the problem. Also, each hidden layer can have its own activation function.\n",
32 | "\n",
33 | "
\n",
34 | "- Here 3 terms Comes in picture 1. Neuron , 2. Weights , 3. Bias , 4. Actiation_Function"
35 | ]
36 | },
37 | {
38 | "cell_type": "markdown",
39 | "metadata": {},
40 | "source": [
41 | "### 1. Neuron"
42 | ]
43 | },
44 | {
45 | "cell_type": "markdown",
46 | "metadata": {},
47 | "source": [
48 | "- Like in a human brain, the basic building block of a Neural Network is a Neuron. Its functionality is similar to a human brain, i.e, it takes in some inputs and fires an output. Each neuron is a small computing unit that takes a set of real valued numbers as input, performs some computation on them, and produces a single output value.\n",
49 | "\n",
50 | "- The basic unit of computation in a neural network is the neuron, often called as a node or unit. It receives input from some other nodes, or from an external source and computes an output. Each input has an associated weight (w), which is assigned on the basis of its relative importance to other inputs. The node applies a activation function f (defined below) to the weighted sum of its inputs as in figure below.\n",
51 | "\n",
52 | "\n",
53 | "\n",
54 | "##### The above network have: \n",
55 | "- numerical inputs X1 and X2 \n",
56 | "- weights w1 and w2 associated with those inputs\n",
57 | "- b (called the Bias) associated with it.\n",
58 | "\n",
59 | "The Left side Picture is Neuron Of Human Brain ,The Right Side is Artificial Neuron \n",
60 | "\n",
61 | "#### Biological Neuron Work:\n",
62 | "* Information from other neurons, in the form of electrical impulses, enters the dendrites at connection points called synapses. The information flows from the dendrites to the cell where it is processed. The output signal, a train of impulses, is then sent down the axon to the synapse of other neurons.
\n",
63 | "\n",
64 | "#### Artificial Neuron Work:\n",
65 | "* The arrangements and connections of the neurons made up the network and have three layers. \n",
66 | "* The first layer is called the input layer and is the only layer exposed to external signals.\n",
67 | "* The input layer transmits signals to the neurons in the next layer, which is called a hidden layer. The hidden layer extracts relevant features or patterns from the received signals. \n",
68 | "* Those features or patterns that are considered important are then directed to the output layer, which is the final layer of the network."
69 | ]
70 | },
71 | {
72 | "cell_type": "markdown",
73 | "metadata": {},
74 | "source": [
75 | ""
76 | ]
77 | },
78 | {
79 | "cell_type": "markdown",
80 | "metadata": {},
81 | "source": [
82 | "### Single Layers And Multi Layer Netwrok\n",
83 | "\n",
84 | "\n",
85 | "- In Multi Layer net there are many number of hidden layer in between input and output layer,but in single only one or not hidden layer."
86 | ]
87 | },
88 | {
89 | "cell_type": "markdown",
90 | "metadata": {},
91 | "source": [
92 | "### Weight:\n",
93 | "\n",
94 | "* Every input(x) to a neuron has an associated weight(w), which is assigned on the basis of its relative importance to other inputs.\n",
95 | "* The way a neuron works is, if the weighted sum of inputs is greater than a specific threshold, it would give an output 1, otherwise an output 0. This is the mathematical model of a neuron, also known as the Perceptron.\n",
96 | "* Every neural unit takes in a weighted sum of its inputs, with an additional term in the sum called a Bias."
97 | ]
98 | },
99 | {
100 | "cell_type": "markdown",
101 | "metadata": {},
102 | "source": [
103 | "### Bias:\n",
104 | "\n",
105 | "* Bias is a constant which is used to adjust the output along with the weighted sum of inputs, so that the model can best fit for the given data.\n",
106 | "
z=w.x+b
\n",
107 | "\n",
108 | "I defined \n",
109 | "- weighted sum z \n",
110 | "- weight vector w\n",
111 | "- input vector x \n",
112 | "- bias value b.\n",
113 | "\n",
114 | "\n",
115 | "
y=a=f(z)
\n",
116 | "\n",
117 | "- The output(y) of the neuron is a function f of the weighted sum of inputs z. The function f is non linear and is called the Activation Function."
118 | ]
119 | },
120 | {
121 | "cell_type": "markdown",
122 | "metadata": {},
123 | "source": [
124 | "### Activation Function: \n",
125 | "- The purpose of activation function is to introduce non-linearity into the output of neuron. It takes a single number, and performs some mathematical operation on it. There are several activation functions used in practice:\n",
126 | "\n",
127 | " 1. Sigmoid\n",
128 | " 2. Tanh\n",
129 | " 3. ReLU\n",
130 | " 4. Leaky relu\n",
131 | " 5. Softmax function\n",
132 | "- These Are most widly use activation function that i covered in subsequent notebook."
133 | ]
134 | }
135 | ],
136 | "metadata": {
137 | "kernelspec": {
138 | "display_name": "Python 3",
139 | "language": "python",
140 | "name": "python3"
141 | },
142 | "language_info": {
143 | "codemirror_mode": {
144 | "name": "ipython",
145 | "version": 3
146 | },
147 | "file_extension": ".py",
148 | "mimetype": "text/x-python",
149 | "name": "python",
150 | "nbconvert_exporter": "python",
151 | "pygments_lexer": "ipython3",
152 | "version": "3.7.6"
153 | }
154 | },
155 | "nbformat": 4,
156 | "nbformat_minor": 4
157 | }
158 |
--------------------------------------------------------------------------------
/Deep/03.Perceptron.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# What is Perceptron?"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "
Perceptron is a single layer neural network and a multi-layer perceptron is called Neural Networks.
\n",
15 | "1. Single-layered perceptron model \n",
16 | "2. Multi-layered perceptron model."
17 | ]
18 | },
19 | {
20 | "cell_type": "markdown",
21 | "metadata": {},
22 | "source": [
23 | "### 1. Single-layered perceptron model\n",
24 | "\n",
25 | "\n",
26 | "\n",
27 | "- If you talk about the functioning of the single-layered perceptron model, its algorithm doesn’t have previous information, so initially, weights are allocated inconstantly, then the algorithm adds up all the weighted inputs, \n",
28 | "- if the added value is more than some pre-determined value( or, threshold value) then single-layered perceptron is stated as activated and delivered output as +1.\n",
29 | "- In simple words, multiple input values feed up to the perceptron model, model executes with input values, and if the estimated value is the same as the required output, then the model performance is found out to be satisfied, therefore weights demand no changes. In fact, if the model doesn’t meet the required result then few changes are made up in weights to minimize errors."
30 | ]
31 | },
32 | {
33 | "cell_type": "markdown",
34 | "metadata": {},
35 | "source": [
36 | "### 2. Multi-layered perceptron model\n",
37 | "\n",
38 | "\n",
39 | "- In the forward stage, activation functions are originated from the input layer to the output layer, and in the backward stage, the error between the actual observed value and demanded given value is originated backward in the output layer for modifying weights and bias values.\n",
40 | "- In simple terms, multi-layered perceptron can be treated as a network of numerous artificial neurons overhead varied layers, the activation function is no longer linear, instead, non-linear activation functions such as Sigmoid functions, TanH, ReLU activation Functions, etc are deployed for execution."
41 | ]
42 | }
43 | ],
44 | "metadata": {
45 | "kernelspec": {
46 | "display_name": "Python 3",
47 | "language": "python",
48 | "name": "python3"
49 | },
50 | "language_info": {
51 | "codemirror_mode": {
52 | "name": "ipython",
53 | "version": 3
54 | },
55 | "file_extension": ".py",
56 | "mimetype": "text/x-python",
57 | "name": "python",
58 | "nbconvert_exporter": "python",
59 | "pygments_lexer": "ipython3",
60 | "version": "3.7.6"
61 | }
62 | },
63 | "nbformat": 4,
64 | "nbformat_minor": 4
65 | }
66 |
--------------------------------------------------------------------------------
/Deep/04. Activation_Function.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Activation Function\n",
8 | "\n",
9 | "- Activation function decides, whether a neuron should be activated or not by calculating weighted sum and further adding bias with it. The purpose of the activation function is to introduce non-linearity into the output of a neuron.\n",
10 | "\n",
11 | "### Explanation :-\n",
12 | "We know, neural network has neurons that work in correspondence of weight, bias and their respective activation function. In a neural network, we would update the weights and biases of the neurons on the basis of the error at the output. This process is known as back-propagation. Activation functions make the back-propagation possible since the gradients are supplied along with the error to update the weights and biases. \n",
13 | "Why do we need Non-linear activation functions :- \n",
14 | "A neural network without an activation function is essentially just a linear regression model. The activation function does the non-linear transformation to the input making it capable to learn and perform more complex tasks.\n",
15 | "\n",
16 | "There are several type of Activation But here i dicuss some of them:\n",
17 | " 1. Sigmoid\n",
18 | " 2. Tanh\n",
19 | " 3. Relu\n",
20 | " 4. Leaky Relu\n",
21 | " 5. Linear"
22 | ]
23 | },
24 | {
25 | "cell_type": "markdown",
26 | "metadata": {},
27 | "source": [
28 | "### 1. Sigmoid\n",
29 | "\n",
30 | "- The Sigmoid Function curve looks like a S-shape.\n",
31 | "\n",
32 | "\n",
33 | "- The main reason why we use sigmoid function is because it exists between (0 to 1). Therefore, it is especially used for models where we have to predict the probability as an output.Since probability of anything exists only between the range of 0 and 1, sigmoid is the right choice.\n",
34 | "\n",
35 | "#### Derivative Of Sigmoid Function\n",
36 | "\n",
37 | "\n",
38 | "- Sigmoid Function Derivative range from 0 to 0.25\n",
39 | "\n",
40 | "Uses : Usually used in output layer of a binary classification, where result is either 0 or 1, as value for sigmoid function lies between 0 and 1 only so, result can be predicted easily to be 1 if value is greater than 0.5 and 0 otherwise."
41 | ]
42 | },
43 | {
44 | "cell_type": "markdown",
45 | "metadata": {},
46 | "source": [
47 | "### 2. Tanh or hyperbolic tangent Activation Function\n",
48 | "\n",
49 | "- tanh is also like logistic sigmoid but better. The range of the tanh function is from (-1 to 1). tanh is also sigmoidal (s - shaped).\n",
50 | "\n",
51 | "\n",
52 | "- The advantage is that the negative inputs will be mapped strongly negative and the zero inputs will be mapped near zero in the tanh graph.\n",
53 | "- The activation that works almost always better than sigmoid function is Tanh function also knows as Tangent Hyperbolic function. It’s actually mathematically shifted version of the sigmoid function. Both are similar and can be derived from each other.\n",
54 | "\n",
55 | "#### Derivative Of Tanh Function:-\n",
56 | "\n",
57 | "\n",
58 | "\n",
59 | "Sigmoid Function Derivative range from 0 to 1\n",
60 | "\n",
61 | "Uses :- Usually used in hidden layers of a neural network as it’s values lies between -1 to 1 hence the mean for the hidden layer comes out be 0 or very close to it, hence helps in centering the data by bringing mean close to 0. This makes learning for the next layer much easier.\n",
62 | "\n",
63 | "\n",
64 | "\n",
65 | "\n",
66 | "#### Point :-\n",
67 | "1. tanh and logistic sigmoid are the most popular activation functions in 90’s but because of their Vanishing gradient problem and sometimes Exploding gradient problem (because of weights), they aren’t mostly used now.\n",
68 | "2. These days Relu activation function is widely used. Even though, it sometimes gets into vanishing gradient problem, variants of Relu help solving such cases.\n",
69 | "3. tanh is preferred to sigmoid for faster convergence BUT again, this might change based on data. Data will also play an important role in deciding which activation function is best to choose."
70 | ]
71 | },
72 | {
73 | "cell_type": "code",
74 | "execution_count": null,
75 | "metadata": {},
76 | "outputs": [],
77 | "source": []
78 | }
79 | ],
80 | "metadata": {
81 | "kernelspec": {
82 | "display_name": "Python 3",
83 | "language": "python",
84 | "name": "python3"
85 | },
86 | "language_info": {
87 | "codemirror_mode": {
88 | "name": "ipython",
89 | "version": 3
90 | },
91 | "file_extension": ".py",
92 | "mimetype": "text/x-python",
93 | "name": "python",
94 | "nbconvert_exporter": "python",
95 | "pygments_lexer": "ipython3",
96 | "version": "3.7.6"
97 | }
98 | },
99 | "nbformat": 4,
100 | "nbformat_minor": 4
101 | }
102 |
--------------------------------------------------------------------------------
/Deep/05. Activation_Function 2.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### 3. Relu\n",
8 | "- By Using of Sigmoid And Tanh function there is vanishing gradient problem occure so the convergence rate slow down.\n",
9 | "- To overcome slighlty we use Relu Function. it not totally overcome this problem but here the convergence rate is faster than sigmoid and tanh.\n",
10 | "- Value Range :- [0, inf)\n",
11 | "- Its Nature non-linear, which means we can easily backpropagate the errors and have multiple layers of neurons being activated by the ReLU function.\n",
12 | "\n",
13 | "\n",
14 | "##### Point:\n",
15 | "1. Vanishing Gradient Problem occure due to multiple number of derivative.\n",
16 | "2. As sigmoid derivative 0 to 0.25 so by multiple by this sigmoid derivative the result might vanishing gradient as number of hidden layer increase.\n",
17 | "3. But in Relu here its derivative 0 to 1 so here no problem of any vanishing gradient problem as its derivative cant be 0.2,0.3 like. \n",
18 | "4. But as its derivative can be 0 so here a problem aries that called Dead_Activation\n",
19 | "\n",
20 | "Uses :- ReLu is less computationally expensive than tanh and sigmoid because it involves simpler mathematical operations. At a time only a few neurons are activated making the network sparse making it efficient and easy for computation.\n",
21 | "\n",
22 | "### What is Dead_Activation ?\n",
23 | "- When Derivative equal to 0 in Relu Then New Weight = Old Weight : \n",
24 | "\n",
25 | "which is not good for any model.Here Weight Cant be update. it occure when value of z is negative.This state called Dead Activation state. to overcome this we use Leaky Relu.\n",
26 | "\n",
27 | "- See here no updation happen the value remain same and ‘nan’ for validation loss is an unexpected very large or very small number. This is dead activation state to overcome this we use leaky relu"
28 | ]
29 | },
30 | {
31 | "cell_type": "markdown",
32 | "metadata": {},
33 | "source": [
34 | "## 4. Leaky Relu\n",
35 | "- Leaky ReLU is an improved version of the ReLU function.\n",
36 | "- ReLU function, the gradient is 0 for x < 0(-ve), which made the neurons die for activations in that region.\n",
37 | "- Leaky ReLU is defined to address this problem. Instead of defining the Relu function as 0 for x less than 0, we define it as a small linear component of x. \n",
38 | "- Leaky ReLUs are one attempt to fix the Dying ReLU problem. Instead of the function being zero when x < 0, a leaky ReLU will instead have a small negative slope (of 0.01, or so). That is, the function computes:\n",
39 | "\n",
40 | ""
41 | ]
42 | },
43 | {
44 | "cell_type": "markdown",
45 | "metadata": {},
46 | "source": [
47 | "### Sigmoid,Tanh,Relu,Leaky Relu\n",
48 | "\n",
49 | ""
50 | ]
51 | },
52 | {
53 | "cell_type": "code",
54 | "execution_count": null,
55 | "metadata": {},
56 | "outputs": [],
57 | "source": []
58 | }
59 | ],
60 | "metadata": {
61 | "kernelspec": {
62 | "display_name": "Python 3",
63 | "language": "python",
64 | "name": "python3"
65 | },
66 | "language_info": {
67 | "codemirror_mode": {
68 | "name": "ipython",
69 | "version": 3
70 | },
71 | "file_extension": ".py",
72 | "mimetype": "text/x-python",
73 | "name": "python",
74 | "nbconvert_exporter": "python",
75 | "pygments_lexer": "ipython3",
76 | "version": "3.7.6"
77 | }
78 | },
79 | "nbformat": 4,
80 | "nbformat_minor": 4
81 | }
82 |
--------------------------------------------------------------------------------
/Ensemble/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Ensemble/1.png
--------------------------------------------------------------------------------
/Ensemble/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Ensemble/2.jpg
--------------------------------------------------------------------------------
/Ensemble/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Ensemble/2.png
--------------------------------------------------------------------------------
/Ensemble/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Ensemble/3.jpg
--------------------------------------------------------------------------------
/Ensemble/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Ensemble/4.png
--------------------------------------------------------------------------------
/Ensemble/5.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Ensemble/5.jpeg
--------------------------------------------------------------------------------
/Gradient Descent/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Gradient Descent/1.png
--------------------------------------------------------------------------------
/Gradient Descent/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Gradient Descent/2.jpg
--------------------------------------------------------------------------------
/Gradient Descent/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Gradient Descent/3.jpg
--------------------------------------------------------------------------------
/Gradient Descent/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Gradient Descent/3.png
--------------------------------------------------------------------------------
/Gradient Descent/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Gradient Descent/4.jpg
--------------------------------------------------------------------------------
/Gradient Descent/6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Gradient Descent/6.jpg
--------------------------------------------------------------------------------
/Gradient Descent/data.csv:
--------------------------------------------------------------------------------
1 | 32.502345269453031,31.70700584656992
2 | 53.426804033275019,68.77759598163891
3 | 61.530358025636438,62.562382297945803
4 | 47.475639634786098,71.546632233567777
5 | 59.813207869512318,87.230925133687393
6 | 55.142188413943821,78.211518270799232
7 | 52.211796692214001,79.64197304980874
8 | 39.299566694317065,59.171489321869508
9 | 48.10504169176825,75.331242297063056
10 | 52.550014442733818,71.300879886850353
11 | 45.419730144973755,55.165677145959123
12 | 54.351634881228918,82.478846757497919
13 | 44.164049496773352,62.008923245725825
14 | 58.16847071685779,75.392870425994957
15 | 56.727208057096611,81.43619215887864
16 | 48.955888566093719,60.723602440673965
17 | 44.687196231480904,82.892503731453715
18 | 60.297326851333466,97.379896862166078
19 | 45.618643772955828,48.847153317355072
20 | 38.816817537445637,56.877213186268506
21 | 66.189816606752601,83.878564664602763
22 | 65.41605174513407,118.59121730252249
23 | 47.48120860786787,57.251819462268969
24 | 41.57564261748702,51.391744079832307
25 | 51.84518690563943,75.380651665312357
26 | 59.370822011089523,74.765564032151374
27 | 57.31000343834809,95.455052922574737
28 | 63.615561251453308,95.229366017555307
29 | 46.737619407976972,79.052406169565586
30 | 50.556760148547767,83.432071421323712
31 | 52.223996085553047,63.358790317497878
32 | 35.567830047746632,41.412885303700563
33 | 42.436476944055642,76.617341280074044
34 | 58.16454011019286,96.769566426108199
35 | 57.504447615341789,74.084130116602523
36 | 45.440530725319981,66.588144414228594
37 | 61.89622268029126,77.768482417793024
38 | 33.093831736163963,50.719588912312084
39 | 36.436009511386871,62.124570818071781
40 | 37.675654860850742,60.810246649902211
41 | 44.555608383275356,52.682983366387781
42 | 43.318282631865721,58.569824717692867
43 | 50.073145632289034,82.905981485070512
44 | 43.870612645218372,61.424709804339123
45 | 62.997480747553091,115.24415280079529
46 | 32.669043763467187,45.570588823376085
47 | 40.166899008703702,54.084054796223612
48 | 53.575077531673656,87.994452758110413
49 | 33.864214971778239,52.725494375900425
50 | 64.707138666121296,93.576118692658241
51 | 38.119824026822805,80.166275447370964
52 | 44.502538064645101,65.101711570560326
53 | 40.599538384552318,65.562301260400375
54 | 41.720676356341293,65.280886920822823
55 | 51.088634678336796,73.434641546324301
56 | 55.078095904923202,71.13972785861894
57 | 41.377726534895203,79.102829683549857
58 | 62.494697427269791,86.520538440347153
59 | 49.203887540826003,84.742697807826218
60 | 41.102685187349664,59.358850248624933
61 | 41.182016105169822,61.684037524833627
62 | 50.186389494880601,69.847604158249183
63 | 52.378446219236217,86.098291205774103
64 | 50.135485486286122,59.108839267699643
65 | 33.644706006191782,69.89968164362763
66 | 39.557901222906828,44.862490711164398
67 | 56.130388816875467,85.498067778840223
68 | 57.362052133238237,95.536686846467219
69 | 60.269214393997906,70.251934419771587
70 | 35.678093889410732,52.721734964774988
71 | 31.588116998132829,50.392670135079896
72 | 53.66093226167304,63.642398775657753
73 | 46.682228649471917,72.247251068662365
74 | 43.107820219102464,57.812512976181402
75 | 70.34607561504933,104.25710158543822
76 | 44.492855880854073,86.642020318822006
77 | 57.50453330326841,91.486778000110135
78 | 36.930076609191808,55.231660886212836
79 | 55.805733357942742,79.550436678507609
80 | 38.954769073377065,44.847124242467601
81 | 56.901214702247074,80.207523139682763
82 | 56.868900661384046,83.14274979204346
83 | 34.33312470421609,55.723489260543914
84 | 59.04974121466681,77.634182511677864
85 | 57.788223993230673,99.051414841748269
86 | 54.282328705967409,79.120646274680027
87 | 51.088719898979143,69.588897851118475
88 | 50.282836348230731,69.510503311494389
89 | 44.211741752090113,73.687564318317285
90 | 38.005488008060688,61.366904537240131
91 | 32.940479942618296,67.170655768995118
92 | 53.691639571070056,85.668203145001542
93 | 68.76573426962166,114.85387123391394
94 | 46.230966498310252,90.123572069967423
95 | 68.319360818255362,97.919821035242848
96 | 50.030174340312143,81.536990783015028
97 | 49.239765342753763,72.111832469615663
98 | 50.039575939875988,85.232007342325673
99 | 48.149858891028863,66.224957888054632
100 | 25.128484647772304,53.454394214850524
101 |
--------------------------------------------------------------------------------
/KNN Model/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/KNN Model/1.png
--------------------------------------------------------------------------------
/KNN Model/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/KNN Model/2.png
--------------------------------------------------------------------------------
/KNN Model/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/KNN Model/3.png
--------------------------------------------------------------------------------
/KNN Model/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/KNN Model/4.png
--------------------------------------------------------------------------------
/KNN Model/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/KNN Model/5.png
--------------------------------------------------------------------------------
/KNN Model/Image 1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/KNN Model/Image 1.png
--------------------------------------------------------------------------------
/Linear Model/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Linear Model/1.png
--------------------------------------------------------------------------------
/Linear Model/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Linear Model/2.jpg
--------------------------------------------------------------------------------
/Linear Model/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Linear Model/3.png
--------------------------------------------------------------------------------
/Linear Model/55.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Linear Model/55.png
--------------------------------------------------------------------------------
/Linear Model/66.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Linear Model/66.png
--------------------------------------------------------------------------------
/Linear Model/data/50_Startups.csv:
--------------------------------------------------------------------------------
1 | R&D Spend,Administration,Marketing Spend,State,Profit
2 | 165349.2,136897.8,471784.1,New York,192261.83
3 | 162597.7,151377.59,443898.53,California,191792.06
4 | 153441.51,101145.55,407934.54,Florida,191050.39
5 | 144372.41,118671.85,383199.62,New York,182901.99
6 | 142107.34,91391.77,366168.42,Florida,166187.94
7 | 131876.9,99814.71,362861.36,New York,156991.12
8 | 134615.46,147198.87,127716.82,California,156122.51
9 | 130298.13,145530.06,323876.68,Florida,155752.6
10 | 120542.52,148718.95,311613.29,New York,152211.77
11 | 123334.88,108679.17,304981.62,California,149759.96
12 | 101913.08,110594.11,229160.95,Florida,146121.95
13 | 100671.96,91790.61,249744.55,California,144259.4
14 | 93863.75,127320.38,249839.44,Florida,141585.52
15 | 91992.39,135495.07,252664.93,California,134307.35
16 | 119943.24,156547.42,256512.92,Florida,132602.65
17 | 114523.61,122616.84,261776.23,New York,129917.04
18 | 78013.11,121597.55,264346.06,California,126992.93
19 | 94657.16,145077.58,282574.31,New York,125370.37
20 | 91749.16,114175.79,294919.57,Florida,124266.9
21 | 86419.7,153514.11,0,New York,122776.86
22 | 76253.86,113867.3,298664.47,California,118474.03
23 | 78389.47,153773.43,299737.29,New York,111313.02
24 | 73994.56,122782.75,303319.26,Florida,110352.25
25 | 67532.53,105751.03,304768.73,Florida,108733.99
26 | 77044.01,99281.34,140574.81,New York,108552.04
27 | 64664.71,139553.16,137962.62,California,107404.34
28 | 75328.87,144135.98,134050.07,Florida,105733.54
29 | 72107.6,127864.55,353183.81,New York,105008.31
30 | 66051.52,182645.56,118148.2,Florida,103282.38
31 | 65605.48,153032.06,107138.38,New York,101004.64
32 | 61994.48,115641.28,91131.24,Florida,99937.59
33 | 61136.38,152701.92,88218.23,New York,97483.56
34 | 63408.86,129219.61,46085.25,California,97427.84
35 | 55493.95,103057.49,214634.81,Florida,96778.92
36 | 46426.07,157693.92,210797.67,California,96712.8
37 | 46014.02,85047.44,205517.64,New York,96479.51
38 | 28663.76,127056.21,201126.82,Florida,90708.19
39 | 44069.95,51283.14,197029.42,California,89949.14
40 | 20229.59,65947.93,185265.1,New York,81229.06
41 | 38558.51,82982.09,174999.3,California,81005.76
42 | 28754.33,118546.05,172795.67,California,78239.91
43 | 27892.92,84710.77,164470.71,Florida,77798.83
44 | 23640.93,96189.63,148001.11,California,71498.49
45 | 15505.73,127382.3,35534.17,New York,69758.98
46 | 22177.74,154806.14,28334.72,California,65200.33
47 | 1000.23,124153.04,1903.93,New York,64926.08
48 | 1315.46,115816.21,297114.46,Florida,49490.75
49 | 0,135426.92,0,California,42559.73
50 | 542.05,51743.15,0,New York,35673.41
51 | 0,116983.8,45173.06,California,14681.4
--------------------------------------------------------------------------------
/Linear Model/data/Advertising.csv:
--------------------------------------------------------------------------------
1 | ,TV,radio,newspaper,sales
2 | 1,230.1,37.8,69.2,22.1
3 | 2,44.5,39.3,45.1,10.4
4 | 3,17.2,45.9,69.3,9.3
5 | 4,151.5,41.3,58.5,18.5
6 | 5,180.8,10.8,58.4,12.9
7 | 6,8.7,48.9,75,7.2
8 | 7,57.5,32.8,23.5,11.8
9 | 8,120.2,19.6,11.6,13.2
10 | 9,8.6,2.1,1,4.8
11 | 10,199.8,2.6,21.2,10.6
12 | 11,66.1,5.8,24.2,8.6
13 | 12,214.7,24,4,17.4
14 | 13,23.8,35.1,65.9,9.2
15 | 14,97.5,7.6,7.2,9.7
16 | 15,204.1,32.9,46,19
17 | 16,195.4,47.7,52.9,22.4
18 | 17,67.8,36.6,114,12.5
19 | 18,281.4,39.6,55.8,24.4
20 | 19,69.2,20.5,18.3,11.3
21 | 20,147.3,23.9,19.1,14.6
22 | 21,218.4,27.7,53.4,18
23 | 22,237.4,5.1,23.5,12.5
24 | 23,13.2,15.9,49.6,5.6
25 | 24,228.3,16.9,26.2,15.5
26 | 25,62.3,12.6,18.3,9.7
27 | 26,262.9,3.5,19.5,12
28 | 27,142.9,29.3,12.6,15
29 | 28,240.1,16.7,22.9,15.9
30 | 29,248.8,27.1,22.9,18.9
31 | 30,70.6,16,40.8,10.5
32 | 31,292.9,28.3,43.2,21.4
33 | 32,112.9,17.4,38.6,11.9
34 | 33,97.2,1.5,30,9.6
35 | 34,265.6,20,0.3,17.4
36 | 35,95.7,1.4,7.4,9.5
37 | 36,290.7,4.1,8.5,12.8
38 | 37,266.9,43.8,5,25.4
39 | 38,74.7,49.4,45.7,14.7
40 | 39,43.1,26.7,35.1,10.1
41 | 40,228,37.7,32,21.5
42 | 41,202.5,22.3,31.6,16.6
43 | 42,177,33.4,38.7,17.1
44 | 43,293.6,27.7,1.8,20.7
45 | 44,206.9,8.4,26.4,12.9
46 | 45,25.1,25.7,43.3,8.5
47 | 46,175.1,22.5,31.5,14.9
48 | 47,89.7,9.9,35.7,10.6
49 | 48,239.9,41.5,18.5,23.2
50 | 49,227.2,15.8,49.9,14.8
51 | 50,66.9,11.7,36.8,9.7
52 | 51,199.8,3.1,34.6,11.4
53 | 52,100.4,9.6,3.6,10.7
54 | 53,216.4,41.7,39.6,22.6
55 | 54,182.6,46.2,58.7,21.2
56 | 55,262.7,28.8,15.9,20.2
57 | 56,198.9,49.4,60,23.7
58 | 57,7.3,28.1,41.4,5.5
59 | 58,136.2,19.2,16.6,13.2
60 | 59,210.8,49.6,37.7,23.8
61 | 60,210.7,29.5,9.3,18.4
62 | 61,53.5,2,21.4,8.1
63 | 62,261.3,42.7,54.7,24.2
64 | 63,239.3,15.5,27.3,15.7
65 | 64,102.7,29.6,8.4,14
66 | 65,131.1,42.8,28.9,18
67 | 66,69,9.3,0.9,9.3
68 | 67,31.5,24.6,2.2,9.5
69 | 68,139.3,14.5,10.2,13.4
70 | 69,237.4,27.5,11,18.9
71 | 70,216.8,43.9,27.2,22.3
72 | 71,199.1,30.6,38.7,18.3
73 | 72,109.8,14.3,31.7,12.4
74 | 73,26.8,33,19.3,8.8
75 | 74,129.4,5.7,31.3,11
76 | 75,213.4,24.6,13.1,17
77 | 76,16.9,43.7,89.4,8.7
78 | 77,27.5,1.6,20.7,6.9
79 | 78,120.5,28.5,14.2,14.2
80 | 79,5.4,29.9,9.4,5.3
81 | 80,116,7.7,23.1,11
82 | 81,76.4,26.7,22.3,11.8
83 | 82,239.8,4.1,36.9,12.3
84 | 83,75.3,20.3,32.5,11.3
85 | 84,68.4,44.5,35.6,13.6
86 | 85,213.5,43,33.8,21.7
87 | 86,193.2,18.4,65.7,15.2
88 | 87,76.3,27.5,16,12
89 | 88,110.7,40.6,63.2,16
90 | 89,88.3,25.5,73.4,12.9
91 | 90,109.8,47.8,51.4,16.7
92 | 91,134.3,4.9,9.3,11.2
93 | 92,28.6,1.5,33,7.3
94 | 93,217.7,33.5,59,19.4
95 | 94,250.9,36.5,72.3,22.2
96 | 95,107.4,14,10.9,11.5
97 | 96,163.3,31.6,52.9,16.9
98 | 97,197.6,3.5,5.9,11.7
99 | 98,184.9,21,22,15.5
100 | 99,289.7,42.3,51.2,25.4
101 | 100,135.2,41.7,45.9,17.2
102 | 101,222.4,4.3,49.8,11.7
103 | 102,296.4,36.3,100.9,23.8
104 | 103,280.2,10.1,21.4,14.8
105 | 104,187.9,17.2,17.9,14.7
106 | 105,238.2,34.3,5.3,20.7
107 | 106,137.9,46.4,59,19.2
108 | 107,25,11,29.7,7.2
109 | 108,90.4,0.3,23.2,8.7
110 | 109,13.1,0.4,25.6,5.3
111 | 110,255.4,26.9,5.5,19.8
112 | 111,225.8,8.2,56.5,13.4
113 | 112,241.7,38,23.2,21.8
114 | 113,175.7,15.4,2.4,14.1
115 | 114,209.6,20.6,10.7,15.9
116 | 115,78.2,46.8,34.5,14.6
117 | 116,75.1,35,52.7,12.6
118 | 117,139.2,14.3,25.6,12.2
119 | 118,76.4,0.8,14.8,9.4
120 | 119,125.7,36.9,79.2,15.9
121 | 120,19.4,16,22.3,6.6
122 | 121,141.3,26.8,46.2,15.5
123 | 122,18.8,21.7,50.4,7
124 | 123,224,2.4,15.6,11.6
125 | 124,123.1,34.6,12.4,15.2
126 | 125,229.5,32.3,74.2,19.7
127 | 126,87.2,11.8,25.9,10.6
128 | 127,7.8,38.9,50.6,6.6
129 | 128,80.2,0,9.2,8.8
130 | 129,220.3,49,3.2,24.7
131 | 130,59.6,12,43.1,9.7
132 | 131,0.7,39.6,8.7,1.6
133 | 132,265.2,2.9,43,12.7
134 | 133,8.4,27.2,2.1,5.7
135 | 134,219.8,33.5,45.1,19.6
136 | 135,36.9,38.6,65.6,10.8
137 | 136,48.3,47,8.5,11.6
138 | 137,25.6,39,9.3,9.5
139 | 138,273.7,28.9,59.7,20.8
140 | 139,43,25.9,20.5,9.6
141 | 140,184.9,43.9,1.7,20.7
142 | 141,73.4,17,12.9,10.9
143 | 142,193.7,35.4,75.6,19.2
144 | 143,220.5,33.2,37.9,20.1
145 | 144,104.6,5.7,34.4,10.4
146 | 145,96.2,14.8,38.9,11.4
147 | 146,140.3,1.9,9,10.3
148 | 147,240.1,7.3,8.7,13.2
149 | 148,243.2,49,44.3,25.4
150 | 149,38,40.3,11.9,10.9
151 | 150,44.7,25.8,20.6,10.1
152 | 151,280.7,13.9,37,16.1
153 | 152,121,8.4,48.7,11.6
154 | 153,197.6,23.3,14.2,16.6
155 | 154,171.3,39.7,37.7,19
156 | 155,187.8,21.1,9.5,15.6
157 | 156,4.1,11.6,5.7,3.2
158 | 157,93.9,43.5,50.5,15.3
159 | 158,149.8,1.3,24.3,10.1
160 | 159,11.7,36.9,45.2,7.3
161 | 160,131.7,18.4,34.6,12.9
162 | 161,172.5,18.1,30.7,14.4
163 | 162,85.7,35.8,49.3,13.3
164 | 163,188.4,18.1,25.6,14.9
165 | 164,163.5,36.8,7.4,18
166 | 165,117.2,14.7,5.4,11.9
167 | 166,234.5,3.4,84.8,11.9
168 | 167,17.9,37.6,21.6,8
169 | 168,206.8,5.2,19.4,12.2
170 | 169,215.4,23.6,57.6,17.1
171 | 170,284.3,10.6,6.4,15
172 | 171,50,11.6,18.4,8.4
173 | 172,164.5,20.9,47.4,14.5
174 | 173,19.6,20.1,17,7.6
175 | 174,168.4,7.1,12.8,11.7
176 | 175,222.4,3.4,13.1,11.5
177 | 176,276.9,48.9,41.8,27
178 | 177,248.4,30.2,20.3,20.2
179 | 178,170.2,7.8,35.2,11.7
180 | 179,276.7,2.3,23.7,11.8
181 | 180,165.6,10,17.6,12.6
182 | 181,156.6,2.6,8.3,10.5
183 | 182,218.5,5.4,27.4,12.2
184 | 183,56.2,5.7,29.7,8.7
185 | 184,287.6,43,71.8,26.2
186 | 185,253.8,21.3,30,17.6
187 | 186,205,45.1,19.6,22.6
188 | 187,139.5,2.1,26.6,10.3
189 | 188,191.1,28.7,18.2,17.3
190 | 189,286,13.9,3.7,15.9
191 | 190,18.7,12.1,23.4,6.7
192 | 191,39.5,41.1,5.8,10.8
193 | 192,75.5,10.8,6,9.9
194 | 193,17.2,4.1,31.6,5.9
195 | 194,166.8,42,3.6,19.6
196 | 195,149.7,35.6,6,17.3
197 | 196,38.2,3.7,13.8,7.6
198 | 197,94.2,4.9,8.1,9.7
199 | 198,177,9.3,6.4,12.8
200 | 199,283.6,42,66.2,25.5
201 | 200,232.1,8.6,8.7,13.4
202 |
--------------------------------------------------------------------------------
/Linear Model/data/Position_Salaries.csv:
--------------------------------------------------------------------------------
1 | Position,Level,Salary
2 | Business Analyst,1,45000
3 | Junior Consultant,2,50000
4 | Senior Consultant,3,60000
5 | Manager,4,80000
6 | Country Manager,5,110000
7 | Region Manager,6,150000
8 | Partner,7,200000
9 | Senior Partner,8,300000
10 | C-level,9,500000
11 | CEO,10,1000000
--------------------------------------------------------------------------------
/Linear Model/data/Salary_Data.csv:
--------------------------------------------------------------------------------
1 | YearsExperience,Salary
2 | 1.1,39343
3 | 1.3,46205
4 | 1.5,37731
5 | 2,43525
6 | 2.2,39891
7 | 2.9,56642
8 | 3,60150
9 | 3.2,54445
10 | 3.2,64445
11 | 3.7,57189
12 | 3.9,63218
13 | 4,55794
14 | 4,56957
15 | 4.1,57081
16 | 4.5,61111
17 | 4.9,67938
18 | 5.1,66029
19 | 5.3,83088
20 | 5.9,81363
21 | 6,93940
22 | 6.8,91738
23 | 7.1,98273
24 | 7.9,101302
25 | 8.2,113812
26 | 8.7,109431
27 | 9,105582
28 | 9.5,116969
29 | 9.6,112635
30 | 10.3,122391
31 | 10.5,121872
32 |
--------------------------------------------------------------------------------
/Logistic/05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Logistic/05.jpg
--------------------------------------------------------------------------------
/Logistic/1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Logistic/1.gif
--------------------------------------------------------------------------------
/Logistic/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Logistic/2.jpg
--------------------------------------------------------------------------------
/Logistic/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Logistic/3.png
--------------------------------------------------------------------------------
/Logistic/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Logistic/4.png
--------------------------------------------------------------------------------
/Metrics/1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/1.gif
--------------------------------------------------------------------------------
/Metrics/1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/1.jpeg
--------------------------------------------------------------------------------
/Metrics/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/1.jpg
--------------------------------------------------------------------------------
/Metrics/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/1.png
--------------------------------------------------------------------------------
/Metrics/12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/12.png
--------------------------------------------------------------------------------
/Metrics/13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/13.png
--------------------------------------------------------------------------------
/Metrics/14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/14.png
--------------------------------------------------------------------------------
/Metrics/15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/15.png
--------------------------------------------------------------------------------
/Metrics/16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/16.png
--------------------------------------------------------------------------------
/Metrics/17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/17.png
--------------------------------------------------------------------------------
/Metrics/2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/2.jpeg
--------------------------------------------------------------------------------
/Metrics/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/2.png
--------------------------------------------------------------------------------
/Metrics/3.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/3.jpeg
--------------------------------------------------------------------------------
/Metrics/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/3.png
--------------------------------------------------------------------------------
/Metrics/4.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/4.jpeg
--------------------------------------------------------------------------------
/Metrics/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/4.png
--------------------------------------------------------------------------------
/Metrics/5.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/5.jpeg
--------------------------------------------------------------------------------
/Metrics/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/5.png
--------------------------------------------------------------------------------
/Metrics/6.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/6.jpeg
--------------------------------------------------------------------------------
/Metrics/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/6.png
--------------------------------------------------------------------------------
/Metrics/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/7.png
--------------------------------------------------------------------------------
/Metrics/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/8.png
--------------------------------------------------------------------------------
/Metrics/Evaluation metric.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Metrics for Machine learning model\n",
8 | "\n",
9 | "- Evaluation is always good in any field right! In the case of machine learning, it is best the practice. In this post, I will almost cover all the popular as well as common metrics used for machine learning.\n",
10 | "\n",
11 | "- Different performance metrics are used to evaluate different Machine Learning Algorithms. For now, we will be focusing on the ones used for Classification problems.\n",
12 | "\n",
13 | "The Classification Metric Are:\n",
14 | " \n",
15 | " 1. Confusion Matrix\n",
16 | " 2. Accuracy\n",
17 | " 3. Precision\n",
18 | " 4. Recall\n",
19 | " 5. Specificity\n",
20 | " 6. F1-Score\n",
21 | " 7. Roc And Auc\n"
22 | ]
23 | },
24 | {
25 | "cell_type": "markdown",
26 | "metadata": {},
27 | "source": [
28 | "## 1. Confusion Matrix :\n",
29 | "\n",
30 | "- The Confusion matrix is one of the most intuitive and easiest metrics used for finding the correctness and accuracy of the model. It is only used for Classification problem where the output can be of two or more types of classes.\n",
31 | "\n",
32 | "There are 4 terms you should keep in mind:\n",
33 | "\n",
34 | " 1. True Positives (TP): It is the case where we predicted Yes and the real output was also yes.\n",
35 | " 2. True Negatives (TN): It is the case where we predicted No and the real output was also No.\n",
36 | " 3. False Positives (FP): It is the case where we predicted Yes but it was actually No.\n",
37 | " 4. False Negatives (FN): It is the case where we predicted No but it was actually Yes.\n",
38 | " \n",
39 | "Lets Take an example to know better this 4 term :\n",
40 | "\n",
41 | " Let’s give a label of to our target variable:\n",
42 | " \n",
43 | "1: When a person is having Corona\n",
44 | "\n",
45 | "0: When a person is NOT having Corona.\n",
46 | "\n",
47 | "Now lets apply this corona example in to this 4 term:\n",
48 | "\n",
49 | "1. True Positives (TP) :- Ex: The case where a person is actually having Corona(1) and the model also predict person haing Corona(1) Then it comes under True positive(TP).\n",
50 | "\n",
51 | "\n",
52 | "\n",
53 | "2. True Negatives (TN) :- Ex: The case where a person NOT having Corona(0) and the model also prdict person Not Having Corona(0) Then it comes under True Negatives(TN).\n",
54 | "\n",
55 | "\n",
56 | "\n",
57 | "3. False Positives (FP) :- Ex: A person NOT having Corona(0) But the model is predict Person haing Corona(1) Then It comes under False Positives (FP).\n",
58 | "\n",
59 | "\n",
60 | "\n",
61 | "4. False Negatives (FN) :- Ex: A person having Corona (1) But the model predict Person not Haing Corona (0) Then it comes under False Negatives(FN). \n",
62 | "\n",
63 | "SO in the above example you see these 4 type of term associate with Confusion Matrix.\n",
64 | "\n",
65 | "\n",
66 | "\n",
67 | "\n",
68 | "\n",
69 | "- we all want is that the model should give 0 False Positives and 0 False Negatives. \n",
70 | "- But that’s not the case in real life as any model will NOT be 100% accurate most of the times.\n",
71 | "- So we might want to minimise either False Positives or False negatives.\n"
72 | ]
73 | },
74 | {
75 | "cell_type": "markdown",
76 | "metadata": {},
77 | "source": [
78 | "## 2. Accuracy :\n",
79 | "\n",
80 | "- Accuracy in classification problems is the number of correct predictions made by the model over all kinds predictions made.\n",
81 | "\n",
82 | "\n",
83 | "\n",
84 | "\n",
85 | "\n",
86 | "\n",
87 | "\n",
88 | "* Accuracy is a good measure when the target variable classes in the data are nearly balanced.\n",
89 | "* Accuracy should NEVER be used as a measure when the target variable classes in the data are a majority of one class. (imbalanced dataset)"
90 | ]
91 | },
92 | {
93 | "cell_type": "markdown",
94 | "metadata": {},
95 | "source": [
96 | "## 3. Precision :\n",
97 | "\n",
98 | "\n",
99 | "\n",
100 | "\n",
101 | "- Precision is a measure that tells us what proportion of patients that we diagnosed as having Corona, actually had Corona. The predicted positives (Total People predicted as Corona are TP and FP) and the people actually having a Corona are TP.\n",
102 | "
\n",
103 | "- precision gives us information about its performance with respect to false positives(how many did we caught).\n",
104 | "- Precision is about being precise. So even if we managed to capture only one Corona case, and we captured it correctly, then we are 100% precise."
105 | ]
106 | },
107 | {
108 | "cell_type": "markdown",
109 | "metadata": {},
110 | "source": [
111 | "## 4. Recall or Sensitivity:\n",
112 | "\n",
113 | "\n",
114 | "\n",
115 | "\n",
116 | "\n",
117 | "- Recall is a measure that tells us what proportion of patients that actually had Corona was diagnosed by the algorithm as having Corona. The actual positives (People having Corona are TP and FN) and the people diagnosed by the model having a Corona are TP. (Note: FN is included because the Person actually had a Corona even though the model predicted otherwise).\n",
118 | "\n",
119 | "
\n",
120 | "\n",
121 | "- It is clear that recall gives us information about a classifier’s performance with respect to false negatives (how many did we miss).\n",
122 | "- Recall is not so much about capturing cases correctly but more about capturing all cases that have “Corona” with the answer as “Corona”. So if we simply always say every case as “Corona”, we have 100% recall."
123 | ]
124 | },
125 | {
126 | "cell_type": "markdown",
127 | "metadata": {},
128 | "source": [
129 | "## 5. Specificity :\n",
130 | "\n",
131 | "\n",
132 | "\n",
133 | "\n",
134 | "- Specificity is the exact opposite of Recall.\n",
135 | "- Specificity is a measure that tells us what proportion of patients that did NOT have Corona, were predicted by the model as not Corona . The actual negatives (People actually NOT having Corona are FP and TN) and the people diagnosed by us not having Corona are TN. (Note: FP is included because the Person did NOT actually have Corona even though the model predicted otherwie)."
136 | ]
137 | },
138 | {
139 | "cell_type": "markdown",
140 | "metadata": {},
141 | "source": [
142 | "-------------------------------------------------------------------------------------------------------------------------------"
143 | ]
144 | },
145 | {
146 | "cell_type": "markdown",
147 | "metadata": {},
148 | "source": [
149 | "## All 4 Metric :"
150 | ]
151 | },
152 | {
153 | "cell_type": "markdown",
154 | "metadata": {},
155 | "source": [
156 | "1. Accuracy 2. Precision 3. Recall or Sensitivity 4.Specificity \n",
157 | "\n",
158 | ""
159 | ]
160 | },
161 | {
162 | "cell_type": "markdown",
163 | "metadata": {},
164 | "source": [
165 | "### f1-score and Roc Auc i am explain in next notebook."
166 | ]
167 | }
168 | ],
169 | "metadata": {
170 | "kernelspec": {
171 | "display_name": "Python 3",
172 | "language": "python",
173 | "name": "python3"
174 | },
175 | "language_info": {
176 | "codemirror_mode": {
177 | "name": "ipython",
178 | "version": 3
179 | },
180 | "file_extension": ".py",
181 | "mimetype": "text/x-python",
182 | "name": "python",
183 | "nbconvert_exporter": "python",
184 | "pygments_lexer": "ipython3",
185 | "version": "3.7.6"
186 | }
187 | },
188 | "nbformat": 4,
189 | "nbformat_minor": 4
190 | }
191 |
--------------------------------------------------------------------------------
/Metrics/Regression_Mertic.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Regression Model Metric\n",
8 | "\n",
9 | "- In my Previous notebook i am focussed on classification metrics like precision, recall, AUC etc. \n",
10 | "- For a change, I wanted to explore all kinds of metrics including those used in regression as well. MAE and RMSE are the two most popular metrics for continuous variables. Let’s start with the more popular one.\n",
11 | "\n",
12 | "- All Types Of Metric Used In Regression\n",
13 | "\n",
14 | " 1. Mean Squared Error(MSE)\n",
15 | " 2. Root-Mean-Squared-Error(RMSE).\n",
16 | " 3. Mean-Absolute-Error(MAE).\n",
17 | " 4. Root Mean Squared Logarithmic Error (RMSLE).\n",
18 | " 5. R² or Coefficient of Determination.\n",
19 | " 6. Adjusted R²\n",
20 | " \n",
21 | "
\n",
22 | "\n",
23 | "#### 1. Mean Squared Error(MSE) :\n",
24 | "\n",
25 | "- MSE or Mean Squared Error is one of the most preferred metrics for regression tasks.\n",
26 | "- It is simply the average of the squared difference between the target value and the value predicted by the regression model. \n",
27 | "- As it squares the differences, it penalizes even a small error which leads to over-estimation of how bad the model is. It is preferred more than other metrics because it is differentiable and hence can be optimized better.\n",
28 | "\n",
29 | "\n",
30 | "\n",
31 | "
\n",
32 | "\n",
33 | "#### 2. Root Mean Squared Error (RMSE) :\n",
34 | "\n",
35 | "- It is simple root of MSE.\n",
36 | "- RMSE is the most widely used metric for regression tasks and is the square root of the averaged squared difference between the target value and the value predicted by the model. \n",
37 | "- It is preferred more in some cases because the errors are first squared before averaging which poses a high penalty on large errors. This implies that RMSE is useful when large errors are undesired.\n",
38 | "\n",
39 | "\n",
40 | "\n",
41 | "
\n",
42 | "\n",
43 | "#### 3. Mean-Absolute-Error(MAE) :\n",
44 | "\n",
45 | "- MAE is the absolute difference between the target value and the value predicted by the model.\n",
46 | "- The MAE is more robust to outliers and does not penalize the errors as extremely as mse. MAE is a linear score which means all the individual differences are weighted equally. It is not suitable for applications where you want to pay more attention to the outliers.\n",
47 | "\n",
48 | "\n",
49 | "\n",
50 | "
\n",
51 | "\n",
52 | "#### 4. Root Mean Squared Logarithmic Error (RMSLE) :\n",
53 | "\n",
54 | "- In case of Root mean squared logarithmic error, we take the log of the predictions and actual values. So basically, what changes are the variance that we are measuring. \n",
55 | "- RMSLE is usually used when we don’t want to penalize huge differences in the predicted and the actual values when both predicted and true values are huge numbers.\n",
56 | "\n",
57 | "\n",
58 | "\n",
59 | "\n",
60 | "
\n",
61 | "\n",
62 | "##### All Four Metric\n",
63 | "\n",
64 | ""
65 | ]
66 | },
67 | {
68 | "cell_type": "markdown",
69 | "metadata": {},
70 | "source": [
71 | "#### 5. R² or Coefficient of Determination: \n",
72 | "\n",
73 | "- Coefficient of Determination or R² is another metric used for evaluating the performance of a regression model.\n",
74 | "- The metric helps us to compare our current model with a constant baseline and tells us how much our model is better.\n",
75 | "- The constant baseline is chosen by taking the mean of the data and drawing a line at the mean. R² is a scale-free score that implies it doesn't matter whether the values are too large or too small, the R² will always be less than or equal to 1.\n",
76 | "\n",
77 | "\n",
78 | "\n",
79 | "
\n",
80 | "\n",
81 | "#### 6. Adjusted R²:\n",
82 | "\n",
83 | "- it is suitable for multiple linear regrssion where more than one independent variable.\n",
84 | "- Adjusted R² depicts the same meaning as R² but is an improvement of it. \n",
85 | "- R² suffers from the problem that the scores improve on increasing terms even though the model is not improving which may misguide the researcher.\n",
86 | "- Adjusted R² is always lower than R² as it adjusts for the increasing predictors and only shows improvement if there is a real improvement.\n",
87 | "\n",
88 | "\n",
89 | "\n",
90 | "
\n",
91 | "\n",
92 | "### Q. Why is R² Negative ?\n",
93 | "\n",
94 | "- There is a misconception among people that R² score ranges from 0 to 1 but actually it ranges from -∞ to 1. Due to this misconception, they are sometimes scared why the R² is negative which is not a possibility according to them.\n",
95 | "\n",
96 | "The main reasons for R² to be negative are the following:\n",
97 | "\n",
98 | "* R² compares the fit of the chosen model with that of a horizontal straight line (the null hypothesis). If the chosen model fits worse than a horizontal line, then R² is negative. \n",
99 | "* Note that R² is not always the square of anything, so it can have a negative value without violating any rules of math.\n",
100 | "* Mainly R² is negative only when the chosen model does not follow the trend of the data, so fits worse than a horizontal line.\n",
101 | "* Maybe their area a large number of outliers in the data that causes the mse of the model to be more than mse of the baseline causing the R² to be negative(i.e the numerator is greater than the denominator)."
102 | ]
103 | },
104 | {
105 | "cell_type": "markdown",
106 | "metadata": {},
107 | "source": [
108 | "In this Notebook, i discovered about the various metrics used in regression analysis and also tried to answer the question of why R² is negative?"
109 | ]
110 | }
111 | ],
112 | "metadata": {
113 | "kernelspec": {
114 | "display_name": "Python 3",
115 | "language": "python",
116 | "name": "python3"
117 | },
118 | "language_info": {
119 | "codemirror_mode": {
120 | "name": "ipython",
121 | "version": 3
122 | },
123 | "file_extension": ".py",
124 | "mimetype": "text/x-python",
125 | "name": "python",
126 | "nbconvert_exporter": "python",
127 | "pygments_lexer": "ipython3",
128 | "version": "3.7.6"
129 | }
130 | },
131 | "nbformat": 4,
132 | "nbformat_minor": 4
133 | }
134 |
--------------------------------------------------------------------------------
/Metrics/all-in-one.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/all-in-one.jpg
--------------------------------------------------------------------------------
/Metrics/metric.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Metrics/metric.jpg
--------------------------------------------------------------------------------
/Naive Bayes/03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Naive Bayes/03.jpg
--------------------------------------------------------------------------------
/Naive Bayes/1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Naive Bayes/1.jpeg
--------------------------------------------------------------------------------
/Naive Bayes/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Naive Bayes/2.jpg
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Machine Learning Projects
2 |   
3 |
4 | 
5 |
6 | ## Why this repository?
7 | • The main purpose of making this repository is to keep all my Machine Learning notes at one place, hence keeping my GitHub clean!
8 | • It looks good, isn't it?
9 |
10 | ## Algorithms
11 |
12 | ### Supervised:
13 | **Regression:**
14 | • _Linear Regression_
15 | • _Multiple-Linear Regression_
16 | • _Polynomial Regression_
17 | • _Lasso and Ridge Regression (L1 & L2 Regularization)_
18 | • _Elastic-Net Regression_
19 |
20 | **Classification:**
21 | • _Logistic Regression_
22 | • _K-Nearest Neighbours_
23 | • _Support Vector Machine_
24 | • _Naive Bayes_
25 | • _Decision Tree_
26 |
27 | **Ensemble:**
28 | • _Random Forest_
29 | • _Adaptive Boosting (AdaBoost)_
30 | • _Extreme Gradient Boosting (XGBoost)_
31 |
32 | ### Unsupervised:
33 | **Clustering:**
34 | • _K-Means_
35 | • _Hierarchical_clustering_
36 | • _ DBSCAN_
37 |
38 | ### NLP:
39 | ### Deep_Learning:
40 | ### Time_series:
41 |
42 |
--------------------------------------------------------------------------------
/Random_forest/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/Random_forest/1.png
--------------------------------------------------------------------------------
/SVM/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/SVM/01.png
--------------------------------------------------------------------------------
/SVM/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/SVM/02.png
--------------------------------------------------------------------------------
/SVM/03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/SVM/03.png
--------------------------------------------------------------------------------
/SVM/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/SVM/4.png
--------------------------------------------------------------------------------
/SVM/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/SVM/5.png
--------------------------------------------------------------------------------
/SVM/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/SVM/6.png
--------------------------------------------------------------------------------
/SVM/7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/SVM/7.jpg
--------------------------------------------------------------------------------
/SVM/8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/SVM/8.jpg
--------------------------------------------------------------------------------
/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pratyusa98/ML_Algo_pdf/e0a46e68c8439911b2da69c0325941a1d4bca941/img/1.png
--------------------------------------------------------------------------------