├── AmazonFineFoodReviews(CaseStudy) ├── Amazon Fine Food Reviews Analysis CourseContent.ipynb ├── Amazon Fine Food Reviews Analysis.ipynb ├── AmazonFineFoodReview_Assignment.ipynb ├── AmazonFineFoodReview_Assignment.pdf ├── AmazonFineFoodReview_TSNE_Assignment.ipynb ├── AmazonFineFoodReviews.ipynb ├── AmazonFineFoodReviews_DT.ipynb ├── AmazonFineFoodReviews_DT.pdf ├── AmazonFineFoodReviews_SVC_Assignment.ipynb ├── AmazonFineFoodReviews_SVC_Assignment.pdf ├── AmazonReviewsClassificationLogisticRegression.ipynb ├── AmazonReviewsClassificationLogisticRegression.pdf ├── AmazonReviewsClassificationNaiveBayes-(2 unnecessary Techniques included W2v and TfidfW2v they are not applicable as features are dependent in these).ipynb ├── AmazonReviewsClassificationNaiveBayes.ipynb ├── AmazonReviewsClassificationNaiveBayes.pdf ├── AmazonReviews_KNN_Assignment-Copy1.ipynb ├── AmazonReviews_KNN_Assignment.ipynb ├── AmazonReviews_KNN_Assignment.pdf ├── AmazonReviews_RF_GBDT.ipynb ├── AmazonReviews_RF_GBDT.pdf ├── TimeSeriesSplitPractice.ipynb ├── WiightedTfidfW2V.pickle ├── hashes.txt └── images │ ├── reviews1.PNG │ ├── reviews2.PNG │ ├── reviews3.PNG │ └── reviews4.PNG ├── AnonymousOrLambdaFunctions_Py.ipynb ├── Basics_Py.ipynb ├── ControlFlow_Py.ipynb ├── ConvertingIpynbToPdf └── ReadMe.txt ├── CovarianceOrCoRelationMatrixVisualization ├── Covariance_Visualization_IrisDataSet.ipynb └── iris.csv ├── Debug_pdb_Py.ipynb ├── Dictionary_Py.ipynb ├── DimensionalityReduction(PCA,t-SNE) ├── 13.10#14.9#14.10#15.7.ipynb ├── DimensionalityReduction.ipynb ├── MNIST_DATA_SET_784_Dimensions.ipynb ├── PCA │ ├── PCA.ipynb │ └── images │ │ ├── pca.PNG │ │ └── pca1.PNG ├── images │ ├── DataPreprocessing.PNG │ ├── coVariance.PNG │ ├── coVariance1.PNG │ ├── coVariance3.PNG │ ├── colNormalization.PNG │ ├── colNormalization1.PNG │ ├── colNormalization2.PNG │ ├── colNormalization3.PNG │ ├── datamatrix.PNG │ ├── datamatrix2.PNG │ ├── mean.PNG │ ├── mean2.PNG │ ├── mnist.PNG │ ├── mnist2.PNG │ ├── mnist3.PNG │ ├── stdzation.PNG │ ├── stdzation2.PNG │ ├── stdzation3.PNG │ ├── stdzation4.PNG │ └── stdzation5.PNG └── tSNE │ ├── 13.10#14.9#14.10#15.7.ipynb │ ├── images │ ├── tsne1.PNG │ ├── tsne2.PNG │ ├── tsne3.PNG │ ├── tsne4.PNG │ └── tsne5.PNG │ └── t-SNE(on_MNIST).ipynb ├── EDA_LinearAlgebra_CreditCardFraudDetectionExercise ├── 50KDataPointsTsne.pickle ├── EDA_CerditCradFraud_Task1.ipynb ├── EDA_CerditCradFraud_Task1.pdf ├── TransactionSimilarityTask2.ipynb ├── TransactionSimilarityTask2.pdf ├── Tsne(CreditCardFraudDetection).ipynb ├── Tsne(CreditCardFraudDetection).pdf └── Untitled.ipynb ├── ExploratoryDataAnalysis(EDA) ├── Box-Plot with Whiskers and Violin Plots.ipynb ├── CDF(Cumulative Distribution Function) EDA.ipynb ├── Exercise │ ├── Haberman'sSurvivalExercise.ipynb │ ├── Haberman'sSurvivalExercise.pdf │ ├── Haberman'sSurvivalExercise_files │ │ ├── Haberman'sSurvivalExercise_12_0.png │ │ ├── Haberman'sSurvivalExercise_14_0.png │ │ ├── Haberman'sSurvivalExercise_17_0.png │ │ ├── Haberman'sSurvivalExercise_21_0.png │ │ ├── Haberman'sSurvivalExercise_23_0.png │ │ ├── Haberman'sSurvivalExercise_24_0.png │ │ ├── Haberman'sSurvivalExercise_31_0.png │ │ ├── Haberman'sSurvivalExercise_32_0.png │ │ ├── Haberman'sSurvivalExercise_33_0.png │ │ ├── Haberman'sSurvivalExercise_35_0.png │ │ ├── Haberman'sSurvivalExercise_37_0.png │ │ ├── Haberman'sSurvivalExercise_38_0.png │ │ └── Haberman'sSurvivalExercise_40_0.png │ └── haberman.csv ├── Exploratory Data Analysis..ipynb ├── HistogramsAndPDF.ipynb ├── Intro to IRIS dataset and 2d Scatter Plot.ipynb ├── MeanMedianStdPercentileQuantile.ipynb ├── Multivariant probability Density(MPD), Contour Plot.ipynb ├── Summary of EDA.ipynb └── iris.csv ├── Functions_Py.ipynb ├── Input_Output_Py.ipynb ├── KNN(K-NearestNeighbour)_Classification_n_Regression ├── Course_Content │ ├── kfold.ipynb │ └── knn.ipynb ├── KNN_Basics.ipynb ├── KNN_CrossValidation_and_K-Fold_CV.ipynb ├── KNN_code.ipynb ├── LSH(Locality_Sensitive_Hashing).ipynb ├── demo_data │ ├── 1.ushape.csv │ ├── 2.concerticcir1.csv │ ├── 3.concertriccir2.csv │ ├── 4.linearsep.csv │ ├── 5.outlier.csv │ ├── 6.overlap.csv │ ├── 7.xor.csv │ ├── 8.twospirals.csv │ ├── 9.random.csv │ └── meshgrid_image.png └── images │ ├── knn1.PNG │ ├── knn2.PNG │ ├── knn3.PNG │ ├── knn4.PNG │ └── knn5.PNG ├── LinearRegression ├── LinearRegression_HousePricePrediction.ipynb └── SGD_LinearRegressionAssignment(Implementing_our_ownLR) │ ├── SGD_LinearRegression_HousePrice_Assignment.ipynb │ ├── SGD_on_LinearRegression.ipynb │ └── SGD_on_LinearRegression.pdf ├── Lists_Py.ipynb ├── Lists_Sets_Tuples_Dict_Py.ipynb ├── LogisticRegression ├── CodeSample.ipynb ├── CourseFileLogisticRegression.ipynb ├── LogisticRegression.ipynb ├── NBayesLogReg.pdf └── Untitled.ipynb ├── Matplotlib.ipynb ├── Modules_Py.ipynb ├── NaiveBayes └── NaiveBayes.ipynb ├── NamedEntityRecognitionNLTK_DialogFLow ├── .ipynb_checkpoints │ └── NLP_NER_CUSTOM_MODEL-checkpoint.ipynb ├── NLP_NER_CUSTOM_MODEL.ipynb ├── custom_ent.tsv ├── dummy-ner-model-custom.ser.gz ├── english.all.3class.distsim.crf.ser.gz ├── prop.txt └── stanford-ner.jar ├── NumPy_Py.ipynb ├── NumericalOperationsNumPy_Py.ipynb ├── Operators.ipynb ├── OutOfCoursePractice ├── BSE.csv ├── NiftyPrediction.ipynb ├── SharePrediction3Months.csv ├── SharePrediction3Months.xlsx ├── SharesPrediction.xlsx ├── SharesPredictionConv.csv ├── Tinplate_prediction │ ├── TINP Historical Data.csv │ ├── TINPLATE.BO.csv │ ├── TINPLATE.NS.csv │ ├── TINPLATE_6thMay.BO.csv │ ├── TINPLATE_6thMay_prev_close.BO.csv │ ├── Tinp_NSE_Prediction_KNN.ipynb │ ├── Tinplate_prediction.ipynb │ └── Untitled1.ipynb ├── Untitled.ipynb └── oneMonthData.csv ├── Pandas_DataFrames ├── Operations_In_DataFrames.ipynb ├── Pandas_Intro.ipynb ├── WritingWeatherToCsv.csv ├── WritingWeatherToExcel.xls ├── nyc_weather.csv ├── weather_data.csv ├── weather_data.xlsx └── weather_data_cities.csv ├── Practice_py.ipynb ├── ProbabilityAndStatistics ├── Box-Cox_or_(Powerlaw to Gaussian transform).ipynb ├── Box-Cox_or_(Powerlaw to Gaussian transform)_3.ipynb ├── Capture.PNG ├── ConfidenceInterval.ipynb ├── ConfidenceIntervalUsingBootstrapping_5.ipynb ├── ConfidenceInterval_4.ipynb ├── Correlation(Covariance,Pearsons,Spearmans Corr Coeff).ipynb ├── Correlation(Covariance,Pearsons,Spearmans Corr Coeff)_8.ipynb ├── HypothesisTesting,NullHypothesis_6.ipynb ├── HypothesisTesting_9.ipynb ├── KS-Test_7.ipynb ├── Q-Q Plot.ipynb ├── Q-Q Plot_1.ipynb ├── Rand Num Generator(Uniform Distribution).ipynb ├── Rand Num Generator(Uniform Distribution)_2.ipynb ├── hypothesistest1.PNG ├── hypothesistest2.PNG ├── hypothesistest3.PNG ├── hypothesistest4.PNG ├── hypothesistest5.PNG ├── hypothesistest6.PNG ├── hypothesistest7.PNG ├── hypothesistest8.PNG └── kstest1.PNG ├── README.md ├── Sets_Py.ipynb ├── SpaceAndTimeComplexity └── TimeNspaceComplexity.ipynb ├── Strings_Py.ipynb ├── Tuple_Py.ipynb ├── ViewingSourceCodeAndDocumentation.ipynb └── populations.txt /AmazonFineFoodReviews(CaseStudy)/AmazonFineFoodReview_Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/AmazonFineFoodReview_Assignment.pdf -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/AmazonFineFoodReviews_DT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/AmazonFineFoodReviews_DT.pdf -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/AmazonFineFoodReviews_SVC_Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/AmazonFineFoodReviews_SVC_Assignment.pdf -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/AmazonReviewsClassificationLogisticRegression.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/AmazonReviewsClassificationLogisticRegression.pdf -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/AmazonReviewsClassificationNaiveBayes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/AmazonReviewsClassificationNaiveBayes.pdf -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/AmazonReviews_KNN_Assignment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/AmazonReviews_KNN_Assignment.pdf -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/AmazonReviews_RF_GBDT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/AmazonReviews_RF_GBDT.pdf -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/TimeSeriesSplitPractice.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "TimeSeriesSplit(max_train_size=None, n_splits=3)\n", 13 | "TRAIN: [0] TEST: [1]\n", 14 | "TRAIN: [0 1] TEST: [2]\n", 15 | "TRAIN: [0 1 2] TEST: [3]\n" 16 | ] 17 | } 18 | ], 19 | "source": [ 20 | "from sklearn.model_selection import TimeSeriesSplit\n", 21 | "import numpy as np\n" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 12, 27 | "metadata": {}, 28 | "outputs": [ 29 | { 30 | "name": "stdout", 31 | "output_type": "stream", 32 | "text": [ 33 | "TimeSeriesSplit(max_train_size=None, n_splits=2)\n" 34 | ] 35 | } 36 | ], 37 | "source": [ 38 | "X = np.array([[1, 2], [3, 4], [1, 2], [3, 4]])\n", 39 | "y = np.array([1, 2, 3, 4])\n", 40 | "tscv = TimeSeriesSplit(n_splits=2)\n", 41 | "print(tscv) \n", 42 | "\n" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 13, 48 | "metadata": {}, 49 | "outputs": [ 50 | { 51 | "name": "stdout", 52 | "output_type": "stream", 53 | "text": [ 54 | "TRAIN: [0 1] TEST: [2]\n", 55 | "X_train : [[1 2]\n", 56 | " [3 4]]\n", 57 | "TRAIN: [0 1 2] TEST: [3]\n", 58 | "X_train : [[1 2]\n", 59 | " [3 4]\n", 60 | " [1 2]]\n" 61 | ] 62 | } 63 | ], 64 | "source": [ 65 | "for train_index, test_index in tscv.split(X):\n", 66 | " print(\"TRAIN:\", train_index, \"TEST:\", test_index)\n", 67 | " \n", 68 | " X_train, X_test = X[train_index], X[test_index]\n", 69 | " y_train, y_test = y[train_index], y[test_index]\n", 70 | " print(\"X_train : \",X_train)" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": 14, 76 | "metadata": {}, 77 | "outputs": [ 78 | { 79 | "data": { 80 | "text/plain": [ 81 | "array([[1, 2],\n", 82 | " [3, 4],\n", 83 | " [1, 2]])" 84 | ] 85 | }, 86 | "execution_count": 14, 87 | "metadata": {}, 88 | "output_type": "execute_result" 89 | } 90 | ], 91 | "source": [ 92 | "X_train" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": 15, 98 | "metadata": {}, 99 | "outputs": [ 100 | { 101 | "data": { 102 | "text/plain": [ 103 | "array([[3, 4]])" 104 | ] 105 | }, 106 | "execution_count": 15, 107 | "metadata": {}, 108 | "output_type": "execute_result" 109 | } 110 | ], 111 | "source": [ 112 | "X_test" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": 16, 118 | "metadata": {}, 119 | "outputs": [ 120 | { 121 | "data": { 122 | "text/plain": [ 123 | "array([1, 2, 3])" 124 | ] 125 | }, 126 | "execution_count": 16, 127 | "metadata": {}, 128 | "output_type": "execute_result" 129 | } 130 | ], 131 | "source": [ 132 | "y_train" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": 17, 138 | "metadata": {}, 139 | "outputs": [ 140 | { 141 | "data": { 142 | "text/plain": [ 143 | "array([4])" 144 | ] 145 | }, 146 | "execution_count": 17, 147 | "metadata": {}, 148 | "output_type": "execute_result" 149 | } 150 | ], 151 | "source": [ 152 | "y_test" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": 20, 158 | "metadata": {}, 159 | "outputs": [ 160 | { 161 | "data": { 162 | "text/plain": [ 163 | "2.5" 164 | ] 165 | }, 166 | "execution_count": 20, 167 | "metadata": {}, 168 | "output_type": "execute_result" 169 | } 170 | ], 171 | "source": [ 172 | "li = [1,2,3,4]\n", 173 | "sum(li)/len(li)" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "metadata": {}, 180 | "outputs": [], 181 | "source": [] 182 | } 183 | ], 184 | "metadata": { 185 | "kernelspec": { 186 | "display_name": "Python 3", 187 | "language": "python", 188 | "name": "python3" 189 | }, 190 | "language_info": { 191 | "codemirror_mode": { 192 | "name": "ipython", 193 | "version": 3 194 | }, 195 | "file_extension": ".py", 196 | "mimetype": "text/x-python", 197 | "name": "python", 198 | "nbconvert_exporter": "python", 199 | "pygments_lexer": "ipython3", 200 | "version": "3.6.4" 201 | } 202 | }, 203 | "nbformat": 4, 204 | "nbformat_minor": 2 205 | } 206 | -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/WiightedTfidfW2V.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/WiightedTfidfW2V.pickle -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/hashes.txt: -------------------------------------------------------------------------------- 1 | Current git commit: 2 | 18824c4d0fea769ebb0301182d550130e4a08560 3 | 4 | Current input/ouput md5 hashes: 5 | MD5 (output/Reviews.csv) = c3c950ae0be8b0736477c89d052d33fd 6 | MD5 (output/database.sqlite) = a50334684f230502a9ce984cb749514f 7 | MD5 (input/Reviews.txt) = 20b122f0d990184a445b84b73aeee074 8 | -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/images/reviews1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/images/reviews1.PNG -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/images/reviews2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/images/reviews2.PNG -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/images/reviews3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/images/reviews3.PNG -------------------------------------------------------------------------------- /AmazonFineFoodReviews(CaseStudy)/images/reviews4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/AmazonFineFoodReviews(CaseStudy)/images/reviews4.PNG -------------------------------------------------------------------------------- /AnonymousOrLambdaFunctions_Py.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Anonymous / Lambda Functions" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stdout", 17 | "output_type": "stream", 18 | "text": [ 19 | "4\n" 20 | ] 21 | } 22 | ], 23 | "source": [ 24 | "sq = lambda x:x**2;\n", 25 | "\n", 26 | "print(sq(2));" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "name": "stdout", 36 | "output_type": "stream", 37 | "text": [ 38 | "3\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "add= lambda x,y:x+y;\n", 44 | "\n", 45 | "print(add(2,1));" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "Example: Even nums" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 5, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "name": "stdout", 62 | "output_type": "stream", 63 | "text": [ 64 | "[2, 4]\n" 65 | ] 66 | } 67 | ], 68 | "source": [ 69 | "lst=[1,2,3,4,5];\n", 70 | "\n", 71 | "evenList = list(filter(lambda x: (x%2==0),lst));\n", 72 | "\n", 73 | "print(evenList);" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "example: squares using map()" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": 6, 86 | "metadata": {}, 87 | "outputs": [ 88 | { 89 | "name": "stdout", 90 | "output_type": "stream", 91 | "text": [ 92 | "[1, 4, 9, 16, 25]\n" 93 | ] 94 | } 95 | ], 96 | "source": [ 97 | "lst=[1,2,3,4,5];\n", 98 | "\n", 99 | "sq = list(map(lambda x: x**2,lst));\n", 100 | "\n", 101 | "print(sq);" 102 | ] 103 | }, 104 | { 105 | "cell_type": "markdown", 106 | "metadata": {}, 107 | "source": [ 108 | "example: Prod of nums using reduce()" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 14, 114 | "metadata": {}, 115 | "outputs": [ 116 | { 117 | "name": "stdout", 118 | "output_type": "stream", 119 | "text": [ 120 | "120\n" 121 | ] 122 | } 123 | ], 124 | "source": [ 125 | "from functools import reduce\n", 126 | "\n", 127 | "lst=[1,2,3,4,5];\n", 128 | "\n", 129 | "prod = reduce(lambda x, y: x*y,lst);\n", 130 | "\n", 131 | "print(prod);" 132 | ] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": null, 137 | "metadata": { 138 | "collapsed": true 139 | }, 140 | "outputs": [], 141 | "source": [] 142 | } 143 | ], 144 | "metadata": { 145 | "kernelspec": { 146 | "display_name": "Python 3", 147 | "language": "python", 148 | "name": "python3" 149 | }, 150 | "language_info": { 151 | "codemirror_mode": { 152 | "name": "ipython", 153 | "version": 3 154 | }, 155 | "file_extension": ".py", 156 | "mimetype": "text/x-python", 157 | "name": "python", 158 | "nbconvert_exporter": "python", 159 | "pygments_lexer": "ipython3", 160 | "version": "3.6.4" 161 | } 162 | }, 163 | "nbformat": 4, 164 | "nbformat_minor": 2 165 | } 166 | -------------------------------------------------------------------------------- /Basics_Py.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Python Keywords" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 7, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stdout", 17 | "output_type": "stream", 18 | "text": [ 19 | "['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']\n", 20 | "\n", 21 | "Total no.of keywords: 33\n" 22 | ] 23 | } 24 | ], 25 | "source": [ 26 | "#get all keywords in py\n", 27 | "\n", 28 | "import keyword\n", 29 | "\n", 30 | "print(keyword.kwlist)\n", 31 | "\n", 32 | "print(\"\\nTotal no.of keywords: \",len(keyword.kwlist))" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "# Comments in Py" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 30, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "# Single line cmt" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "metadata": {}, 54 | "source": [ 55 | "# Multi-line Statement" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": 14, 61 | "metadata": {}, 62 | "outputs": [ 63 | { 64 | "name": "stdout", 65 | "output_type": "stream", 66 | "text": [ 67 | "21\n", 68 | "10\n" 69 | ] 70 | } 71 | ], 72 | "source": [ 73 | "# '\\' slash is used to represent end of line i.e new line char.\n", 74 | "a=1+2+3+ \\\n", 75 | " 4+5+\\\n", 76 | " 6;\n", 77 | "\n", 78 | "#or\n", 79 | "\n", 80 | "b=(1+2\n", 81 | " +3+4);\n", 82 | "\n", 83 | "print(a)\n", 84 | "print(b)" 85 | ] 86 | }, 87 | { 88 | "cell_type": "markdown", 89 | "metadata": {}, 90 | "source": [ 91 | "# Varialbes\n", 92 | "### Multiple Assignments" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": 16, 98 | "metadata": {}, 99 | "outputs": [ 100 | { 101 | "name": "stdout", 102 | "output_type": "stream", 103 | "text": [ 104 | "20 2.2 AI\n" 105 | ] 106 | } 107 | ], 108 | "source": [ 109 | "a, b, c=20,2.2,\"AI\";\n", 110 | "\n", 111 | "print(a,b,c)" 112 | ] 113 | }, 114 | { 115 | "cell_type": "markdown", 116 | "metadata": {}, 117 | "source": [ 118 | "# Storage Locations" 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": 21, 124 | "metadata": {}, 125 | "outputs": [ 126 | { 127 | "name": "stdout", 128 | "output_type": "stream", 129 | "text": [ 130 | "address of x: 1772974048\n", 131 | "address of y: 1772974048\n", 132 | "address of y: 1772973664\n" 133 | ] 134 | } 135 | ], 136 | "source": [ 137 | "x = 123; \n", 138 | "y = 123;\n", 139 | "\n", 140 | "#id's or address of x,y vars\n", 141 | "print(\"address of x: \",id(x))\n", 142 | "\n", 143 | "print(\"address of y: \",id(y))\n", 144 | "\n", 145 | "y = 111;\n", 146 | "print(\"address of y: \",id(y))" 147 | ] 148 | }, 149 | { 150 | "cell_type": "markdown", 151 | "metadata": {}, 152 | "source": [ 153 | "Observation: Here x,y points to same address i.e it is reusing the memory location, memory location is created based on the value assigned, in java seperate Memory location is created for every variable.\n", 154 | "\n", 155 | "if value is changed address also will be changed, as we have changed 'y' value the memory location of 'y' is also changed" 156 | ] 157 | }, 158 | { 159 | "cell_type": "markdown", 160 | "metadata": {}, 161 | "source": [ 162 | "# Data Types\n", 163 | "### Every thing in python is 'Object' like wrapper classes in Java" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 28, 169 | "metadata": {}, 170 | "outputs": [ 171 | { 172 | "name": "stdout", 173 | "output_type": "stream", 174 | "text": [ 175 | "5 its of type: \n", 176 | "222.2 its of type: \n", 177 | "Hello its of type: \n", 178 | "2.2222222222222223 its of type: \n", 179 | "(1+2j) its of type: \n", 180 | "True its of type: \n" 181 | ] 182 | } 183 | ], 184 | "source": [ 185 | "a = 5;\n", 186 | "\n", 187 | "print(a, \" its of type: \",type(a));\n", 188 | "\n", 189 | "a = 222.2;\n", 190 | "\n", 191 | "print(a, \" its of type: \",type(a));\n", 192 | "\n", 193 | "a = \"Hello\";\n", 194 | "\n", 195 | "print(a, \" its of type: \",type(a));\n", 196 | "\n", 197 | "a = 2.2222222222222222222;\n", 198 | "\n", 199 | "print(a, \" its of type: \",type(a));\n", 200 | "\n", 201 | "\n", 202 | "# Python also supports Complex Numbers\n", 203 | "a = 1+2j;\n", 204 | "\n", 205 | "print(a, \" its of type: \",type(a));\n", 206 | "\n", 207 | "a = True;\n", 208 | "\n", 209 | "print(a, \" its of type: \",type(a));\n", 210 | "\n" 211 | ] 212 | }, 213 | { 214 | "cell_type": "markdown", 215 | "metadata": {}, 216 | "source": [ 217 | "# Strings" 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "execution_count": 38, 223 | "metadata": {}, 224 | "outputs": [ 225 | { 226 | "name": "stdout", 227 | "output_type": "stream", 228 | "text": [ 229 | "hi\n", 230 | "hi\n", 231 | "\n", 232 | "\n", 233 | "Multi \n", 234 | "line\n", 235 | "String\n", 236 | "\n", 237 | "\n", 238 | "\n", 239 | "\n", 240 | "hi\n", 241 | "\n", 242 | "\n" 243 | ] 244 | } 245 | ], 246 | "source": [ 247 | "a='hi';\n", 248 | "print(a);\n", 249 | "\n", 250 | "a=\"hi\";\n", 251 | "print(a);\n", 252 | "\n", 253 | "a=\"\"\"\n", 254 | "\n", 255 | "Multi \n", 256 | "line\n", 257 | "String\n", 258 | "\n", 259 | "\"\"\"\n", 260 | "print(a);\n", 261 | "\n", 262 | "#or\n", 263 | "\n", 264 | "a='''\n", 265 | "\n", 266 | "hi\n", 267 | "\n", 268 | "'''\n", 269 | "print(a);" 270 | ] 271 | }, 272 | { 273 | "cell_type": "code", 274 | "execution_count": 51, 275 | "metadata": {}, 276 | "outputs": [ 277 | { 278 | "name": "stdout", 279 | "output_type": "stream", 280 | "text": [ 281 | "H\n", 282 | "Length of str is: 19\n" 283 | ] 284 | } 285 | ], 286 | "source": [ 287 | "a=\"HI I am Learning ML\"\n", 288 | "print(a[0]);\n", 289 | "\n", 290 | "print(\"Length of str is: \",len(a))" 291 | ] 292 | }, 293 | { 294 | "cell_type": "markdown", 295 | "metadata": {}, 296 | "source": [ 297 | "# Slicing in Strings" 298 | ] 299 | }, 300 | { 301 | "cell_type": "code", 302 | "execution_count": 57, 303 | "metadata": {}, 304 | "outputs": [ 305 | { 306 | "name": "stdout", 307 | "output_type": "stream", 308 | "text": [ 309 | "Learning ML\n", 310 | "HI\n", 311 | "L\n", 312 | "HI I am Learning ML\n", 313 | "HI\n" 314 | ] 315 | } 316 | ], 317 | "source": [ 318 | "#index starts at 0\n", 319 | "\n", 320 | "print(a[8:]) #prints from 8th char to end\n", 321 | "\n", 322 | "print(a[:2]) #prints till 2nd char\n", 323 | "\n", 324 | "print(a[-1]) #prints last Char\n", 325 | "\n", 326 | "print(a[:]) #prints total string\n", 327 | "\n", 328 | "print(a[0:2]) # 0,1 chars will be printed" 329 | ] 330 | }, 331 | { 332 | "cell_type": "markdown", 333 | "metadata": {}, 334 | "source": [ 335 | "# Conversions between DataTypes" 336 | ] 337 | }, 338 | { 339 | "cell_type": "code", 340 | "execution_count": 64, 341 | "metadata": {}, 342 | "outputs": [ 343 | { 344 | "name": "stdout", 345 | "output_type": "stream", 346 | "text": [ 347 | "10.0\n", 348 | "10\n", 349 | "10.1\n" 350 | ] 351 | }, 352 | { 353 | "data": { 354 | "text/plain": [ 355 | "'10.1'" 356 | ] 357 | }, 358 | "execution_count": 64, 359 | "metadata": {}, 360 | "output_type": "execute_result" 361 | } 362 | ], 363 | "source": [ 364 | "print(float(10))\n", 365 | "\n", 366 | "print(int(10.25))\n", 367 | "\n", 368 | "print(str(10.1))\n", 369 | "\n", 370 | "str(10.1)" 371 | ] 372 | }, 373 | { 374 | "cell_type": "code", 375 | "execution_count": null, 376 | "metadata": { 377 | "collapsed": true 378 | }, 379 | "outputs": [], 380 | "source": [] 381 | } 382 | ], 383 | "metadata": { 384 | "kernelspec": { 385 | "display_name": "Python 3", 386 | "language": "python", 387 | "name": "python3" 388 | }, 389 | "language_info": { 390 | "codemirror_mode": { 391 | "name": "ipython", 392 | "version": 3 393 | }, 394 | "file_extension": ".py", 395 | "mimetype": "text/x-python", 396 | "name": "python", 397 | "nbconvert_exporter": "python", 398 | "pygments_lexer": "ipython3", 399 | "version": "3.6.4" 400 | } 401 | }, 402 | "nbformat": 4, 403 | "nbformat_minor": 2 404 | } 405 | -------------------------------------------------------------------------------- /ControlFlow_Py.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# if else" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 3, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stdout", 17 | "output_type": "stream", 18 | "text": [ 19 | "enter a val:\n", 20 | "enter b val:\n" 21 | ] 22 | }, 23 | { 24 | "ename": "ValueError", 25 | "evalue": "invalid literal for int() with base 10: ''", 26 | "output_type": "error", 27 | "traceback": [ 28 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 29 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 30 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"enter a val:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"enter b val:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m>\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"true\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 31 | "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: ''" 32 | ] 33 | } 34 | ], 35 | "source": [ 36 | "a=input(\"enter a val:\");\n", 37 | "b=input(\"enter b val:\");\n", 38 | "if (int(a) >int(b)):\n", 39 | " print(\"true\")\n", 40 | "else:\n", 41 | " print(\"false\")" 42 | ] 43 | }, 44 | { 45 | "cell_type": "markdown", 46 | "metadata": { 47 | "collapsed": true 48 | }, 49 | "source": [ 50 | "# 0, None, False are considered as False" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 4, 56 | "metadata": {}, 57 | "outputs": [ 58 | { 59 | "name": "stdout", 60 | "output_type": "stream", 61 | "text": [ 62 | "if condition is false\n" 63 | ] 64 | } 65 | ], 66 | "source": [ 67 | "if 0:\n", 68 | " print(\"if condition is true\");\n", 69 | "print(\"if condition is false\");" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": 5, 75 | "metadata": {}, 76 | "outputs": [ 77 | { 78 | "name": "stdout", 79 | "output_type": "stream", 80 | "text": [ 81 | "if condition is false\n" 82 | ] 83 | } 84 | ], 85 | "source": [ 86 | "if None:\n", 87 | " print(\"if condition is true\");\n", 88 | "print(\"if condition is false\");" 89 | ] 90 | }, 91 | { 92 | "cell_type": "markdown", 93 | "metadata": {}, 94 | "source": [ 95 | "# if elif" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": 6, 101 | "metadata": {}, 102 | "outputs": [ 103 | { 104 | "name": "stdout", 105 | "output_type": "stream", 106 | "text": [ 107 | "enter a val:\n" 108 | ] 109 | }, 110 | { 111 | "ename": "ValueError", 112 | "evalue": "invalid literal for int() with base 10: ''", 113 | "output_type": "error", 114 | "traceback": [ 115 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 116 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 117 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"enter a val:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"enter b val:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mif\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m>\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"a\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 118 | "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: ''" 119 | ] 120 | } 121 | ], 122 | "source": [ 123 | "a=int(input(\"enter a val:\"));\n", 124 | "b=int(input(\"enter b val:\"));\n", 125 | "\n", 126 | "if(a>b):\n", 127 | " print(\"a\");\n", 128 | "elif(a" 32 | ] 33 | }, 34 | { 35 | "cell_type": "markdown", 36 | "metadata": {}, 37 | "source": [ 38 | "or" 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": {}, 44 | "source": [ 45 | "" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "its nothing but transpose of first matrix" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "metadata": {}, 58 | "source": [ 59 | "## Data PreProcessing: Column Normalization" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": {}, 65 | "source": [ 66 | "" 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "First Step after obtaining the dataset is PreProcessing i.e we perform some operations to neatly process our data, after this we perform Dimensionality Reduction." 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "metadata": {}, 86 | "source": [ 87 | "" 88 | ] 89 | }, 90 | { 91 | "cell_type": "markdown", 92 | "metadata": {}, 93 | "source": [ 94 | "normalizing col values such that the values lies between 0-1" 95 | ] 96 | }, 97 | { 98 | "cell_type": "markdown", 99 | "metadata": {}, 100 | "source": [ 101 | "### Why Data Normalization" 102 | ] 103 | }, 104 | { 105 | "cell_type": "markdown", 106 | "metadata": {}, 107 | "source": [ 108 | "" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "Here we considered 2 features Heights and Weights in cm and kg, As we get data from different sources The scale may be different i.e in one data set it might cm in other data set it might be feets in this case its hard to perform operations on data, so we Transform or Normalize the data so that the values lies between 0-1, so that we are not depending on the scale of measure." 116 | ] 117 | }, 118 | { 119 | "cell_type": "markdown", 120 | "metadata": {}, 121 | "source": [ 122 | "### Geometry perspective of col normalization" 123 | ] 124 | }, 125 | { 126 | "cell_type": "markdown", 127 | "metadata": {}, 128 | "source": [ 129 | "" 130 | ] 131 | }, 132 | { 133 | "cell_type": "markdown", 134 | "metadata": {}, 135 | "source": [ 136 | "Here we can see that after col normalization the values are fit into a unit square(2D) or unit cube(3D), so that performing operations on this is easy.\n", 137 | "\n", 138 | "
\n", 139 | "Column normalization is nothing but squeezing the data to fit into unit square or unit cube.\n", 140 | "\n", 141 | "
\n", 142 | "Major Advantage of this is we are getting rid of Scale of Measures." 143 | ] 144 | }, 145 | { 146 | "cell_type": "markdown", 147 | "metadata": {}, 148 | "source": [ 149 | "## Mean Of Data Matrix" 150 | ] 151 | }, 152 | { 153 | "cell_type": "markdown", 154 | "metadata": {}, 155 | "source": [ 156 | "" 157 | ] 158 | }, 159 | { 160 | "cell_type": "markdown", 161 | "metadata": {}, 162 | "source": [ 163 | "### Geometry Perspective" 164 | ] 165 | }, 166 | { 167 | "cell_type": "markdown", 168 | "metadata": {}, 169 | "source": [ 170 | "" 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "## Data PreProcessing: Column Standardization" 178 | ] 179 | }, 180 | { 181 | "cell_type": "markdown", 182 | "metadata": {}, 183 | "source": [ 184 | "" 185 | ] 186 | }, 187 | { 188 | "cell_type": "markdown", 189 | "metadata": {}, 190 | "source": [ 191 | "" 192 | ] 193 | }, 194 | { 195 | "cell_type": "markdown", 196 | "metadata": {}, 197 | "source": [ 198 | "Here in Col standardization we transform the data such that Mean of col chould be = 0 and std dev = 1.\n", 199 | "\n", 200 | "
\n", 201 | "This is another way of getting rid of scale of measures.\n", 202 | "
\n", 203 | "\n", 204 | "### Col Normalization vs Col Standardization\n", 205 | "In Col Norm we transform col vector values to lie betwee 0-1
\n", 206 | "In COl Std we transform col vector Mean to 0 and std dev to 1. i.e similar to normal distribution" 207 | ] 208 | }, 209 | { 210 | "cell_type": "markdown", 211 | "metadata": {}, 212 | "source": [ 213 | "" 214 | ] 215 | }, 216 | { 217 | "cell_type": "markdown", 218 | "metadata": {}, 219 | "source": [ 220 | "By using this formula we calculate the ai_dash vals the mean of these values will be 0 and std dev will be 1" 221 | ] 222 | }, 223 | { 224 | "cell_type": "markdown", 225 | "metadata": {}, 226 | "source": [ 227 | "" 228 | ] 229 | }, 230 | { 231 | "cell_type": "markdown", 232 | "metadata": {}, 233 | "source": [ 234 | "They both are same." 235 | ] 236 | }, 237 | { 238 | "cell_type": "markdown", 239 | "metadata": {}, 240 | "source": [ 241 | "### Geometry Perspective" 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": {}, 247 | "source": [ 248 | "" 249 | ] 250 | }, 251 | { 252 | "cell_type": "markdown", 253 | "metadata": {}, 254 | "source": [ 255 | "We will get to know the advtg of this while using PCA" 256 | ] 257 | }, 258 | { 259 | "cell_type": "markdown", 260 | "metadata": {}, 261 | "source": [ 262 | "## Co-Variance of a Data Matrix" 263 | ] 264 | }, 265 | { 266 | "cell_type": "markdown", 267 | "metadata": {}, 268 | "source": [ 269 | "" 270 | ] 271 | }, 272 | { 273 | "cell_type": "markdown", 274 | "metadata": {}, 275 | "source": [ 276 | "" 277 | ] 278 | }, 279 | { 280 | "cell_type": "markdown", 281 | "metadata": {}, 282 | "source": [ 283 | "#### if f1, f2 are Col Standardization then" 284 | ] 285 | }, 286 | { 287 | "cell_type": "markdown", 288 | "metadata": {}, 289 | "source": [ 290 | "" 291 | ] 292 | }, 293 | { 294 | "cell_type": "markdown", 295 | "metadata": {}, 296 | "source": [ 297 | "If we col std f1, f2 the mean will be zero, resulting in the above formula" 298 | ] 299 | }, 300 | { 301 | "cell_type": "code", 302 | "execution_count": null, 303 | "metadata": {}, 304 | "outputs": [], 305 | "source": [] 306 | } 307 | ], 308 | "metadata": { 309 | "kernelspec": { 310 | "display_name": "Python 3", 311 | "language": "python", 312 | "name": "python3" 313 | }, 314 | "language_info": { 315 | "codemirror_mode": { 316 | "name": "ipython", 317 | "version": 3 318 | }, 319 | "file_extension": ".py", 320 | "mimetype": "text/x-python", 321 | "name": "python", 322 | "nbconvert_exporter": "python", 323 | "pygments_lexer": "ipython3", 324 | "version": "3.6.4" 325 | } 326 | }, 327 | "nbformat": 4, 328 | "nbformat_minor": 2 329 | } 330 | -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/PCA/PCA.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# PCA(principle component analysis)\n", 8 | "## Dimensionality Reduction Technique" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "Why PCA?
\n", 16 | "Its a Dimensionality Reduction technique
\n", 17 | "It is used to convert nD -> 2D.
\n", 18 | "This is one of the most imp ML technique." 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": {}, 24 | "source": [ 25 | "## Geometric intution of PCA" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "### as variance/spread of f1 is low we will skip f1 and take only f2 if we want to consider only one feature i.e dimension is reduced\n", 40 | "\n", 41 | "## More Spread -> More Information" 42 | ] 43 | }, 44 | { 45 | "cell_type": "markdown", 46 | "metadata": {}, 47 | "source": [ 48 | "" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "metadata": {}, 54 | "source": [ 55 | "We have tilted/rotated the axes so that it will be in the direction of maximum spread/variance. In the above image we can see that befor tilting we cant correctly identify for which feature we have max spread, but after tilt we can see that f2_dash spread is very low so we can remove it and consider only f1." 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [] 64 | } 65 | ], 66 | "metadata": { 67 | "kernelspec": { 68 | "display_name": "Python 3", 69 | "language": "python", 70 | "name": "python3" 71 | }, 72 | "language_info": { 73 | "codemirror_mode": { 74 | "name": "ipython", 75 | "version": 3 76 | }, 77 | "file_extension": ".py", 78 | "mimetype": "text/x-python", 79 | "name": "python", 80 | "nbconvert_exporter": "python", 81 | "pygments_lexer": "ipython3", 82 | "version": "3.6.4" 83 | } 84 | }, 85 | "nbformat": 4, 86 | "nbformat_minor": 2 87 | } 88 | -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/PCA/images/pca.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/PCA/images/pca.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/PCA/images/pca1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/PCA/images/pca1.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/DataPreprocessing.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/DataPreprocessing.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/coVariance.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/coVariance.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/coVariance1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/coVariance1.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/coVariance3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/coVariance3.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/colNormalization.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/colNormalization.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/colNormalization1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/colNormalization1.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/colNormalization2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/colNormalization2.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/colNormalization3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/colNormalization3.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/datamatrix.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/datamatrix.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/datamatrix2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/datamatrix2.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/mean.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/mean.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/mean2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/mean2.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/mnist.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/mnist.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/mnist2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/mnist2.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/mnist3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/mnist3.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/stdzation.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/stdzation.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/stdzation2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/stdzation2.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/stdzation3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/stdzation3.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/stdzation4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/stdzation4.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/images/stdzation5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/images/stdzation5.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne1.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne2.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne3.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne4.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/DimensionalityReduction(PCA,t-SNE)/tSNE/images/tsne5.PNG -------------------------------------------------------------------------------- /DimensionalityReduction(PCA,t-SNE)/tSNE/t-SNE(on_MNIST).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# t-SNE(T-Distributed Stochastic Neighborhood Embedding)" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "Its a best Dimensionality Reduction Technique and its most widely used for Visualization.
\n", 15 | "Its Most advanced Technique that PCA" 16 | ] 17 | }, 18 | { 19 | "cell_type": "markdown", 20 | "metadata": {}, 21 | "source": [ 22 | "" 23 | ] 24 | }, 25 | { 26 | "cell_type": "markdown", 27 | "metadata": {}, 28 | "source": [ 29 | "Disadvantage of PCA is it doesnt consider the distance between the point but it considers if the points lie in one direction which doesnt give good result." 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "Advantage of tSNE is it preserves Local Strctures i.e in the above fig there are two outliers They are local structures, Global structure is nothing but the entire plot.\n", 37 | "
\n", 38 | "Tsne can even preserve the global structure by changing one param in the method." 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": {}, 44 | "source": [ 45 | "## Understanding The Terms of T-SNE" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "### Neighbourhood" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "metadata": {}, 58 | "source": [ 59 | "Its ntg but if we consider a point from the bunch of points and calculate the distance b/w this pt and other pt and if the distance is small then these points are Neighbouring points." 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": {}, 65 | "source": [ 66 | "### Embedding" 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "Its the process of placing point of N-Dimension in low dimension space. " 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "## Geometric Intution of t-SNE" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "metadata": {}, 86 | "source": [ 87 | "" 88 | ] 89 | }, 90 | { 91 | "cell_type": "markdown", 92 | "metadata": {}, 93 | "source": [ 94 | "Observation: Here in t-SNE while converting from d-dim to 2-dim we will preserve the distance between the points but it will not preserve the distance between the points which are in diff clusters." 95 | ] 96 | }, 97 | { 98 | "cell_type": "markdown", 99 | "metadata": {}, 100 | "source": [ 101 | "## Crowding Problem" 102 | ] 103 | }, 104 | { 105 | "cell_type": "markdown", 106 | "metadata": {}, 107 | "source": [ 108 | "" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "Crowding Problem: In the above case while converting from 2d to 1d we are not able to preserve every neighbourhood points distance for example in our case the neighbours of x4 are x1 and x3 but if we want to plot that in 1d either x4 can be placed near x1 or near x3, i.e if we place near x1 the distance between x4 and x3 will be 3*d not d, This is Crowding Problem its the major drawback of SNE, to AVOIDE THIS WE USE t-SNE." 116 | ] 117 | }, 118 | { 119 | "cell_type": "markdown", 120 | "metadata": {}, 121 | "source": [ 122 | "# How to apply t-SNE & Interpret its o/p" 123 | ] 124 | }, 125 | { 126 | "cell_type": "markdown", 127 | "metadata": {}, 128 | "source": [ 129 | "http://distill.pub/2016/misread-tsne/" 130 | ] 131 | }, 132 | { 133 | "cell_type": "markdown", 134 | "metadata": {}, 135 | "source": [ 136 | "" 137 | ] 138 | }, 139 | { 140 | "cell_type": "markdown", 141 | "metadata": {}, 142 | "source": [ 143 | "Explanation of Terms from above fig:
\n", 144 | "\n", 145 | "### Perplexity:\n", 146 | "For example Perplexity=10 then it preserves the distance of 10 neighbouring points.
\n", 147 | "\n", 148 | "From the above fig we can observe if perplexity is increasing the plot is getting stablized at perplexity=50 the plot is stable.
\n", 149 | "\n", 150 | "When Perplexity=100 the plot is unstable as in this case they have taken only 100 data points and p=100 i.e every point is neighbour of every other point i.e point less...\n", 151 | "\n", 152 | "#### Rule 1: Perplexity should be less than no.of data points\n", 153 | "#### Rule 2: Check ur plot with different no.of perplexities i.e increase the perplexity until the plot is stable\n", 154 | "\n" 155 | ] 156 | }, 157 | { 158 | "cell_type": "markdown", 159 | "metadata": {}, 160 | "source": [ 161 | "" 162 | ] 163 | }, 164 | { 165 | "cell_type": "markdown", 166 | "metadata": {}, 167 | "source": [ 168 | "### Step:\n", 169 | "Its ntg but the no.of iterations the algo runs..\n", 170 | "\n", 171 | "#### t-SNE is Stochastic/probabilistic Distribution i.e every time we run the algo the result varies so we will run the algo until plot is stable i.e after some no.of iterations the graph will not change i.e its stable, Examples in the above link. " 172 | ] 173 | }, 174 | { 175 | "cell_type": "markdown", 176 | "metadata": {}, 177 | "source": [ 178 | "Disadvantage of t-SNE is we cannot say whether a cluster is dense or sparse" 179 | ] 180 | }, 181 | { 182 | "cell_type": "markdown", 183 | "metadata": {}, 184 | "source": [ 185 | "#### Note: Distance between the clusters mean nothing i.e It doesnt preserve distance between clusters" 186 | ] 187 | }, 188 | { 189 | "cell_type": "markdown", 190 | "metadata": {}, 191 | "source": [ 192 | "# t-SNE on MNIST" 193 | ] 194 | }, 195 | { 196 | "cell_type": "markdown", 197 | "metadata": {}, 198 | "source": [ 199 | "http://colah.github.io/posts/2014-10-Visualizing-MNIST/" 200 | ] 201 | }, 202 | { 203 | "cell_type": "markdown", 204 | "metadata": {}, 205 | "source": [ 206 | "t-SNE groups points based on the Visual SImilarity" 207 | ] 208 | }, 209 | { 210 | "cell_type": "markdown", 211 | "metadata": {}, 212 | "source": [ 213 | "# Check t-SNE on MNIST code in MNIST_DATA_SET_784_Dimensions.ipynb file." 214 | ] 215 | }, 216 | { 217 | "cell_type": "code", 218 | "execution_count": 1, 219 | "metadata": {}, 220 | "outputs": [], 221 | "source": [] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": null, 226 | "metadata": {}, 227 | "outputs": [], 228 | "source": [] 229 | }, 230 | { 231 | "cell_type": "code", 232 | "execution_count": null, 233 | "metadata": {}, 234 | "outputs": [], 235 | "source": [] 236 | } 237 | ], 238 | "metadata": { 239 | "kernelspec": { 240 | "display_name": "Python 3", 241 | "language": "python", 242 | "name": "python3" 243 | }, 244 | "language_info": { 245 | "codemirror_mode": { 246 | "name": "ipython", 247 | "version": 3 248 | }, 249 | "file_extension": ".py", 250 | "mimetype": "text/x-python", 251 | "name": "python", 252 | "nbconvert_exporter": "python", 253 | "pygments_lexer": "ipython3", 254 | "version": "3.6.4" 255 | } 256 | }, 257 | "nbformat": 4, 258 | "nbformat_minor": 2 259 | } 260 | -------------------------------------------------------------------------------- /EDA_LinearAlgebra_CreditCardFraudDetectionExercise/50KDataPointsTsne.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/EDA_LinearAlgebra_CreditCardFraudDetectionExercise/50KDataPointsTsne.pickle -------------------------------------------------------------------------------- /EDA_LinearAlgebra_CreditCardFraudDetectionExercise/EDA_CerditCradFraud_Task1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/EDA_LinearAlgebra_CreditCardFraudDetectionExercise/EDA_CerditCradFraud_Task1.pdf -------------------------------------------------------------------------------- /EDA_LinearAlgebra_CreditCardFraudDetectionExercise/TransactionSimilarityTask2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/EDA_LinearAlgebra_CreditCardFraudDetectionExercise/TransactionSimilarityTask2.pdf -------------------------------------------------------------------------------- /EDA_LinearAlgebra_CreditCardFraudDetectionExercise/Tsne(CreditCardFraudDetection).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/EDA_LinearAlgebra_CreditCardFraudDetectionExercise/Tsne(CreditCardFraudDetection).pdf -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise.pdf -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_12_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_12_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_14_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_14_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_17_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_17_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_21_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_21_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_23_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_23_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_24_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_24_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_31_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_31_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_32_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_32_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_33_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_33_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_35_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_35_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_37_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_37_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_38_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_38_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_40_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ExploratoryDataAnalysis(EDA)/Exercise/Haberman'sSurvivalExercise_files/Haberman'sSurvivalExercise_40_0.png -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Exercise/haberman.csv: -------------------------------------------------------------------------------- 1 | Age,Year,No.of Pos Axillary nodes,Survival Status 2 | 30,64,1,1 3 | 30,62,3,1 4 | 30,65,0,1 5 | 31,59,2,1 6 | 31,65,4,1 7 | 33,58,10,1 8 | 33,60,0,1 9 | 34,59,0,2 10 | 34,66,9,2 11 | 34,58,30,1 12 | 34,60,1,1 13 | 34,61,10,1 14 | 34,67,7,1 15 | 34,60,0,1 16 | 35,64,13,1 17 | 35,63,0,1 18 | 36,60,1,1 19 | 36,69,0,1 20 | 37,60,0,1 21 | 37,63,0,1 22 | 37,58,0,1 23 | 37,59,6,1 24 | 37,60,15,1 25 | 37,63,0,1 26 | 38,69,21,2 27 | 38,59,2,1 28 | 38,60,0,1 29 | 38,60,0,1 30 | 38,62,3,1 31 | 38,64,1,1 32 | 38,66,0,1 33 | 38,66,11,1 34 | 38,60,1,1 35 | 38,67,5,1 36 | 39,66,0,2 37 | 39,63,0,1 38 | 39,67,0,1 39 | 39,58,0,1 40 | 39,59,2,1 41 | 39,63,4,1 42 | 40,58,2,1 43 | 40,58,0,1 44 | 40,65,0,1 45 | 41,60,23,2 46 | 41,64,0,2 47 | 41,67,0,2 48 | 41,58,0,1 49 | 41,59,8,1 50 | 41,59,0,1 51 | 41,64,0,1 52 | 41,69,8,1 53 | 41,65,0,1 54 | 41,65,0,1 55 | 42,69,1,2 56 | 42,59,0,2 57 | 42,58,0,1 58 | 42,60,1,1 59 | 42,59,2,1 60 | 42,61,4,1 61 | 42,62,20,1 62 | 42,65,0,1 63 | 42,63,1,1 64 | 43,58,52,2 65 | 43,59,2,2 66 | 43,64,0,2 67 | 43,64,0,2 68 | 43,63,14,1 69 | 43,64,2,1 70 | 43,64,3,1 71 | 43,60,0,1 72 | 43,63,2,1 73 | 43,65,0,1 74 | 43,66,4,1 75 | 44,64,6,2 76 | 44,58,9,2 77 | 44,63,19,2 78 | 44,61,0,1 79 | 44,63,1,1 80 | 44,61,0,1 81 | 44,67,16,1 82 | 45,65,6,2 83 | 45,66,0,2 84 | 45,67,1,2 85 | 45,60,0,1 86 | 45,67,0,1 87 | 45,59,14,1 88 | 45,64,0,1 89 | 45,68,0,1 90 | 45,67,1,1 91 | 46,58,2,2 92 | 46,69,3,2 93 | 46,62,5,2 94 | 46,65,20,2 95 | 46,62,0,1 96 | 46,58,3,1 97 | 46,63,0,1 98 | 47,63,23,2 99 | 47,62,0,2 100 | 47,65,0,2 101 | 47,61,0,1 102 | 47,63,6,1 103 | 47,66,0,1 104 | 47,67,0,1 105 | 47,58,3,1 106 | 47,60,4,1 107 | 47,68,4,1 108 | 47,66,12,1 109 | 48,58,11,2 110 | 48,58,11,2 111 | 48,67,7,2 112 | 48,61,8,1 113 | 48,62,2,1 114 | 48,64,0,1 115 | 48,66,0,1 116 | 49,63,0,2 117 | 49,64,10,2 118 | 49,61,1,1 119 | 49,62,0,1 120 | 49,66,0,1 121 | 49,60,1,1 122 | 49,62,1,1 123 | 49,63,3,1 124 | 49,61,0,1 125 | 49,67,1,1 126 | 50,63,13,2 127 | 50,64,0,2 128 | 50,59,0,1 129 | 50,61,6,1 130 | 50,61,0,1 131 | 50,63,1,1 132 | 50,58,1,1 133 | 50,59,2,1 134 | 50,61,0,1 135 | 50,64,0,1 136 | 50,65,4,1 137 | 50,66,1,1 138 | 51,59,13,2 139 | 51,59,3,2 140 | 51,64,7,1 141 | 51,59,1,1 142 | 51,65,0,1 143 | 51,66,1,1 144 | 52,69,3,2 145 | 52,59,2,2 146 | 52,62,3,2 147 | 52,66,4,2 148 | 52,61,0,1 149 | 52,63,4,1 150 | 52,69,0,1 151 | 52,60,4,1 152 | 52,60,5,1 153 | 52,62,0,1 154 | 52,62,1,1 155 | 52,64,0,1 156 | 52,65,0,1 157 | 52,68,0,1 158 | 53,58,4,2 159 | 53,65,1,2 160 | 53,59,3,2 161 | 53,60,9,2 162 | 53,63,24,2 163 | 53,65,12,2 164 | 53,58,1,1 165 | 53,60,1,1 166 | 53,60,2,1 167 | 53,61,1,1 168 | 53,63,0,1 169 | 54,60,11,2 170 | 54,65,23,2 171 | 54,65,5,2 172 | 54,68,7,2 173 | 54,59,7,1 174 | 54,60,3,1 175 | 54,66,0,1 176 | 54,67,46,1 177 | 54,62,0,1 178 | 54,69,7,1 179 | 54,63,19,1 180 | 54,58,1,1 181 | 54,62,0,1 182 | 55,63,6,2 183 | 55,68,15,2 184 | 55,58,1,1 185 | 55,58,0,1 186 | 55,58,1,1 187 | 55,66,18,1 188 | 55,66,0,1 189 | 55,69,3,1 190 | 55,69,22,1 191 | 55,67,1,1 192 | 56,65,9,2 193 | 56,66,3,2 194 | 56,60,0,1 195 | 56,66,2,1 196 | 56,66,1,1 197 | 56,67,0,1 198 | 56,60,0,1 199 | 57,61,5,2 200 | 57,62,14,2 201 | 57,64,1,2 202 | 57,64,9,1 203 | 57,69,0,1 204 | 57,61,0,1 205 | 57,62,0,1 206 | 57,63,0,1 207 | 57,64,0,1 208 | 57,64,0,1 209 | 57,67,0,1 210 | 58,59,0,1 211 | 58,60,3,1 212 | 58,61,1,1 213 | 58,67,0,1 214 | 58,58,0,1 215 | 58,58,3,1 216 | 58,61,2,1 217 | 59,62,35,2 218 | 59,60,0,1 219 | 59,63,0,1 220 | 59,64,1,1 221 | 59,64,4,1 222 | 59,64,0,1 223 | 59,64,7,1 224 | 59,67,3,1 225 | 60,59,17,2 226 | 60,65,0,2 227 | 60,61,1,1 228 | 60,67,2,1 229 | 60,61,25,1 230 | 60,64,0,1 231 | 61,62,5,2 232 | 61,65,0,2 233 | 61,68,1,2 234 | 61,59,0,1 235 | 61,59,0,1 236 | 61,64,0,1 237 | 61,65,8,1 238 | 61,68,0,1 239 | 61,59,0,1 240 | 62,59,13,2 241 | 62,58,0,2 242 | 62,65,19,2 243 | 62,62,6,1 244 | 62,66,0,1 245 | 62,66,0,1 246 | 62,58,0,1 247 | 63,60,1,2 248 | 63,61,0,1 249 | 63,62,0,1 250 | 63,63,0,1 251 | 63,63,0,1 252 | 63,66,0,1 253 | 63,61,9,1 254 | 63,61,28,1 255 | 64,58,0,1 256 | 64,65,22,1 257 | 64,66,0,1 258 | 64,61,0,1 259 | 64,68,0,1 260 | 65,58,0,2 261 | 65,61,2,2 262 | 65,62,22,2 263 | 65,66,15,2 264 | 65,58,0,1 265 | 65,64,0,1 266 | 65,67,0,1 267 | 65,59,2,1 268 | 65,64,0,1 269 | 65,67,1,1 270 | 66,58,0,2 271 | 66,61,13,2 272 | 66,58,0,1 273 | 66,58,1,1 274 | 66,68,0,1 275 | 67,64,8,2 276 | 67,63,1,2 277 | 67,66,0,1 278 | 67,66,0,1 279 | 67,61,0,1 280 | 67,65,0,1 281 | 68,67,0,1 282 | 68,68,0,1 283 | 69,67,8,2 284 | 69,60,0,1 285 | 69,65,0,1 286 | 69,66,0,1 287 | 70,58,0,2 288 | 70,58,4,2 289 | 70,66,14,1 290 | 70,67,0,1 291 | 70,68,0,1 292 | 70,59,8,1 293 | 70,63,0,1 294 | 71,68,2,1 295 | 72,63,0,2 296 | 72,58,0,1 297 | 72,64,0,1 298 | 72,67,3,1 299 | 73,62,0,1 300 | 73,68,0,1 301 | 74,65,3,2 302 | 74,63,0,1 303 | 75,62,1,1 304 | 76,67,0,1 305 | 77,65,3,1 306 | 78,65,1,2 307 | 83,58,2,2 308 | -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/MeanMedianStdPercentileQuantile.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Mean and Std" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import pandas as pd\n", 17 | "import numpy as np\n", 18 | "import matplotlib.pyplot as plt\n", 19 | "import seaborn as sns\n" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 5, 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [ 28 | "iris = pd.read_csv('iris.csv');\n", 29 | "iris_setosa = iris['petal_length'][iris['species']=='setosa']\n", 30 | "iris_versicolor = iris['petal_length'][iris['species']=='versicolor']\n", 31 | "iris_virginica = iris['petal_length'][iris['species']=='virginica']" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": 7, 37 | "metadata": {}, 38 | "outputs": [ 39 | { 40 | "name": "stdout", 41 | "output_type": "stream", 42 | "text": [ 43 | "Mean: \n", 44 | "1.464\n", 45 | "4.26\n", 46 | "5.552\n", 47 | "----------------------------\n", 48 | "std: \n", 49 | "0.17176728442867115\n", 50 | "0.4651881339845204\n", 51 | "0.5463478745268441\n" 52 | ] 53 | } 54 | ], 55 | "source": [ 56 | "print(\"Mean: \")\n", 57 | "print(np.mean(iris_setosa))\n", 58 | "print(np.mean(iris_versicolor))\n", 59 | "print(np.mean(iris_virginica))\n", 60 | "print(\"----------------------------\")\n", 61 | "print(\"std: \")\n", 62 | "print(np.std(iris_setosa))\n", 63 | "print(np.std(iris_versicolor))\n", 64 | "print(np.std(iris_virginica))" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": 11, 70 | "metadata": {}, 71 | "outputs": [ 72 | { 73 | "name": "stdout", 74 | "output_type": "stream", 75 | "text": [ 76 | "1.464\n", 77 | "2.4156862745098038\n" 78 | ] 79 | } 80 | ], 81 | "source": [ 82 | "print(np.mean(iris_setosa))\n", 83 | "\n", 84 | "#outlier is added\n", 85 | "print(np.mean(np.append(iris_setosa,50)));" 86 | ] 87 | }, 88 | { 89 | "cell_type": "markdown", 90 | "metadata": {}, 91 | "source": [ 92 | "Observation:\n", 93 | "51st flower length is added to our data and it is wrong i.e huge value is inserted in our case its 50, but actual length will be 1-2 so the mean is changed drastically, so following only mean is not feasible, similarly std also" 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "# Median" 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": 13, 106 | "metadata": {}, 107 | "outputs": [ 108 | { 109 | "name": "stdout", 110 | "output_type": "stream", 111 | "text": [ 112 | "1.5\n", 113 | "1.5\n" 114 | ] 115 | } 116 | ], 117 | "source": [ 118 | "print(np.median(iris_setosa))\n", 119 | "\n", 120 | "print(np.median(np.append(iris_setosa,50)));" 121 | ] 122 | }, 123 | { 124 | "cell_type": "markdown", 125 | "metadata": {}, 126 | "source": [ 127 | "Observation: Even after Adding Outlier the result is almost same.because \n", 128 | "\n", 129 | "if there are more than 50% of outliers then result will be useless.\n", 130 | "\n", 131 | "So its better than mean and std." 132 | ] 133 | }, 134 | { 135 | "cell_type": "markdown", 136 | "metadata": {}, 137 | "source": [ 138 | "# Percentiles" 139 | ] 140 | }, 141 | { 142 | "cell_type": "markdown", 143 | "metadata": {}, 144 | "source": [ 145 | "Example: 10 percentile indicates there are 10% of values which are less than it" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": 16, 151 | "metadata": {}, 152 | "outputs": [ 153 | { 154 | "name": "stdout", 155 | "output_type": "stream", 156 | "text": [ 157 | "1.7\n" 158 | ] 159 | } 160 | ], 161 | "source": [ 162 | "#second param is percentile\n", 163 | "print(np.percentile(iris_setosa,90))" 164 | ] 165 | }, 166 | { 167 | "cell_type": "markdown", 168 | "metadata": {}, 169 | "source": [ 170 | "# Quantile\n", 171 | "Quantile is nothing but 0,25,50,75 Percentiles" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": 20, 177 | "metadata": {}, 178 | "outputs": [ 179 | { 180 | "name": "stdout", 181 | "output_type": "stream", 182 | "text": [ 183 | "Quantiles: \n", 184 | "1.0\n", 185 | "1.4\n", 186 | "1.5\n", 187 | "1.5750000000000002\n" 188 | ] 189 | } 190 | ], 191 | "source": [ 192 | "print(\"Quantiles: \")\n", 193 | "print(np.percentile(iris_setosa,0))\n", 194 | "print(np.percentile(iris_setosa,25))\n", 195 | "print(np.percentile(iris_setosa,50))\n", 196 | "print(np.percentile(iris_setosa,75))" 197 | ] 198 | }, 199 | { 200 | "cell_type": "markdown", 201 | "metadata": {}, 202 | "source": [ 203 | "# IQR(Inter Quartile Range)And MAD(Median Absolute Deviation)" 204 | ] 205 | }, 206 | { 207 | "cell_type": "markdown", 208 | "metadata": {}, 209 | "source": [ 210 | "### MAD" 211 | ] 212 | }, 213 | { 214 | "cell_type": "markdown", 215 | "metadata": {}, 216 | "source": [ 217 | "It is similar to Std, In MAD also we calculate the distance betwwen the point and median.\n", 218 | "\n", 219 | "Formula: median(| x-medianOfVals |) from i=1 to n" 220 | ] 221 | }, 222 | { 223 | "cell_type": "code", 224 | "execution_count": 22, 225 | "metadata": {}, 226 | "outputs": [ 227 | { 228 | "name": "stdout", 229 | "output_type": "stream", 230 | "text": [ 231 | "Median Abs Deviation(MAD)\n", 232 | "0.14826022185056031\n" 233 | ] 234 | } 235 | ], 236 | "source": [ 237 | "from statsmodels import robust\n", 238 | "\n", 239 | "print(\"Median Abs Deviation(MAD)\");\n", 240 | "\n", 241 | "print(robust.mad(iris_setosa))" 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": {}, 247 | "source": [ 248 | "# IQR\n", 249 | "\n", 250 | "is nothing but the difference between 2 quantiles" 251 | ] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "execution_count": 24, 256 | "metadata": {}, 257 | "outputs": [ 258 | { 259 | "name": "stdout", 260 | "output_type": "stream", 261 | "text": [ 262 | "0.17500000000000027\n" 263 | ] 264 | } 265 | ], 266 | "source": [ 267 | "print(np.percentile(iris_setosa,75)-np.percentile(iris_setosa,25))" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": null, 273 | "metadata": {}, 274 | "outputs": [], 275 | "source": [] 276 | } 277 | ], 278 | "metadata": { 279 | "kernelspec": { 280 | "display_name": "Python 3", 281 | "language": "python", 282 | "name": "python3" 283 | }, 284 | "language_info": { 285 | "codemirror_mode": { 286 | "name": "ipython", 287 | "version": 3 288 | }, 289 | "file_extension": ".py", 290 | "mimetype": "text/x-python", 291 | "name": "python", 292 | "nbconvert_exporter": "python", 293 | "pygments_lexer": "ipython3", 294 | "version": "3.6.4" 295 | } 296 | }, 297 | "nbformat": 4, 298 | "nbformat_minor": 2 299 | } 300 | -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/Summary of EDA.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Summarizing EDA" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "### UniVariant Analysis:(Considered 1 feature / 1D)
\n", 15 | " PDF/Histograms\n", 16 | " CDF\n", 17 | " Box Plot\n", 18 | " Violin Plot\n", 19 | "\n", 20 | "### BiVarient Analysis:(Considered 2 features / 2D)
\n", 21 | " Scatter Plot\n", 22 | " Pair Plot\n", 23 | " \n", 24 | "### MultiVariant Analysis:(Considered 3 or more features / nD)
\n", 25 | " 3D Plot" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": null, 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [] 34 | } 35 | ], 36 | "metadata": { 37 | "kernelspec": { 38 | "display_name": "Python 3", 39 | "language": "python", 40 | "name": "python3" 41 | }, 42 | "language_info": { 43 | "codemirror_mode": { 44 | "name": "ipython", 45 | "version": 3 46 | }, 47 | "file_extension": ".py", 48 | "mimetype": "text/x-python", 49 | "name": "python", 50 | "nbconvert_exporter": "python", 51 | "pygments_lexer": "ipython3", 52 | "version": "3.6.4" 53 | } 54 | }, 55 | "nbformat": 4, 56 | "nbformat_minor": 2 57 | } 58 | -------------------------------------------------------------------------------- /ExploratoryDataAnalysis(EDA)/iris.csv: -------------------------------------------------------------------------------- 1 | sepal_length,sepal_width,petal_length,petal_width,species 2 | 5.1,3.5,1.4,0.2,setosa 3 | 4.9,3,1.4,0.2,setosa 4 | 4.7,3.2,1.3,0.2,setosa 5 | 4.6,3.1,1.5,0.2,setosa 6 | 5,3.6,1.4,0.2,setosa 7 | 5.4,3.9,1.7,0.4,setosa 8 | 4.6,3.4,1.4,0.3,setosa 9 | 5,3.4,1.5,0.2,setosa 10 | 4.4,2.9,1.4,0.2,setosa 11 | 4.9,3.1,1.5,0.1,setosa 12 | 5.4,3.7,1.5,0.2,setosa 13 | 4.8,3.4,1.6,0.2,setosa 14 | 4.8,3,1.4,0.1,setosa 15 | 4.3,3,1.1,0.1,setosa 16 | 5.8,4,1.2,0.2,setosa 17 | 5.7,4.4,1.5,0.4,setosa 18 | 5.4,3.9,1.3,0.4,setosa 19 | 5.1,3.5,1.4,0.3,setosa 20 | 5.7,3.8,1.7,0.3,setosa 21 | 5.1,3.8,1.5,0.3,setosa 22 | 5.4,3.4,1.7,0.2,setosa 23 | 5.1,3.7,1.5,0.4,setosa 24 | 4.6,3.6,1,0.2,setosa 25 | 5.1,3.3,1.7,0.5,setosa 26 | 4.8,3.4,1.9,0.2,setosa 27 | 5,3,1.6,0.2,setosa 28 | 5,3.4,1.6,0.4,setosa 29 | 5.2,3.5,1.5,0.2,setosa 30 | 5.2,3.4,1.4,0.2,setosa 31 | 4.7,3.2,1.6,0.2,setosa 32 | 4.8,3.1,1.6,0.2,setosa 33 | 5.4,3.4,1.5,0.4,setosa 34 | 5.2,4.1,1.5,0.1,setosa 35 | 5.5,4.2,1.4,0.2,setosa 36 | 4.9,3.1,1.5,0.1,setosa 37 | 5,3.2,1.2,0.2,setosa 38 | 5.5,3.5,1.3,0.2,setosa 39 | 4.9,3.1,1.5,0.1,setosa 40 | 4.4,3,1.3,0.2,setosa 41 | 5.1,3.4,1.5,0.2,setosa 42 | 5,3.5,1.3,0.3,setosa 43 | 4.5,2.3,1.3,0.3,setosa 44 | 4.4,3.2,1.3,0.2,setosa 45 | 5,3.5,1.6,0.6,setosa 46 | 5.1,3.8,1.9,0.4,setosa 47 | 4.8,3,1.4,0.3,setosa 48 | 5.1,3.8,1.6,0.2,setosa 49 | 4.6,3.2,1.4,0.2,setosa 50 | 5.3,3.7,1.5,0.2,setosa 51 | 5,3.3,1.4,0.2,setosa 52 | 7,3.2,4.7,1.4,versicolor 53 | 6.4,3.2,4.5,1.5,versicolor 54 | 6.9,3.1,4.9,1.5,versicolor 55 | 5.5,2.3,4,1.3,versicolor 56 | 6.5,2.8,4.6,1.5,versicolor 57 | 5.7,2.8,4.5,1.3,versicolor 58 | 6.3,3.3,4.7,1.6,versicolor 59 | 4.9,2.4,3.3,1,versicolor 60 | 6.6,2.9,4.6,1.3,versicolor 61 | 5.2,2.7,3.9,1.4,versicolor 62 | 5,2,3.5,1,versicolor 63 | 5.9,3,4.2,1.5,versicolor 64 | 6,2.2,4,1,versicolor 65 | 6.1,2.9,4.7,1.4,versicolor 66 | 5.6,2.9,3.6,1.3,versicolor 67 | 6.7,3.1,4.4,1.4,versicolor 68 | 5.6,3,4.5,1.5,versicolor 69 | 5.8,2.7,4.1,1,versicolor 70 | 6.2,2.2,4.5,1.5,versicolor 71 | 5.6,2.5,3.9,1.1,versicolor 72 | 5.9,3.2,4.8,1.8,versicolor 73 | 6.1,2.8,4,1.3,versicolor 74 | 6.3,2.5,4.9,1.5,versicolor 75 | 6.1,2.8,4.7,1.2,versicolor 76 | 6.4,2.9,4.3,1.3,versicolor 77 | 6.6,3,4.4,1.4,versicolor 78 | 6.8,2.8,4.8,1.4,versicolor 79 | 6.7,3,5,1.7,versicolor 80 | 6,2.9,4.5,1.5,versicolor 81 | 5.7,2.6,3.5,1,versicolor 82 | 5.5,2.4,3.8,1.1,versicolor 83 | 5.5,2.4,3.7,1,versicolor 84 | 5.8,2.7,3.9,1.2,versicolor 85 | 6,2.7,5.1,1.6,versicolor 86 | 5.4,3,4.5,1.5,versicolor 87 | 6,3.4,4.5,1.6,versicolor 88 | 6.7,3.1,4.7,1.5,versicolor 89 | 6.3,2.3,4.4,1.3,versicolor 90 | 5.6,3,4.1,1.3,versicolor 91 | 5.5,2.5,4,1.3,versicolor 92 | 5.5,2.6,4.4,1.2,versicolor 93 | 6.1,3,4.6,1.4,versicolor 94 | 5.8,2.6,4,1.2,versicolor 95 | 5,2.3,3.3,1,versicolor 96 | 5.6,2.7,4.2,1.3,versicolor 97 | 5.7,3,4.2,1.2,versicolor 98 | 5.7,2.9,4.2,1.3,versicolor 99 | 6.2,2.9,4.3,1.3,versicolor 100 | 5.1,2.5,3,1.1,versicolor 101 | 5.7,2.8,4.1,1.3,versicolor 102 | 6.3,3.3,6,2.5,virginica 103 | 5.8,2.7,5.1,1.9,virginica 104 | 7.1,3,5.9,2.1,virginica 105 | 6.3,2.9,5.6,1.8,virginica 106 | 6.5,3,5.8,2.2,virginica 107 | 7.6,3,6.6,2.1,virginica 108 | 4.9,2.5,4.5,1.7,virginica 109 | 7.3,2.9,6.3,1.8,virginica 110 | 6.7,2.5,5.8,1.8,virginica 111 | 7.2,3.6,6.1,2.5,virginica 112 | 6.5,3.2,5.1,2,virginica 113 | 6.4,2.7,5.3,1.9,virginica 114 | 6.8,3,5.5,2.1,virginica 115 | 5.7,2.5,5,2,virginica 116 | 5.8,2.8,5.1,2.4,virginica 117 | 6.4,3.2,5.3,2.3,virginica 118 | 6.5,3,5.5,1.8,virginica 119 | 7.7,3.8,6.7,2.2,virginica 120 | 7.7,2.6,6.9,2.3,virginica 121 | 6,2.2,5,1.5,virginica 122 | 6.9,3.2,5.7,2.3,virginica 123 | 5.6,2.8,4.9,2,virginica 124 | 7.7,2.8,6.7,2,virginica 125 | 6.3,2.7,4.9,1.8,virginica 126 | 6.7,3.3,5.7,2.1,virginica 127 | 7.2,3.2,6,1.8,virginica 128 | 6.2,2.8,4.8,1.8,virginica 129 | 6.1,3,4.9,1.8,virginica 130 | 6.4,2.8,5.6,2.1,virginica 131 | 7.2,3,5.8,1.6,virginica 132 | 7.4,2.8,6.1,1.9,virginica 133 | 7.9,3.8,6.4,2,virginica 134 | 6.4,2.8,5.6,2.2,virginica 135 | 6.3,2.8,5.1,1.5,virginica 136 | 6.1,2.6,5.6,1.4,virginica 137 | 7.7,3,6.1,2.3,virginica 138 | 6.3,3.4,5.6,2.4,virginica 139 | 6.4,3.1,5.5,1.8,virginica 140 | 6,3,4.8,1.8,virginica 141 | 6.9,3.1,5.4,2.1,virginica 142 | 6.7,3.1,5.6,2.4,virginica 143 | 6.9,3.1,5.1,2.3,virginica 144 | 5.8,2.7,5.1,1.9,virginica 145 | 6.8,3.2,5.9,2.3,virginica 146 | 6.7,3.3,5.7,2.5,virginica 147 | 6.7,3,5.2,2.3,virginica 148 | 6.3,2.5,5,1.9,virginica 149 | 6.5,3,5.2,2,virginica 150 | 6.2,3.4,5.4,2.3,virginica 151 | 5.9,3,5.1,1.8,virginica -------------------------------------------------------------------------------- /Input_Output_Py.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Output Formatting" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 2, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stdout", 17 | "output_type": "stream", 18 | "text": [ 19 | "the val of a is 10 and b is 20\n" 20 | ] 21 | } 22 | ], 23 | "source": [ 24 | "a = 10; b=20;\n", 25 | "\n", 26 | "print(\"the val of a is {} and b is {}\".format(a,b)); #similar to C lang" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 8, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "name": "stdout", 36 | "output_type": "stream", 37 | "text": [ 38 | "the val of b is 20 and a is 10\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "a = 10; b=20;\n", 44 | "\n", 45 | "print(\"the val of b is {1} and a is {0}\".format(a,b)); #mentioning positions of a and b\n" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 9, 51 | "metadata": {}, 52 | "outputs": [ 53 | { 54 | "name": "stdout", 55 | "output_type": "stream", 56 | "text": [ 57 | "Hello Akarsh Akarsh\n" 58 | ] 59 | } 60 | ], 61 | "source": [ 62 | "print(\"Hello {name} {name}\".format(name=\"Akarsh\"))" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "metadata": {}, 68 | "source": [ 69 | "# Input\n", 70 | "### input() will always takes value in terms of String,\n", 71 | "### we need to convert it to int, float....accordingly. " 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 1, 77 | "metadata": {}, 78 | "outputs": [ 79 | { 80 | "name": "stdout", 81 | "output_type": "stream", 82 | "text": [ 83 | "Enter a Number10\n", 84 | "The value entered is: 10\n", 85 | "\n" 86 | ] 87 | } 88 | ], 89 | "source": [ 90 | "a = input(\"Enter a Number\")\n", 91 | "print(\"The value entered is: \",a)\n", 92 | "\n", 93 | "print(type(a));" 94 | ] 95 | } 96 | ], 97 | "metadata": { 98 | "kernelspec": { 99 | "display_name": "Python 3", 100 | "language": "python", 101 | "name": "python3" 102 | }, 103 | "language_info": { 104 | "codemirror_mode": { 105 | "name": "ipython", 106 | "version": 3 107 | }, 108 | "file_extension": ".py", 109 | "mimetype": "text/x-python", 110 | "name": "python", 111 | "nbconvert_exporter": "python", 112 | "pygments_lexer": "ipython3", 113 | "version": "3.6.4" 114 | } 115 | }, 116 | "nbformat": 4, 117 | "nbformat_minor": 2 118 | } 119 | -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/KNN_Basics.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# K-NN (K Nearest Neighbour) Classification n Regression" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "### What is KNN?
\n", 15 | "\n", 16 | "KNN is technique which is used for Classification Problems for example Amazon Reviews to classify whether a review is positive or negative.
\n", 17 | "\n", 18 | "Its done by Training a function f(x) i.e we will train this function from the given dataset and after that if we give any queryPoint to this function it will return whether its positive or negative review.
\n", 19 | "\n", 20 | "### How KNN is calculated?
\n", 21 | "\n", 22 | "When we pass a querypoint(the point which need to be classified) to y=f(x), It will calculate 'K nearest Neighbours' to the querypoint so that we will get k yi's(i.e positive or negative) and if majority of Yi's are positive the Querypoint is considered as positive review or else negative review.
\n", 23 | "\n", 24 | "### Where KNN Fails?
\n", 25 | "\n", 26 | "KNN fails in 2 cases:
\n", 27 | "\n", 28 | "Case 1: When the query point is far away from both the positive and negative points(i.e its an outlier), then its hard to classify.
\n", 29 | "\n", 30 | "Case 2: When Data Points are randomly spread the its hard to classify if the querypoint is positive or negative review.
" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": {}, 36 | "source": [ 37 | "## TERMS Used in this concept" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": {}, 43 | "source": [ 44 | "Euclidean(L2) distance -> distance between 2 points regular formula.
\n", 45 | "\n", 46 | "Manhattan(L1) distance -> is sum of 2 sides other than Hypotenuse.
\n", 47 | "\n", 48 | "Minkowski -> generalized formula for L2 and L1.
\n", 49 | "\n", 50 | "Hamming Distance -> Its the count of no.of difference values Between 2 vectors
\n", 51 | "Example:
\n", 52 | "\n", 53 | "x -> [a,b,a,a,b]
\n", 54 | "y -> [a,a,b,a,b]
\n", 55 | "\n", 56 | "In the above case Hamming distance is 2 as in positions/indices 1,2 values are not same.\n" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "# KNN Decision Surface" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "" 71 | ] 72 | }, 73 | { 74 | "cell_type": "markdown", 75 | "metadata": {}, 76 | "source": [ 77 | "In the above image the curve which is not smmoth is called Decision Surface,\n", 78 | "The smoothness of the curve depends on the 'K' Value i.e if K increases Smoothness Increases." 79 | ] 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "metadata": {}, 84 | "source": [ 85 | "### Limitations:
\n", 86 | "\n", 87 | "If K=n: Example Amazon reviews positive/negative, If there are 50 positive points and 20 negative points and K=n then query point will be classified as Positive as there are more no.of pos points and we are considering K as 'n'.
\n", 88 | "\n", 89 | "It Even fails when no.of Positive points = no.of Negative points, i.e it cannot classify whether its a positive point or negative point.
\n", 90 | "\n", 91 | "Shown in the below image." 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "" 99 | ] 100 | }, 101 | { 102 | "cell_type": "markdown", 103 | "metadata": {}, 104 | "source": [ 105 | "# OverFitting and UnderFitting" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "metadata": {}, 111 | "source": [ 112 | "" 113 | ] 114 | }, 115 | { 116 | "cell_type": "markdown", 117 | "metadata": {}, 118 | "source": [ 119 | "### OverFitting:(K is min)
\n", 120 | "\n", 121 | "In this case we are considering every minute detail i.e considering every data point which is even an Outlier so that we can create a 'Perfect Curve', as we are considering noisy data the results may not be likely.\n", 122 | "\n", 123 | "\n", 124 | "### WellFit:( min < k < max )
\n", 125 | "\n", 126 | "In This Case the noisy data is not considered as K value is more than 1, So its the Curve which is Ideal to deal with, So we need to find this K value so that curve is Well Fit.\n", 127 | "\n", 128 | "\n", 129 | "### UnderFitting:(K is n or max)
\n", 130 | "Here If there are more no.of positive points than negative points then Query point is considered as Positive point, its the worst fit." 131 | ] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "metadata": {}, 136 | "source": [ 137 | "# Cross Validation" 138 | ] 139 | }, 140 | { 141 | "cell_type": "markdown", 142 | "metadata": {}, 143 | "source": [ 144 | "#### How To determine the right K Value?
\n", 145 | "\n", 146 | "Let 'D' be total data set,
\n", 147 | "Its divided into Three Parts:
\n", 148 | "1)D-Train ----------------------------> 70% of DataPoints
\n", 149 | "2)D-CV (Cross Validation) ------------> 10% of DataPoints
\n", 150 | "3)D-Test -----------------------------> 20% of DataPoints
\n", 151 | "\n", 152 | "Note: Division of Data is Our Wish
\n", 153 | "\n", 154 | "Now, Perform the operations below:
\n", 155 | "\n", 156 | "K = 1 --------> apply K-NN on D-Train -------> Check accuracy of this model \n", 157 | " By passing\n", 158 | " D-CV data points to this\n", 159 | " trained model.
\n", 160 | " \n", 161 | "\n", 162 | "K = 2 --------> apply K-NN on D-Train -------> Check accuracy of this model \n", 163 | " By passing\n", 164 | " D-CV data points to this\n", 165 | " trained model.
\n", 166 | " \n", 167 | ".
\n", 168 | ".
\n", 169 | ".
\n", 170 | "\n", 171 | "Until the accuracy starts decreasing.\n" 172 | ] 173 | }, 174 | { 175 | "cell_type": "markdown", 176 | "metadata": {}, 177 | "source": [ 178 | "# K-Fold Cross Validation" 179 | ] 180 | }, 181 | { 182 | "cell_type": "markdown", 183 | "metadata": {}, 184 | "source": [ 185 | "As in the above case We considered 70% datapoints as Train Data and rest 30 as DCV and DTest, But In ML if we have more data more Strong is our Model, so To consider More percent of Data as DTrain We use K-Fold Cross Validation.
\n", 186 | "\n", 187 | "Note: DCV and DTest will be considered as above case only but Dtrain Will change i.e Dtrain will be 80%, This can be achieved by performing below operations." 188 | ] 189 | }, 190 | { 191 | "cell_type": "markdown", 192 | "metadata": {}, 193 | "source": [ 194 | "" 195 | ] 196 | }, 197 | { 198 | "cell_type": "markdown", 199 | "metadata": {}, 200 | "source": [ 201 | "" 202 | ] 203 | }, 204 | { 205 | "cell_type": "markdown", 206 | "metadata": {}, 207 | "source": [ 208 | "So By doing this we are not wasting our data as in the previous technique we have considered DTrain as 70% DCV as 10% and DTest as 20%, here DTrain is 80%, DCV is 80% and DTest is 20%. but DCV and DTrain Doesnt interfer i.e both are different.\n", 209 | "\n", 210 | "In The above case Dtrain, DTest, DCV all three's data points are different at any instance." 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": null, 216 | "metadata": {}, 217 | "outputs": [], 218 | "source": [] 219 | } 220 | ], 221 | "metadata": { 222 | "kernelspec": { 223 | "display_name": "Python 3", 224 | "language": "python", 225 | "name": "python3" 226 | }, 227 | "language_info": { 228 | "codemirror_mode": { 229 | "name": "ipython", 230 | "version": 3 231 | }, 232 | "file_extension": ".py", 233 | "mimetype": "text/x-python", 234 | "name": "python", 235 | "nbconvert_exporter": "python", 236 | "pygments_lexer": "ipython3", 237 | "version": "3.6.4" 238 | } 239 | }, 240 | "nbformat": 4, 241 | "nbformat_minor": 2 242 | } 243 | -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/LSH(Locality_Sensitive_Hashing).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# LSH(Locality Sensitive Hashing) for Cosine Similarity." 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "### Outlook:
\n", 15 | "In this technique we divide the Data Points present in space into Slices like pizza slices then for Each Slice we will calculate Hash value and put all the Data points of one slice into one bucket of hash table, If query point is given its hash value is generated and lookedup in the hash table with the generated value, The value of this key will be the all the data points i.e slice in which query point is present, so We will calculate KNN on these data points instead of calculating KNN on whole data set, so that Time Complexity and Space Complexity are Reduced.
\n", 16 | "\n", 17 | "\n", 18 | "As Said above The space is divided into slices by Planes i.e generate a random Vector (W) with N Dim's which is normal to the plane, for each plane each W is created and Perform
\n", 19 | "(Wi.T * xi) and create a list of length 'M', M is no.of planes which is usually of size lon(n) and if (Wi.T * xi)>=0 insert +1 into list else -1, and this list will be 'key' in the hash table and the value will be All the data points of the slice.
\n", 20 | "\n", 21 | "In (Wi.T * xi) Wi-> planes, xi->data points, This calculation is ntg but it decides if the point is above the plane or below the plane." 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "# LSH(Locality Sensitive Hashing) for Euclidean Distance" 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "Its same as above method with small change In the above case in the list which we have created with 'M' dimensions we have inserted values +1 or -1 depending on (Wi.T * xi) this val, but Here the region number into which the point falls is Inserted. " 36 | ] 37 | }, 38 | { 39 | "cell_type": "markdown", 40 | "metadata": {}, 41 | "source": [ 42 | "### Note:
\n", 43 | "LSH is Randomized Technique i.e It will not give the same value for every computation, So we will calculate no.of Hashes i.e for every iteration we will create different planes and do entire operation each time so that we can cover diff scenarios, by this we will get Stable Plot." 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": null, 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [] 52 | } 53 | ], 54 | "metadata": { 55 | "kernelspec": { 56 | "display_name": "Python 3", 57 | "language": "python", 58 | "name": "python3" 59 | }, 60 | "language_info": { 61 | "codemirror_mode": { 62 | "name": "ipython", 63 | "version": 3 64 | }, 65 | "file_extension": ".py", 66 | "mimetype": "text/x-python", 67 | "name": "python", 68 | "nbconvert_exporter": "python", 69 | "pygments_lexer": "ipython3", 70 | "version": "3.6.4" 71 | } 72 | }, 73 | "nbformat": 4, 74 | "nbformat_minor": 2 75 | } 76 | -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/demo_data/1.ushape.csv: -------------------------------------------------------------------------------- 1 | 3.159499363321345566e-02,9.869877579082642072e-01,0.000000000000000000e+00 2 | 2.115097840005998098e+00,-4.624396793368001912e-02,1.000000000000000000e+00 3 | 8.824897202429525800e-01,-7.575605515192823658e-02,0.000000000000000000e+00 4 | -5.514410395493309081e-02,-3.733245922211456125e-02,1.000000000000000000e+00 5 | 8.295450281029342898e-01,-5.393214930366995175e-01,1.000000000000000000e+00 6 | 2.112857076342865792e+00,6.620835334836001618e-01,1.000000000000000000e+00 7 | 5.696926997602634879e-01,3.374413575291368428e-01,0.000000000000000000e+00 8 | 9.521745361967547394e-01,-7.530747091382108405e-01,1.000000000000000000e+00 9 | -2.922114573667314308e-02,3.928733563262766237e-01,1.000000000000000000e+00 10 | 1.715795573379396366e+00,3.606945394211044098e-01,1.000000000000000000e+00 11 | -2.788301416383404119e-01,6.142053862138131537e-01,1.000000000000000000e+00 12 | 2.003445086685660126e+00,-3.091496039347518821e-01,1.000000000000000000e+00 13 | 1.500096159481413727e+00,-7.463637596324144141e-01,1.000000000000000000e+00 14 | 1.225408349269704544e+00,1.197930168674084639e+00,0.000000000000000000e+00 15 | 4.673081934172612084e-01,5.470319224500304056e-01,0.000000000000000000e+00 16 | -3.665322231763949445e-01,1.119716334184672979e+00,0.000000000000000000e+00 17 | 3.012445942883550942e-01,1.233156971330037432e+00,0.000000000000000000e+00 18 | 3.043074627037069546e-01,8.237393538028817686e-01,0.000000000000000000e+00 19 | -2.371249156395008328e-01,7.787603354698340308e-01,0.000000000000000000e+00 20 | 1.163398317807733617e+00,5.529023837343670644e-01,0.000000000000000000e+00 21 | -5.970241655451735685e-01,6.572360991187755630e-01,0.000000000000000000e+00 22 | 4.635673501248080974e-01,-1.951542983892050054e-01,1.000000000000000000e+00 23 | 6.845111142379667335e-01,7.528768522591495760e-01,0.000000000000000000e+00 24 | 7.051569889057123230e-01,-4.589244400760628118e-01,1.000000000000000000e+00 25 | -6.580500787381697858e-01,-1.294421121982363143e-01,0.000000000000000000e+00 26 | -7.466294632068579684e-01,-3.829632037287942214e-01,0.000000000000000000e+00 27 | 6.058522563968107288e-01,3.125284196699863459e-01,0.000000000000000000e+00 28 | 2.181371683049025290e+00,-2.291746927689475299e-02,1.000000000000000000e+00 29 | 1.919806334070562004e+00,1.724732889634024158e-01,1.000000000000000000e+00 30 | 1.483436402074378879e+00,-1.051702314984633846e-01,1.000000000000000000e+00 31 | 4.740472260478199584e-01,-1.457506719636281201e-01,1.000000000000000000e+00 32 | 1.056146046768832836e+00,-1.035702068049833224e+00,1.000000000000000000e+00 33 | 1.865007322962233038e+00,-1.107873734719251602e-02,1.000000000000000000e+00 34 | 4.194721021516975568e-01,-3.247810115072367054e-01,1.000000000000000000e+00 35 | 6.873257777127617096e-02,5.664846702876994433e-01,1.000000000000000000e+00 36 | -1.733243247632655637e-01,1.002151307685729575e+00,0.000000000000000000e+00 37 | 1.241242064812876911e-01,1.000628918576098814e+00,0.000000000000000000e+00 38 | 1.812114227881840844e-01,2.471774309096053668e-01,1.000000000000000000e+00 39 | -2.545155930677909240e-01,1.931727159301120933e-01,1.000000000000000000e+00 40 | 1.025806681391205011e+00,-6.257456623273742746e-01,1.000000000000000000e+00 41 | 1.520021431031716830e+00,-4.515581275373087289e-02,0.000000000000000000e+00 42 | 6.417403675063451107e-01,-3.936946837063957649e-01,1.000000000000000000e+00 43 | -8.761558871630454881e-01,4.656620251346510475e-02,0.000000000000000000e+00 44 | -1.069649973668143961e+00,1.366602473161631637e-01,0.000000000000000000e+00 45 | 1.026587654482872258e+00,3.778245769022746670e-01,0.000000000000000000e+00 46 | 9.313132543149978959e-01,1.385178411971548895e+00,0.000000000000000000e+00 47 | 6.768054363547377772e-01,1.571899312714103214e+00,0.000000000000000000e+00 48 | -3.688573309732531280e-01,7.288660141702617556e-01,0.000000000000000000e+00 49 | -1.024654954906715432e+00,1.619021463664266358e-01,0.000000000000000000e+00 50 | 7.745538478844521402e-01,1.537580320941234757e-01,0.000000000000000000e+00 51 | 1.404511600814796868e+00,-7.057005138314489945e-03,1.000000000000000000e+00 52 | -3.814717421672545461e-01,-2.348874665349006408e-01,1.000000000000000000e+00 53 | 7.215522446289361902e-01,4.472165750877070134e-01,0.000000000000000000e+00 54 | -5.134668595395711632e-01,6.786909545326080817e-01,0.000000000000000000e+00 55 | 3.211854615031241034e-01,2.866866685419984240e-01,0.000000000000000000e+00 56 | 1.953628037527059547e-01,1.608510651493313959e-01,1.000000000000000000e+00 57 | 5.282419616404990803e-01,9.830099315447119457e-01,0.000000000000000000e+00 58 | -2.216538968943560506e-01,2.516013870512852080e-01,0.000000000000000000e+00 59 | 2.233467635561762754e-01,1.322171826480582402e+00,0.000000000000000000e+00 60 | -1.070457181226829591e-01,5.617832625636306476e-01,1.000000000000000000e+00 61 | 6.365168516040098368e-01,7.544482523438968968e-01,0.000000000000000000e+00 62 | -3.722784784934399238e-01,9.929131660820307292e-01,0.000000000000000000e+00 63 | 2.071808326598170713e-01,-9.767142739891909731e-02,1.000000000000000000e+00 64 | 1.273314190904384913e-01,-3.796548967118948403e-01,1.000000000000000000e+00 65 | 7.143523082580421901e-01,-7.999416121460020124e-01,1.000000000000000000e+00 66 | 1.094878136347054998e+00,-3.684184482190744347e-01,1.000000000000000000e+00 67 | -1.481436228328241178e-01,9.615865686187115013e-01,0.000000000000000000e+00 68 | 1.586187998577996972e+00,-6.298451656162282752e-01,1.000000000000000000e+00 69 | 7.444455063252204408e-01,5.766137068632283258e-01,0.000000000000000000e+00 70 | 2.180110277730073598e+00,-6.997775077802520505e-01,1.000000000000000000e+00 71 | 2.457559354815964103e-01,8.496383011786972084e-01,0.000000000000000000e+00 72 | -9.500358136002062803e-01,9.036169893360138650e-01,0.000000000000000000e+00 73 | -8.823075833032376636e-01,7.249044196648242455e-02,0.000000000000000000e+00 74 | 2.022970787506752632e+00,1.232514823244950652e-01,1.000000000000000000e+00 75 | 2.145773210175075274e+00,4.629636173144290878e-01,1.000000000000000000e+00 76 | 3.553646839272793789e-01,-6.784798863681882342e-01,1.000000000000000000e+00 77 | 3.466502588474150715e-01,1.115706761193445029e+00,0.000000000000000000e+00 78 | 1.739237300610891879e+00,4.590035242014501304e-01,1.000000000000000000e+00 79 | 6.385646696350306684e-01,-4.471844341651154409e-01,1.000000000000000000e+00 80 | 1.287668701134548455e+00,-4.910366009324704795e-01,1.000000000000000000e+00 81 | -1.377260693484619047e-01,1.245326198712558785e+00,0.000000000000000000e+00 82 | -5.617530312161083117e-01,1.054860510060877887e+00,0.000000000000000000e+00 83 | 1.290037479098052442e+00,-2.069140475048650007e-01,1.000000000000000000e+00 84 | -8.753936535485004056e-01,5.054342299267167160e-01,0.000000000000000000e+00 85 | -9.285824919481816542e-01,-4.563199052393643873e-01,0.000000000000000000e+00 86 | 2.493632078646507155e-02,1.074795833868681938e-01,1.000000000000000000e+00 87 | 1.972558991834818531e-01,-6.801667981997078227e-02,1.000000000000000000e+00 88 | 7.334605649545697936e-01,2.816192880885117211e-01,0.000000000000000000e+00 89 | 1.682944338271429530e+00,-2.020423031727686392e-01,1.000000000000000000e+00 90 | 5.076412403964466469e-01,-1.173197933475253474e-01,1.000000000000000000e+00 91 | 1.667602174755152822e+00,-4.248566522717369676e-01,1.000000000000000000e+00 92 | -8.217228210436642311e-01,6.314106629162008488e-01,0.000000000000000000e+00 93 | 3.017090266430521028e-01,7.860353394551198303e-01,0.000000000000000000e+00 94 | 1.376715047058109320e+00,-8.091510741803735751e-01,1.000000000000000000e+00 95 | 1.170375508314319912e+00,5.984065269053864267e-01,0.000000000000000000e+00 96 | 1.699453094326453195e+00,5.877196698165860766e-01,1.000000000000000000e+00 97 | 2.186232335250059000e-01,-6.525211867631453000e-01,1.000000000000000000e+00 98 | 9.529142847496185897e-01,-4.197656395767486170e-01,1.000000000000000000e+00 99 | -1.318500344394381019e+00,4.231123496153353924e-01,0.000000000000000000e+00 100 | -1.296817644442520123e+00,1.841470902307968671e-01,0.000000000000000000e+00 101 | -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/demo_data/2.concerticcir1.csv: -------------------------------------------------------------------------------- 1 | -3.828911738602102099e-01,-9.084004237811005300e-02,1.000000000000000000e+00 2 | -2.096229060118734444e-02,-4.778741558510644083e-01,1.000000000000000000e+00 3 | -3.961159621497807870e-01,-1.289426942412771115e+00,0.000000000000000000e+00 4 | -6.181301837811659095e-01,-6.383715022671060391e-02,1.000000000000000000e+00 5 | 7.034783759088518718e-01,-1.870383680999883058e-01,1.000000000000000000e+00 6 | -4.597046341500667932e-01,6.947746536502913406e-01,0.000000000000000000e+00 7 | -4.509168151319991047e-01,-7.157052357026995049e-01,0.000000000000000000e+00 8 | -4.556200447837268075e-01,-1.340601561295691191e-01,1.000000000000000000e+00 9 | -2.651390428962208112e-01,4.081287134881198542e-01,1.000000000000000000e+00 10 | -1.547464788798145197e-01,4.140697330504542473e-01,1.000000000000000000e+00 11 | 2.312059976302998643e-01,-5.327589929312029904e-01,1.000000000000000000e+00 12 | 1.562387538667342479e-01,-8.678087959146379982e-01,0.000000000000000000e+00 13 | 5.164754088213727723e-01,4.894099515623506758e-01,1.000000000000000000e+00 14 | 6.870700669548217565e-01,-2.334129271349616452e-02,1.000000000000000000e+00 15 | 5.475986850653906668e-01,-1.648237288163639236e-01,1.000000000000000000e+00 16 | -3.217957207127715158e-01,-8.055353563951547224e-01,0.000000000000000000e+00 17 | -1.074786391852546208e+00,-7.333620008863706019e-01,0.000000000000000000e+00 18 | 7.675845492733637254e-01,-4.349878312955712811e-01,0.000000000000000000e+00 19 | -4.747523436963354548e-01,-3.381318601057874407e-01,1.000000000000000000e+00 20 | 1.542065566257118103e-01,1.073060318223337140e+00,0.000000000000000000e+00 21 | 6.591669593400859561e-01,2.077363413668956715e-01,0.000000000000000000e+00 22 | -7.779500271637578290e-01,1.326554985671240805e-01,1.000000000000000000e+00 23 | 4.702545410708354745e-01,-3.122874753919116508e-01,1.000000000000000000e+00 24 | -4.246799088786083753e-02,2.655544606295164312e-01,1.000000000000000000e+00 25 | -7.240595430250984510e-01,4.880718549196249034e-01,0.000000000000000000e+00 26 | -3.696000549180210593e-01,-1.065140282112972958e+00,0.000000000000000000e+00 27 | 1.783332738249141514e-01,-4.971897241531270106e-01,1.000000000000000000e+00 28 | -9.392786432969637556e-01,-4.195163753548514785e-01,0.000000000000000000e+00 29 | 5.091415177797765645e-01,-7.097746675138559835e-01,0.000000000000000000e+00 30 | -5.569852006012616930e-02,-8.216260724131693172e-01,0.000000000000000000e+00 31 | -1.121457892534244438e-01,7.219704398744608564e-01,1.000000000000000000e+00 32 | 8.046392140975882068e-01,-1.522129552070076441e-01,1.000000000000000000e+00 33 | 8.261487280609236539e-02,-1.174902097578534588e-01,1.000000000000000000e+00 34 | 2.034954115001688379e-01,-3.739678935557311790e-01,1.000000000000000000e+00 35 | 1.386469331887233980e-01,-2.390564213390756754e-01,1.000000000000000000e+00 36 | 3.278530715455694744e-01,-1.007690373334440448e+00,0.000000000000000000e+00 37 | 8.894406123385016905e-01,-3.911762808785548273e-01,0.000000000000000000e+00 38 | -5.837947262909021218e-02,2.848703867476858331e-01,1.000000000000000000e+00 39 | -1.067365296106876027e+00,2.204005982162877131e-01,0.000000000000000000e+00 40 | -6.007134457729654820e-01,-6.954518933410470671e-01,0.000000000000000000e+00 41 | -3.972324037760179005e-02,-4.093605593635569750e-01,1.000000000000000000e+00 42 | 3.974208510485954249e-01,2.062116236212662712e-01,1.000000000000000000e+00 43 | -3.694115367189275689e-01,1.298110326829030048e-02,1.000000000000000000e+00 44 | 3.573702759174757215e-02,4.666622872439885605e-01,0.000000000000000000e+00 45 | -5.681499890870698177e-01,-4.128841892948301728e-01,1.000000000000000000e+00 46 | 4.104729914097019483e-01,-7.364086765512785071e-01,0.000000000000000000e+00 47 | 8.824970659226714087e-01,-6.900440415525347371e-01,0.000000000000000000e+00 48 | 6.579821735790389314e-02,-5.045839482894732830e-01,1.000000000000000000e+00 49 | -7.573722298764056227e-01,-7.240280057904840971e-02,0.000000000000000000e+00 50 | 1.831696614176975269e-01,8.722006644173714573e-02,1.000000000000000000e+00 51 | 6.724831385082246094e-01,-4.189266508845179704e-01,0.000000000000000000e+00 52 | 2.589872313936384396e-01,3.968864517685565252e-01,1.000000000000000000e+00 53 | -1.131298296892087940e+00,4.810614005977202345e-01,0.000000000000000000e+00 54 | 1.059284404233769017e+00,6.449028673879386719e-01,0.000000000000000000e+00 55 | 4.101966268999728826e-01,3.879019832912261601e-01,1.000000000000000000e+00 56 | 9.514202917293155259e-01,-4.089982645716697118e-02,0.000000000000000000e+00 57 | -6.049298779492366940e-01,4.395090642176294748e-01,0.000000000000000000e+00 58 | 2.331476157773189894e-01,-8.178571103935092790e-01,1.000000000000000000e+00 59 | 9.106733145141466812e-01,3.070207542307892279e-01,0.000000000000000000e+00 60 | -4.502647182093109657e-01,-3.724103905968392803e-02,1.000000000000000000e+00 61 | -8.139612106103979450e-01,-6.473395934969226051e-01,0.000000000000000000e+00 62 | -2.319133844618320450e-01,5.053399243940082108e-01,1.000000000000000000e+00 63 | -5.976098250012880087e-01,2.802316809234396966e-01,1.000000000000000000e+00 64 | 7.396016572034366243e-01,-8.427028053995542223e-01,0.000000000000000000e+00 65 | 5.729465935036953672e-01,-3.119892761550970284e-01,0.000000000000000000e+00 66 | 2.482113254768641419e-01,-5.478450903300359220e-01,1.000000000000000000e+00 67 | 5.212780193736283874e-01,9.410800532390148909e-01,0.000000000000000000e+00 68 | 3.397319842618129471e-01,1.060997846437403136e-01,1.000000000000000000e+00 69 | 1.053390357534016442e+00,-2.197592862029202482e-02,0.000000000000000000e+00 70 | 1.327465868041982633e-02,-6.337950167400366874e-01,1.000000000000000000e+00 71 | 2.422589022457533603e-01,4.903206374725526118e-01,1.000000000000000000e+00 72 | -8.926661173065930655e-01,6.345075979165555324e-01,0.000000000000000000e+00 73 | 1.672566036937978562e-01,2.354846161226166745e-01,1.000000000000000000e+00 74 | -5.611704670612876339e-02,3.883409921252401475e-01,1.000000000000000000e+00 75 | 8.469548600275456085e-01,8.143581098121059902e-01,0.000000000000000000e+00 76 | 2.997619526162534909e-01,-7.943030735271219833e-02,1.000000000000000000e+00 77 | -1.404762043460740517e-01,7.248603242634668042e-01,0.000000000000000000e+00 78 | -5.482024060525886311e-02,1.841732833343766862e-01,1.000000000000000000e+00 79 | -2.464388447432506180e-01,-4.328333677022815351e-01,1.000000000000000000e+00 80 | -2.346064540878696203e-01,6.409441977220393660e-01,0.000000000000000000e+00 81 | -1.131848931379264345e+00,-6.196494237218049816e-01,0.000000000000000000e+00 82 | -9.241382098445175552e-01,-4.530208919773014986e-01,0.000000000000000000e+00 83 | 2.225745046281891737e-01,7.705259659342518219e-01,0.000000000000000000e+00 84 | -6.945376523420367931e-01,5.301414731009287395e-01,0.000000000000000000e+00 85 | -1.036250899510139378e+00,7.733996472325201932e-01,0.000000000000000000e+00 86 | 5.188058511368854875e-01,3.015223208297168056e-01,1.000000000000000000e+00 87 | -7.742954098262425644e-01,2.553766931152208833e-02,0.000000000000000000e+00 88 | 7.146832644296318149e-01,5.686901478327923698e-01,0.000000000000000000e+00 89 | -3.387527378078334928e-01,4.682606327836119076e-01,1.000000000000000000e+00 90 | -3.474924425636272129e-01,1.344141761290389980e-01,1.000000000000000000e+00 91 | 1.129807963603577603e+00,4.281936260310230391e-02,0.000000000000000000e+00 92 | -3.830897937264843844e-01,7.911681228258917731e-01,0.000000000000000000e+00 93 | -7.425140597242434193e-02,2.184624982833010542e-01,1.000000000000000000e+00 94 | -4.494520248082683467e-01,-5.722265738641826860e-02,1.000000000000000000e+00 95 | 8.578328755550748141e-01,6.377888778176594720e-01,0.000000000000000000e+00 96 | -4.748620338912356020e-01,-2.249811220793074829e-01,1.000000000000000000e+00 97 | 1.262724332365476321e-01,8.697841238487512561e-01,0.000000000000000000e+00 98 | -6.473645756890735736e-01,-3.634243739531914930e-01,1.000000000000000000e+00 99 | 4.744045874153203224e-01,1.011015845865479656e+00,0.000000000000000000e+00 100 | -3.856577212802564381e-01,-8.103118329773687512e-01,0.000000000000000000e+00 101 | -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/demo_data/4.linearsep.csv: -------------------------------------------------------------------------------- 1 | -1.774965779898558527e-01,9.304962660386675299e-01,1.000000000000000000e+00 2 | 1.977424058719914779e+00,1.766155293485646371e+00,0.000000000000000000e+00 3 | 1.800023793920340509e+00,1.700342797185373511e+00,0.000000000000000000e+00 4 | -7.708368567582637443e-01,2.359163483274678619e+00,1.000000000000000000e+00 5 | -3.080090137780033821e-01,1.594063156240643098e+00,1.000000000000000000e+00 6 | 6.147214057742914628e-01,2.434898235370948072e+00,1.000000000000000000e+00 7 | 1.090943101035112273e+00,2.216634021089654016e+00,0.000000000000000000e+00 8 | -8.348895413310100100e-01,2.358688750248903787e+00,1.000000000000000000e+00 9 | 2.479464994607870842e+00,1.334189672185075004e+00,0.000000000000000000e+00 10 | 1.199265974174295257e+00,1.826813922878029350e+00,1.000000000000000000e+00 11 | 2.185061835186317136e+00,8.226874969283189953e-01,0.000000000000000000e+00 12 | 1.684232026065965782e+00,1.041131097355358026e+00,0.000000000000000000e+00 13 | 1.146211348679538666e+00,2.070485267927013595e+00,0.000000000000000000e+00 14 | 1.355969451792044644e+00,5.680249816835929444e-01,0.000000000000000000e+00 15 | 1.385207480422569137e+00,1.826072384846579855e+00,0.000000000000000000e+00 16 | 1.867292166552691368e+00,1.186926990211513822e+00,0.000000000000000000e+00 17 | 3.122737560105236510e-01,2.246053532298049937e+00,1.000000000000000000e+00 18 | -8.183483649778811042e-02,1.700655112374142020e+00,1.000000000000000000e+00 19 | 9.048447162452653014e-01,2.606830160734105561e+00,1.000000000000000000e+00 20 | -4.358608976285560654e-01,2.015141400218765977e+00,1.000000000000000000e+00 21 | 8.144119636882038993e-01,2.135467843821274414e+00,1.000000000000000000e+00 22 | 3.108743116165684661e+00,2.267865043649954337e+00,0.000000000000000000e+00 23 | -2.557421694500754406e-01,1.712811456067370841e+00,1.000000000000000000e+00 24 | 1.886630270530996523e+00,2.720895134840621843e+00,0.000000000000000000e+00 25 | 2.295035469724568955e+00,3.892677587182644672e+00,0.000000000000000000e+00 26 | -1.141562624026013495e-01,8.559335743499960625e-01,1.000000000000000000e+00 27 | 1.697035367840272091e+00,3.477177988234282591e+00,0.000000000000000000e+00 28 | 1.838557751539753760e+00,9.266721259907292341e-01,0.000000000000000000e+00 29 | 1.602988071656992641e+00,1.301843598872431951e+00,0.000000000000000000e+00 30 | 1.138032150157472611e+00,2.829550071364288044e+00,1.000000000000000000e+00 31 | 5.700273793343100248e-01,1.822024689866410085e+00,1.000000000000000000e+00 32 | 2.513017189624151548e-01,1.322250481643853837e+00,1.000000000000000000e+00 33 | -3.983307826628607051e-01,1.984344997008685940e+00,1.000000000000000000e+00 34 | 1.629132603977066163e+00,8.816818237799028957e-01,0.000000000000000000e+00 35 | 3.105035853801514811e+00,1.740006329741113689e+00,0.000000000000000000e+00 36 | -5.668735947146341658e-03,1.120390406582786991e+00,1.000000000000000000e+00 37 | 1.368665571630571565e+00,2.139644376435396289e+00,0.000000000000000000e+00 38 | 2.698399612481068299e+00,3.549323823792247090e+00,0.000000000000000000e+00 39 | 2.001708378027932334e+00,1.098623139012122607e+00,0.000000000000000000e+00 40 | 2.436277083831795309e+00,1.437694756271542307e+00,0.000000000000000000e+00 41 | -3.099693757090293822e-01,9.125644420984648786e-01,1.000000000000000000e+00 42 | 8.528147847486300392e-02,1.722860964695664965e+00,1.000000000000000000e+00 43 | 2.062358034643298588e+00,1.603515287454766902e+00,0.000000000000000000e+00 44 | 1.610269843336894713e+00,2.068993077936323921e+00,0.000000000000000000e+00 45 | 1.398759141001534534e+00,6.929503354994610564e-01,1.000000000000000000e+00 46 | 1.684171952121574778e+00,1.054990758030300402e+00,0.000000000000000000e+00 47 | 6.032636952024524879e-01,2.186250564240889371e+00,1.000000000000000000e+00 48 | -8.009040540807352837e-01,1.898739987887355429e+00,1.000000000000000000e+00 49 | 2.286229055698735024e+00,2.004851988947004671e+00,0.000000000000000000e+00 50 | -1.081077375616385616e+00,2.775077844910318170e+00,1.000000000000000000e+00 51 | 6.731464992893574362e-01,1.083744532546206507e+00,1.000000000000000000e+00 52 | 2.969705764781013890e+00,2.123229129246612779e+00,0.000000000000000000e+00 53 | 6.795066838796897102e-01,2.098642739513909117e+00,1.000000000000000000e+00 54 | -4.478117660940801326e-01,3.184203720390454961e+00,1.000000000000000000e+00 55 | -5.003385420029125008e-01,2.021055306383067851e+00,1.000000000000000000e+00 56 | 1.853071177060094721e+00,3.666124956341999308e+00,0.000000000000000000e+00 57 | 1.721864236857777231e+00,1.780558741729883376e+00,0.000000000000000000e+00 58 | 2.250334831878852526e+00,3.121431119277734201e+00,0.000000000000000000e+00 59 | 3.135690796092169830e-01,1.351279486529370910e+00,1.000000000000000000e+00 60 | -2.841069052814206852e-01,1.857273044804755191e+00,1.000000000000000000e+00 61 | 2.129156564328551049e+00,2.584631266530066807e+00,0.000000000000000000e+00 62 | 1.576422703102946521e+00,2.019872822311515215e+00,0.000000000000000000e+00 63 | -1.078195491779146087e+00,1.401474050532345306e+00,1.000000000000000000e+00 64 | 1.197681188039566580e+00,2.402490745788781190e+00,0.000000000000000000e+00 65 | 1.376901121367063885e+00,1.149858415798459266e+00,0.000000000000000000e+00 66 | -1.660064884699084864e+00,1.463134737166496002e+00,1.000000000000000000e+00 67 | 1.243900114922203759e+00,1.460046281048402061e+00,0.000000000000000000e+00 68 | 1.879223047046559625e+00,1.722623141704533234e+00,0.000000000000000000e+00 69 | 2.908507911078423103e+00,2.941591450737263358e+00,0.000000000000000000e+00 70 | -4.812261291629479354e-01,1.791437619908470502e+00,1.000000000000000000e+00 71 | 2.437430404747939150e+00,1.345353314595293170e+00,0.000000000000000000e+00 72 | 2.565798740945202105e+00,9.933435817717286564e-01,0.000000000000000000e+00 73 | 2.448992408843662094e+00,2.490727267490959740e+00,0.000000000000000000e+00 74 | 4.603424688115833607e-01,6.840261153626066015e-01,1.000000000000000000e+00 75 | -3.906826803657038605e-01,2.132233005519266200e+00,1.000000000000000000e+00 76 | -1.266765944159567558e+00,1.156063813239409654e+00,1.000000000000000000e+00 77 | 1.418826938851164510e+00,2.571545267687625369e+00,0.000000000000000000e+00 78 | -5.676043617011623521e-01,9.901022939191341798e-01,1.000000000000000000e+00 79 | -1.801737447070235199e+00,1.231491323532391657e+00,1.000000000000000000e+00 80 | 1.803590606052267731e-01,1.255877974195551028e+00,1.000000000000000000e+00 81 | 2.852717658438677972e+00,1.845205605055966869e+00,0.000000000000000000e+00 82 | 1.845887234057941306e+00,1.150837334162890802e+00,0.000000000000000000e+00 83 | 2.233285696103223028e+00,3.152813902136283097e+00,0.000000000000000000e+00 84 | -5.501804398209573232e-01,1.081691471630426893e+00,1.000000000000000000e+00 85 | -7.908902086462197278e-01,1.650855213986880621e+00,1.000000000000000000e+00 86 | -1.319932910875936116e-01,1.940077956506024215e+00,1.000000000000000000e+00 87 | 7.025725688316544204e-01,1.357012961600498446e+00,0.000000000000000000e+00 88 | 2.767215468587310712e-01,2.672986681801555520e+00,1.000000000000000000e+00 89 | 6.102158686229843809e-01,2.165148599216429215e+00,1.000000000000000000e+00 90 | -5.300036754118879756e-01,2.019431636896686921e+00,1.000000000000000000e+00 91 | 1.837278877763967477e+00,2.111012897719438008e+00,0.000000000000000000e+00 92 | 2.841601916945832862e-01,2.644929637261184574e+00,1.000000000000000000e+00 93 | 1.896883789441271784e+00,2.260446930472400418e+00,0.000000000000000000e+00 94 | 2.068136134818725047e+00,2.610166904605157434e+00,0.000000000000000000e+00 95 | -1.722741267563606682e+00,1.279076521554840085e+00,1.000000000000000000e+00 96 | 2.632381606575672883e+00,1.271305076028492298e+00,0.000000000000000000e+00 97 | -4.025573878955279739e-02,1.782708097172356787e+00,1.000000000000000000e+00 98 | -7.874531842525254177e-01,1.400356884878678709e+00,1.000000000000000000e+00 99 | 2.702441156473601502e+00,1.587443580131801202e+00,0.000000000000000000e+00 100 | 1.290969301992858087e+00,2.751936730055132507e+00,1.000000000000000000e+00 101 | -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/demo_data/6.overlap.csv: -------------------------------------------------------------------------------- 1 | 7,3.2,0 2 | 6.4,3.2,0 3 | 6.9,3.1,0 4 | 5.5,2.3,0 5 | 6.5,2.8,0 6 | 5.7,2.8,0 7 | 6.3,3.3,0 8 | 4.9,2.4,0 9 | 6.6,2.9,0 10 | 5.2,2.7,0 11 | 5,2,0 12 | 5.9,3,0 13 | 6,2.2,0 14 | 6.1,2.9,0 15 | 5.6,2.9,0 16 | 6.7,3.1,0 17 | 5.6,3,0 18 | 5.8,2.7,0 19 | 6.2,2.2,0 20 | 5.6,2.5,0 21 | 5.9,3.2,0 22 | 6.1,2.8,0 23 | 6.3,2.5,0 24 | 6.1,2.8,0 25 | 6.4,2.9,0 26 | 6.6,3,0 27 | 6.8,2.8,0 28 | 6.7,3,0 29 | 6,2.9,0 30 | 5.7,2.6,0 31 | 5.5,2.4,0 32 | 5.5,2.4,0 33 | 5.8,2.7,0 34 | 6,2.7,0 35 | 5.4,3,0 36 | 6,3.4,0 37 | 6.7,3.1,0 38 | 6.3,2.3,0 39 | 5.6,3,0 40 | 5.5,2.5,0 41 | 5.5,2.6,0 42 | 6.1,3,0 43 | 5.8,2.6,0 44 | 5,2.3,0 45 | 5.6,2.7,0 46 | 5.7,3,0 47 | 5.7,2.9,0 48 | 6.2,2.9,0 49 | 5.1,2.5,0 50 | 5.7,2.8,0 51 | 6.3,3.3,1 52 | 5.8,2.7,1 53 | 7.1,3,1 54 | 6.3,2.9,1 55 | 6.5,3,1 56 | 7.6,3,1 57 | 4.9,2.5,1 58 | 7.3,2.9,1 59 | 6.7,2.5,1 60 | 7.2,3.6,1 61 | 6.5,3.2,1 62 | 6.4,2.7,1 63 | 6.8,3,1 64 | 5.7,2.5,1 65 | 5.8,2.8,1 66 | 6.4,3.2,1 67 | 6.5,3,1 68 | 7.7,3.8,1 69 | 7.7,2.6,1 70 | 6,2.2,1 71 | 6.9,3.2,1 72 | 5.6,2.8,1 73 | 7.7,2.8,1 74 | 6.3,2.7,1 75 | 6.7,3.3,1 76 | 7.2,3.2,1 77 | 6.2,2.8,1 78 | 6.1,3,1 79 | 6.4,2.8,1 80 | 7.2,3,1 81 | 7.4,2.8,1 82 | 7.9,3.8,1 83 | 6.4,2.8,1 84 | 6.3,2.8,1 85 | 6.1,2.6,1 86 | 7.7,3,1 87 | 6.3,3.4,1 88 | 6.4,3.1,1 89 | 6,3,1 90 | 6.9,3.1,1 91 | 6.7,3.1,1 92 | 6.9,3.1,1 93 | 5.8,2.7,1 94 | 6.8,3.2,1 95 | 6.7,3.3,1 96 | 6.7,3,1 97 | 6.3,2.5,1 98 | 6.5,3,1 99 | 6.2,3.4,1 100 | 5.9,3,1 101 | -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/demo_data/meshgrid_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/KNN(K-NearestNeighbour)_Classification_n_Regression/demo_data/meshgrid_image.png -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn1.PNG -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn2.PNG -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn3.PNG -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn4.PNG -------------------------------------------------------------------------------- /KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/KNN(K-NearestNeighbour)_Classification_n_Regression/images/knn5.PNG -------------------------------------------------------------------------------- /LinearRegression/SGD_LinearRegressionAssignment(Implementing_our_ownLR)/SGD_on_LinearRegression.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/LinearRegression/SGD_LinearRegressionAssignment(Implementing_our_ownLR)/SGD_on_LinearRegression.pdf -------------------------------------------------------------------------------- /Lists_Sets_Tuples_Dict_Py.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Lists in Python" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "### 1)Multiple items with different data types can be stored in lists\n", 15 | "### 2)They are mutable" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 1, 21 | "metadata": {}, 22 | "outputs": [ 23 | { 24 | "name": "stdout", 25 | "output_type": "stream", 26 | "text": [ 27 | "[1, 2.2, 1, 'Akarsh', True]\n" 28 | ] 29 | } 30 | ], 31 | "source": [ 32 | "a = [1,2.2,1,\"Akarsh\",True]\n", 33 | "print(a)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 2, 39 | "metadata": {}, 40 | "outputs": [ 41 | { 42 | "name": "stdout", 43 | "output_type": "stream", 44 | "text": [ 45 | "[10.1, 2.2, 1, 'Akarsh', True]\n", 46 | "1\n" 47 | ] 48 | } 49 | ], 50 | "source": [ 51 | "a[0]=10.1\n", 52 | "\n", 53 | "print(a);\n", 54 | "\n", 55 | "print(a[2])" 56 | ] 57 | }, 58 | { 59 | "cell_type": "markdown", 60 | "metadata": {}, 61 | "source": [ 62 | "# Tuples in Python" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "metadata": {}, 68 | "source": [ 69 | "### 1)They are immutable \n", 70 | "### 2)They are represented in ( )" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": 18, 76 | "metadata": {}, 77 | "outputs": [ 78 | { 79 | "name": "stdout", 80 | "output_type": "stream", 81 | "text": [ 82 | "(1, 1, 2.2, 'Akarsh')\n", 83 | "1\n" 84 | ] 85 | } 86 | ], 87 | "source": [ 88 | "a=(1,1,2.2,\"Akarsh\")\n", 89 | "print(a)\n", 90 | "\n", 91 | "print(a[1])" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": 12, 97 | "metadata": {}, 98 | "outputs": [ 99 | { 100 | "ename": "TypeError", 101 | "evalue": "'tuple' object does not support item assignment", 102 | "output_type": "error", 103 | "traceback": [ 104 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 105 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 106 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m2.3\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m#as they are immutable the elements cannot be modified\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", 107 | "\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment" 108 | ] 109 | } 110 | ], 111 | "source": [ 112 | "a[1]=2.3\n", 113 | "print(a) #as they are immutable the elements cannot be modified" 114 | ] 115 | }, 116 | { 117 | "cell_type": "markdown", 118 | "metadata": {}, 119 | "source": [ 120 | "# Sets in Py" 121 | ] 122 | }, 123 | { 124 | "cell_type": "markdown", 125 | "metadata": {}, 126 | "source": [ 127 | "### 1)Not Ordered\n", 128 | "### 2)Represented by { }\n", 129 | "### 3)Doesn't allow Duplicate values \n", 130 | "### 4)As its unorderd accessing through index is not possible." 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": 20, 136 | "metadata": {}, 137 | "outputs": [ 138 | { 139 | "name": "stdout", 140 | "output_type": "stream", 141 | "text": [ 142 | "{1, 2.2, 'Akarsh'}\n" 143 | ] 144 | } 145 | ], 146 | "source": [ 147 | "a = {1,1,2.2,\"Akarsh\"}\n", 148 | "print(a)" 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": 22, 154 | "metadata": {}, 155 | "outputs": [ 156 | { 157 | "ename": "TypeError", 158 | "evalue": "'set' object does not support indexing", 159 | "output_type": "error", 160 | "traceback": [ 161 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 162 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 163 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 164 | "\u001b[1;31mTypeError\u001b[0m: 'set' object does not support indexing" 165 | ] 166 | } 167 | ], 168 | "source": [ 169 | "print(a[1])" 170 | ] 171 | }, 172 | { 173 | "cell_type": "markdown", 174 | "metadata": {}, 175 | "source": [ 176 | "# Dictionary in Py" 177 | ] 178 | }, 179 | { 180 | "cell_type": "markdown", 181 | "metadata": {}, 182 | "source": [ 183 | "### 1)Unordered collection of Key-Value Pairs\n", 184 | "### 2)Represented as {\"key\" : \"Value\" , \"key\" : \"Value\" }" 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": 26, 190 | "metadata": {}, 191 | "outputs": [ 192 | { 193 | "name": "stdout", 194 | "output_type": "stream", 195 | "text": [ 196 | "{'a': 'Akarsh', 'b': 'Bachu'}\n" 197 | ] 198 | } 199 | ], 200 | "source": [ 201 | "x = {'a':\"Akarsh\", \"b\":\"Bachu\"}\n", 202 | "\n", 203 | "print(x)\n" 204 | ] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": 31, 209 | "metadata": {}, 210 | "outputs": [ 211 | { 212 | "name": "stdout", 213 | "output_type": "stream", 214 | "text": [ 215 | "Akarsh\n" 216 | ] 217 | } 218 | ], 219 | "source": [ 220 | "print(x[\"a\"])" 221 | ] 222 | }, 223 | { 224 | "cell_type": "markdown", 225 | "metadata": {}, 226 | "source": [ 227 | "# Conversions" 228 | ] 229 | }, 230 | { 231 | "cell_type": "code", 232 | "execution_count": 33, 233 | "metadata": {}, 234 | "outputs": [ 235 | { 236 | "name": "stdout", 237 | "output_type": "stream", 238 | "text": [ 239 | "[1, 1, 4, 3]\n", 240 | "{1, 3, 4}\n" 241 | ] 242 | } 243 | ], 244 | "source": [ 245 | "a = [1,1,4,3] #List\n", 246 | "\n", 247 | "print(a)\n", 248 | "\n", 249 | "b = set(a) #List is converted to set\n", 250 | "\n", 251 | "print(b)" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": 36, 257 | "metadata": {}, 258 | "outputs": [ 259 | { 260 | "name": "stdout", 261 | "output_type": "stream", 262 | "text": [ 263 | "[1, 3, 4]\n" 264 | ] 265 | } 266 | ], 267 | "source": [ 268 | "c = list(b) #Set to List\n", 269 | "print(c)" 270 | ] 271 | }, 272 | { 273 | "cell_type": "code", 274 | "execution_count": 39, 275 | "metadata": {}, 276 | "outputs": [ 277 | { 278 | "name": "stdout", 279 | "output_type": "stream", 280 | "text": [ 281 | "['A', 'k', 'a', 'r', 's', 'h']\n" 282 | ] 283 | } 284 | ], 285 | "source": [ 286 | "s = \"Akarsh\"\n", 287 | "\n", 288 | "l = list(s) #String to list\n", 289 | "\n", 290 | "print(l)" 291 | ] 292 | }, 293 | { 294 | "cell_type": "code", 295 | "execution_count": 43, 296 | "metadata": {}, 297 | "outputs": [ 298 | { 299 | "name": "stdout", 300 | "output_type": "stream", 301 | "text": [ 302 | "['a', 'b']\n" 303 | ] 304 | } 305 | ], 306 | "source": [ 307 | "d = {\"a\":\"sadas\", \"b\":\"asdas\"} \n", 308 | "\n", 309 | "f = list(d) #keys will be converted to list\n", 310 | "print(f)" 311 | ] 312 | }, 313 | { 314 | "cell_type": "code", 315 | "execution_count": null, 316 | "metadata": { 317 | "collapsed": true 318 | }, 319 | "outputs": [], 320 | "source": [] 321 | } 322 | ], 323 | "metadata": { 324 | "kernelspec": { 325 | "display_name": "Python 3", 326 | "language": "python", 327 | "name": "python3" 328 | }, 329 | "language_info": { 330 | "codemirror_mode": { 331 | "name": "ipython", 332 | "version": 3 333 | }, 334 | "file_extension": ".py", 335 | "mimetype": "text/x-python", 336 | "name": "python", 337 | "nbconvert_exporter": "python", 338 | "pygments_lexer": "ipython3", 339 | "version": "3.6.4" 340 | } 341 | }, 342 | "nbformat": 4, 343 | "nbformat_minor": 2 344 | } 345 | -------------------------------------------------------------------------------- /LogisticRegression/CourseFileLogisticRegression.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stderr", 10 | "output_type": "stream", 11 | "text": [ 12 | "C:\\Users\\Dell\\Anaconda3\\lib\\site-packages\\sklearn\\cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.\n", 13 | " \"This module will be removed in 0.20.\", DeprecationWarning)\n", 14 | "C:\\Users\\Dell\\Anaconda3\\lib\\site-packages\\sklearn\\grid_search.py:42: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. This module will be removed in 0.20.\n", 15 | " DeprecationWarning)\n", 16 | "C:\\Users\\Dell\\Anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_split.py:2026: FutureWarning: From version 0.21, test_size will always complement train_size unless both are specified.\n", 17 | " FutureWarning)\n" 18 | ] 19 | }, 20 | { 21 | "name": "stdout", 22 | "output_type": "stream", 23 | "text": [ 24 | "LogisticRegression(C=100, class_weight=None, dual=False, fit_intercept=True,\n", 25 | " intercept_scaling=1, max_iter=100, multi_class='ovr', n_jobs=1,\n", 26 | " penalty='l2', random_state=None, solver='liblinear', tol=0.0001,\n", 27 | " verbose=0, warm_start=False)\n", 28 | "0.9705882352941176\n" 29 | ] 30 | } 31 | ], 32 | "source": [ 33 | "#code source: http://occam.olin.edu/sites/default/files/DataScienceMaterials/machine_learning_lecture_2/Machine%20Learning%20Lecture%202.html\n", 34 | "from sklearn.model_selection import train_test_split\n", 35 | "from sklearn.grid_search import GridSearchCV\n", 36 | "from sklearn.datasets import *\n", 37 | "from sklearn.linear_model import LogisticRegression\n", 38 | "\n", 39 | "data = load_breast_cancer() #refer: http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_breast_cancer.html#sklearn.datasets.load_breast_cancer\n", 40 | "\n", 41 | "tuned_parameters = [{'C': [10**-4, 10**-2, 10**0, 10**2, 10**4]}]\n", 42 | "X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, train_size=.9)\n", 43 | "\n", 44 | "\n", 45 | "#Using GridSearchCV\n", 46 | "model = GridSearchCV(LogisticRegression(), tuned_parameters, scoring = 'f1', cv=5)\n", 47 | "model.fit(X_train, y_train)\n", 48 | "\n", 49 | "print(model.best_estimator_)\n", 50 | "print(model.score(X_test, y_test))" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 17, 56 | "metadata": {}, 57 | "outputs": [ 58 | { 59 | "name": "stdout", 60 | "output_type": "stream", 61 | "text": [ 62 | "8\n" 63 | ] 64 | } 65 | ], 66 | "source": [ 67 | "# More Sparsity (Fewer elements of W* being non-zero) by increasing Lambda (decreasing C) \n", 68 | "\n", 69 | "import numpy as np\n", 70 | "\n", 71 | "clf = LogisticRegression(C=0.1, penalty='l1');\n", 72 | "clf.fit(X_train, y_train);\n", 73 | "w = clf.coef_\n", 74 | "print(np.count_nonzero(w))\n" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 19, 80 | "metadata": {}, 81 | "outputs": [ 82 | { 83 | "name": "stdout", 84 | "output_type": "stream", 85 | "text": [ 86 | "4\n" 87 | ] 88 | } 89 | ], 90 | "source": [ 91 | "clf = LogisticRegression(C=0.01, penalty='l1');\n", 92 | "clf.fit(X_train, y_train);\n", 93 | "w = clf.coef_\n", 94 | "print(np.count_nonzero(w))\n" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": 21, 100 | "metadata": {}, 101 | "outputs": [ 102 | { 103 | "name": "stdout", 104 | "output_type": "stream", 105 | "text": [ 106 | "3\n" 107 | ] 108 | } 109 | ], 110 | "source": [ 111 | "clf = LogisticRegression(C=0.001, penalty='l1');\n", 112 | "clf.fit(X_train, y_train);\n", 113 | "w = clf.coef_\n", 114 | "print(np.count_nonzero(w))\n" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": 22, 120 | "metadata": {}, 121 | "outputs": [ 122 | { 123 | "name": "stdout", 124 | "output_type": "stream", 125 | "text": [ 126 | "15\n" 127 | ] 128 | } 129 | ], 130 | "source": [ 131 | "clf = LogisticRegression(C=10, penalty='l1');\n", 132 | "clf.fit(X_train, y_train);\n", 133 | "w = clf.coef_\n", 134 | "print(np.count_nonzero(w))" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": null, 140 | "metadata": { 141 | "collapsed": true 142 | }, 143 | "outputs": [], 144 | "source": [] 145 | } 146 | ], 147 | "metadata": { 148 | "kernelspec": { 149 | "display_name": "Python 3", 150 | "language": "python", 151 | "name": "python3" 152 | }, 153 | "language_info": { 154 | "codemirror_mode": { 155 | "name": "ipython", 156 | "version": 3 157 | }, 158 | "file_extension": ".py", 159 | "mimetype": "text/x-python", 160 | "name": "python", 161 | "nbconvert_exporter": "python", 162 | "pygments_lexer": "ipython3", 163 | "version": "3.6.4" 164 | } 165 | }, 166 | "nbformat": 4, 167 | "nbformat_minor": 2 168 | } 169 | -------------------------------------------------------------------------------- /LogisticRegression/LogisticRegression.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Logistic Regression" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "### Please check the explanations and Theory in the hard copy/notebook" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": null, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [] 23 | } 24 | ], 25 | "metadata": { 26 | "kernelspec": { 27 | "display_name": "Python 3", 28 | "language": "python", 29 | "name": "python3" 30 | }, 31 | "language_info": { 32 | "codemirror_mode": { 33 | "name": "ipython", 34 | "version": 3 35 | }, 36 | "file_extension": ".py", 37 | "mimetype": "text/x-python", 38 | "name": "python", 39 | "nbconvert_exporter": "python", 40 | "pygments_lexer": "ipython3", 41 | "version": "3.6.4" 42 | } 43 | }, 44 | "nbformat": 4, 45 | "nbformat_minor": 2 46 | } 47 | -------------------------------------------------------------------------------- /LogisticRegression/NBayesLogReg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/LogisticRegression/NBayesLogReg.pdf -------------------------------------------------------------------------------- /LogisticRegression/Untitled.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 2 6 | } 7 | -------------------------------------------------------------------------------- /Modules_Py.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Modules" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 2, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stdout", 17 | "output_type": "stream", 18 | "text": [ 19 | "3.141592653589793\n" 20 | ] 21 | } 22 | ], 23 | "source": [ 24 | "import math\n", 25 | "\n", 26 | "print(math.pi)" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 3, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "name": "stdout", 36 | "output_type": "stream", 37 | "text": [ 38 | "3.141592653589793\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "import math as m\n", 44 | "\n", 45 | "print(m.pi);" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 12, 51 | "metadata": {}, 52 | "outputs": [ 53 | { 54 | "name": "stdout", 55 | "output_type": "stream", 56 | "text": [ 57 | "2018-02-11 19:02:50.529877\n" 58 | ] 59 | } 60 | ], 61 | "source": [ 62 | "import datetime as dt;\n", 63 | "print(dt.datetime.now());\n" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 13, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "name": "stdout", 73 | "output_type": "stream", 74 | "text": [ 75 | "2018-02-11 19:03:41.590263\n" 76 | ] 77 | } 78 | ], 79 | "source": [ 80 | "from datetime import datetime as dt;\n", 81 | "\n", 82 | "print(dt.now());" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": 15, 88 | "metadata": {}, 89 | "outputs": [ 90 | { 91 | "data": { 92 | "text/plain": [ 93 | "['__doc__',\n", 94 | " '__loader__',\n", 95 | " '__name__',\n", 96 | " '__package__',\n", 97 | " '__spec__',\n", 98 | " 'acos',\n", 99 | " 'acosh',\n", 100 | " 'asin',\n", 101 | " 'asinh',\n", 102 | " 'atan',\n", 103 | " 'atan2',\n", 104 | " 'atanh',\n", 105 | " 'ceil',\n", 106 | " 'copysign',\n", 107 | " 'cos',\n", 108 | " 'cosh',\n", 109 | " 'degrees',\n", 110 | " 'e',\n", 111 | " 'erf',\n", 112 | " 'erfc',\n", 113 | " 'exp',\n", 114 | " 'expm1',\n", 115 | " 'fabs',\n", 116 | " 'factorial',\n", 117 | " 'floor',\n", 118 | " 'fmod',\n", 119 | " 'frexp',\n", 120 | " 'fsum',\n", 121 | " 'gamma',\n", 122 | " 'gcd',\n", 123 | " 'hypot',\n", 124 | " 'inf',\n", 125 | " 'isclose',\n", 126 | " 'isfinite',\n", 127 | " 'isinf',\n", 128 | " 'isnan',\n", 129 | " 'ldexp',\n", 130 | " 'lgamma',\n", 131 | " 'log',\n", 132 | " 'log10',\n", 133 | " 'log1p',\n", 134 | " 'log2',\n", 135 | " 'modf',\n", 136 | " 'nan',\n", 137 | " 'pi',\n", 138 | " 'pow',\n", 139 | " 'radians',\n", 140 | " 'sin',\n", 141 | " 'sinh',\n", 142 | " 'sqrt',\n", 143 | " 'tan',\n", 144 | " 'tanh',\n", 145 | " 'tau',\n", 146 | " 'trunc']" 147 | ] 148 | }, 149 | "execution_count": 15, 150 | "metadata": {}, 151 | "output_type": "execute_result" 152 | } 153 | ], 154 | "source": [ 155 | "dir(math)" 156 | ] 157 | }, 158 | { 159 | "cell_type": "code", 160 | "execution_count": null, 161 | "metadata": { 162 | "collapsed": true 163 | }, 164 | "outputs": [], 165 | "source": [] 166 | } 167 | ], 168 | "metadata": { 169 | "kernelspec": { 170 | "display_name": "Python 3", 171 | "language": "python", 172 | "name": "python3" 173 | }, 174 | "language_info": { 175 | "codemirror_mode": { 176 | "name": "ipython", 177 | "version": 3 178 | }, 179 | "file_extension": ".py", 180 | "mimetype": "text/x-python", 181 | "name": "python", 182 | "nbconvert_exporter": "python", 183 | "pygments_lexer": "ipython3", 184 | "version": "3.6.4" 185 | } 186 | }, 187 | "nbformat": 4, 188 | "nbformat_minor": 2 189 | } 190 | -------------------------------------------------------------------------------- /NaiveBayes/NaiveBayes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Naive Bayes" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "http://shatterline.com/blog/2013/09/12/not-so-naive-classification-with-the-naive-bayes-classifier/" 15 | ] 16 | }, 17 | { 18 | "cell_type": "markdown", 19 | "metadata": {}, 20 | "source": [ 21 | "Examples in the above link" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "# Assumptions:
\n", 29 | "\n", 30 | "### Features must be independent so we can use
\n", 31 | "\n", 32 | "#### -> BOW
\n", 33 | "#### -> TFIDF
\n", 34 | "\n", 35 | "#### we cant use W2V and tfidf W2V as features are dependent in these techniques." 36 | ] 37 | }, 38 | { 39 | "cell_type": "markdown", 40 | "metadata": {}, 41 | "source": [ 42 | "### Applications:
\n", 43 | "-> Spam Filtering
\n", 44 | "-> Review Classififcation etc...
\n", 45 | "\n", 46 | "basically its most widely used for Text Classification" 47 | ] 48 | }, 49 | { 50 | "cell_type": "markdown", 51 | "metadata": {}, 52 | "source": [ 53 | "## Laplace/Additive Smoothing" 54 | ] 55 | }, 56 | { 57 | "cell_type": "markdown", 58 | "metadata": {}, 59 | "source": [ 60 | "its used to avoide errors in probabilities i.e While calculating using Naive Bayes formula if we get probability as 0 in any part of the formula total value becomes zero to avoide this we add alpha in numerator and 2alpha in denominator so that value will not be zero." 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "## Log Probabilities For numerical Stablization" 68 | ] 69 | }, 70 | { 71 | "cell_type": "markdown", 72 | "metadata": {}, 73 | "source": [ 74 | "Just apply log for every part in Naive Bayes Formula to avoide very smaller values with larger precision. i.e we are dealing with the values between 0-1 python supports upto 16 decimal places if the calculation goes beyond it, it will round of to give error value to avoide this we use LOG." 75 | ] 76 | }, 77 | { 78 | "cell_type": "markdown", 79 | "metadata": {}, 80 | "source": [ 81 | "## Applications / Note:\n", 82 | "It works well with data set where the Features are independent but practically it works good even some features are dependent
\n", 83 | "\n", 84 | "It Works Well in Case of Text Based Classification.
\n", 85 | "\n", 86 | "Its most widely used with Catogorical Features.
\n", 87 | "\n", 88 | "Perform Laplace Smoothing so that our model works well
" 89 | ] 90 | }, 91 | { 92 | "cell_type": "markdown", 93 | "metadata": {}, 94 | "source": [] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": null, 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [] 102 | } 103 | ], 104 | "metadata": { 105 | "kernelspec": { 106 | "display_name": "Python 3", 107 | "language": "python", 108 | "name": "python3" 109 | }, 110 | "language_info": { 111 | "codemirror_mode": { 112 | "name": "ipython", 113 | "version": 3 114 | }, 115 | "file_extension": ".py", 116 | "mimetype": "text/x-python", 117 | "name": "python", 118 | "nbconvert_exporter": "python", 119 | "pygments_lexer": "ipython3", 120 | "version": "3.6.4" 121 | } 122 | }, 123 | "nbformat": 4, 124 | "nbformat_minor": 2 125 | } 126 | -------------------------------------------------------------------------------- /NamedEntityRecognitionNLTK_DialogFLow/custom_ent.tsv: -------------------------------------------------------------------------------- 1 | what O 2 | is O 3 | the O 4 | headcount METRIC 5 | in O 6 | 2017 DATE 7 | what O 8 | is O 9 | the O 10 | averageage METRIC 11 | in O 12 | march DATE 13 | tell O 14 | me O 15 | headcount METRIC 16 | in O 17 | newyork LOCATION 18 | in O 19 | 2016 DATE 20 | what O 21 | is O 22 | the O 23 | absence METRIC 24 | in O 25 | london LOCATION 26 | in O 27 | last DATE 28 | quarter DATE 29 | show O 30 | me O 31 | headcount METRIC 32 | in O 33 | 2019 DATE 34 | in O 35 | arizona LOCATION 36 | show O 37 | me O 38 | head METRIC 39 | count METRIC 40 | in O 41 | new LOCATION 42 | york LOCATION 43 | in O 44 | june DATE 45 | 2018 DATE 46 | . O 47 | Time METRIC 48 | utilization METRIC 49 | female METRIC 50 | percentage METRIC 51 | brazil LOCATION 52 | china LOCATION 53 | india LOCATION 54 | . O 55 | show O 56 | retention METRIC 57 | in O 58 | brazil LOCATION 59 | in O 60 | 2011 DATE 61 | . O -------------------------------------------------------------------------------- /NamedEntityRecognitionNLTK_DialogFLow/dummy-ner-model-custom.ser.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/NamedEntityRecognitionNLTK_DialogFLow/dummy-ner-model-custom.ser.gz -------------------------------------------------------------------------------- /NamedEntityRecognitionNLTK_DialogFLow/english.all.3class.distsim.crf.ser.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/NamedEntityRecognitionNLTK_DialogFLow/english.all.3class.distsim.crf.ser.gz -------------------------------------------------------------------------------- /NamedEntityRecognitionNLTK_DialogFLow/prop.txt: -------------------------------------------------------------------------------- 1 | trainFile = custom_ent.tsv 2 | serializeTo = dummy-ner-model-custom.ser.gz 3 | map = word=0,answer=1 4 | 5 | useClassFeature=true 6 | useWord=true 7 | useNGrams=true 8 | noMidNGrams=true 9 | maxNGramLeng=6 10 | usePrev=true 11 | useNext=true 12 | useSequences=true 13 | usePrevSequences=true 14 | maxLeft=1 15 | useTypeSeqs=true 16 | useTypeSeqs2=true 17 | useTypeySequences=true 18 | wordShape=chris2useLC 19 | useDisjunctive=true -------------------------------------------------------------------------------- /NamedEntityRecognitionNLTK_DialogFLow/stanford-ner.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/NamedEntityRecognitionNLTK_DialogFLow/stanford-ner.jar -------------------------------------------------------------------------------- /Operators.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Operators which are not present in Java" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 17, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stdout", 17 | "output_type": "stream", 18 | "text": [ 19 | "1\n" 20 | ] 21 | } 22 | ], 23 | "source": [ 24 | "#Arithematic\n", 25 | "\n", 26 | "print(16//10) #Floor Division" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 8, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "name": "stdout", 36 | "output_type": "stream", 37 | "text": [ 38 | "32\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "print(2**5) #power or exponent" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 19, 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "name": "stdout", 53 | "output_type": "stream", 54 | "text": [ 55 | "False\n", 56 | "True\n", 57 | "False\n" 58 | ] 59 | } 60 | ], 61 | "source": [ 62 | "a, b = True, False\n", 63 | "\n", 64 | "print(a and b)\n", 65 | "\n", 66 | "print(a or b)\n", 67 | "\n", 68 | "print(not a)" 69 | ] 70 | }, 71 | { 72 | "cell_type": "markdown", 73 | "metadata": {}, 74 | "source": [ 75 | "# Special Operators" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": 24, 81 | "metadata": {}, 82 | "outputs": [ 83 | { 84 | "name": "stdout", 85 | "output_type": "stream", 86 | "text": [ 87 | "True\n", 88 | "False\n", 89 | "False\n" 90 | ] 91 | } 92 | ], 93 | "source": [ 94 | "a = 5\n", 95 | "b = 5\n", 96 | "\n", 97 | "print(a is b) #checks if a,b memory locations are same\n", 98 | "\n", 99 | "print(a is not b)\n", 100 | "\n", 101 | "\n", 102 | "li = [1,2,3]\n", 103 | "li2 = [1,2,3]\n", 104 | "\n", 105 | "print(li is li2) #fals it doesnt work for lists" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "metadata": {}, 111 | "source": [ 112 | "# MemberShip Operatos" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": 28, 118 | "metadata": {}, 119 | "outputs": [ 120 | { 121 | "name": "stdout", 122 | "output_type": "stream", 123 | "text": [ 124 | "True\n", 125 | "True\n" 126 | ] 127 | } 128 | ], 129 | "source": [ 130 | "li = [1,2,3]\n", 131 | "\n", 132 | "print(1 in li)\n", 133 | "\n", 134 | "print(10 not in li)" 135 | ] 136 | } 137 | ], 138 | "metadata": { 139 | "kernelspec": { 140 | "display_name": "Python 3", 141 | "language": "python", 142 | "name": "python3" 143 | }, 144 | "language_info": { 145 | "codemirror_mode": { 146 | "name": "ipython", 147 | "version": 3 148 | }, 149 | "file_extension": ".py", 150 | "mimetype": "text/x-python", 151 | "name": "python", 152 | "nbconvert_exporter": "python", 153 | "pygments_lexer": "ipython3", 154 | "version": "3.6.4" 155 | } 156 | }, 157 | "nbformat": 4, 158 | "nbformat_minor": 2 159 | } 160 | -------------------------------------------------------------------------------- /OutOfCoursePractice/BSE.csv: -------------------------------------------------------------------------------- 1 | Date,Open,High,Low,Close 2 | 2018-03-09,3504.75,3514.0,3482.8,3488.62 3 | 2018-03-08,3485.37,3510.0,3452.86,3500.07 4 | 2018-03-07,3500.79,3504.52,3466.14,3475.16 5 | 2018-03-06,3566.05,3573.05,3497.0,3506.91 6 | 2018-03-05,3579.12,3579.32,3530.66,3544.63 7 | 2018-03-01,3594.74,3606.88,3574.64,3581.08 8 | 2018-02-28,3589.14,3602.99,3573.75,3596.55 9 | 2018-02-27,3645.16,3652.65,3607.89,3611.54 10 | 2018-02-26,3612.49,3643.71,3608.35,3634.8 11 | 2018-02-23,3554.76,3596.62,3551.03,3594.16 12 | 2018-02-22,3569.66,3569.66,3539.5,3550.99 13 | 2018-02-21,3589.67,3594.6,3559.53,3579.92 14 | 2018-02-20,3578.43,3598.16,3569.17,3575.11 15 | 2018-02-19,3627.18,3628.65,3554.25,3580.67 16 | 2018-02-16,3681.07,3694.77,3614.87,3624.78 17 | 2018-02-15,3677.55,3703.01,3666.54,3682.22 18 | 2018-02-14,3726.95,3734.48,3661.81,3676.21 19 | 2018-02-12,3707.4,3721.62,3700.64,3711.16 20 | 2018-02-09,3671.22,3692.99,3650.43,3684.74 21 | 2018-02-08,3704.47,3738.29,3701.06,3712.43 22 | 2018-02-07,3732.33,3749.39,3686.22,3699.9 23 | 2018-02-06,3631.26,3718.63,3600.11,3683.5 24 | 2018-02-05,3705.79,3758.17,3678.61,3736.13 25 | 2018-02-02,3829.58,3829.89,3736.15,3744.46 26 | 2018-02-01,3872.03,3898.6,3794.6,3843.86 27 | 2018-01-31,3859.4,3875.04,3823.79,3844.23 28 | 2018-01-30,3861.76,3875.28,3842.04,3867.65 29 | 2018-01-29,3893.17,3912.33,3852.76,3857.39 30 | 2018-01-25,3908.73,3916.76,3868.05,3885.25 31 | 2018-01-24,3888.95,3901.54,3870.43,3897.79 32 | 2018-01-23,3838.38,3887.96,3838.38,3881.53 33 | 2018-01-22,3812.81,3826.08,3788.54,3820.91 34 | 2018-01-19,3778.3,3806.46,3765.2,3800.88 35 | 2018-01-18,3819.31,3830.96,3748.58,3769.67 36 | 2018-01-17,3745.13,3806.73,3696.07,3796.21 37 | 2018-01-16,3815.16,3822.39,3736.51,3739.23 38 | 2018-01-15,3817.39,3843.71,3804.24,3806.93 39 | 2018-01-12,3825.22,3834.35,3785.03,3807.25 40 | 2018-01-11,3823.39,3824.42,3804.46,3811.9 41 | 2018-01-10,3855.93,3857.78,3812.84,3817.5 42 | 2018-01-09,3845.22,3861.62,3834.38,3841.17 43 | 2018-01-08,3814.29,3840.31,3814.29,3833.13 44 | 2018-01-05,3823.21,3829.16,3797.93,3805.98 45 | 2018-01-04,3781.48,3812.5,3773.07,3806.8 46 | 2018-01-03,3760.02,3775.92,3752.88,3763.61 47 | 2018-01-02,3785.83,3788.5,3740.44,3751.92 48 | 2018-01-01,3788.57,3793.35,3762.99,3768.63 49 | 2017-12-29,3777.6,3787.34,3763.93,3772.25 50 | 2017-12-28,3779.05,3791.8,3752.37,3759.57 51 | 2017-12-27,3811.23,3822.69,3769.71,3778.23 52 | 2017-12-26,3808.97,3825.59,3795.06,3803.91 53 | 2017-12-22,3789.06,3808.8,3785.8,3805.35 54 | 2017-12-21,3765.5,3786.25,3765.5,3781.42 55 | 2017-12-20,3759.77,3779.56,3746.44,3762.81 56 | 2017-12-19,3738.68,3752.82,3730.72,3750.08 57 | 2017-12-18,3701.42,3739.11,3620.62,3723.82 58 | 2017-12-15,3723.22,3733.13,3705.39,3708.9 59 | 2017-12-14,3677.71,3696.58,3643.2,3687.13 60 | 2017-12-13,3687.65,3706.48,3656.71,3663.81 61 | 2017-12-12,3725.47,3726.5,3683.42,3688.35 62 | 2017-12-11,3733.17,3742.72,3712.09,3721.29 63 | 2017-12-08,3685.22,3717.95,3685.22,3711.18 64 | 2017-12-07,3613.42,3681.58,3613.38,3674.58 65 | 2017-12-06,3658.49,3659.33,3612.8,3616.39 66 | 2017-12-05,3667.3,3668.57,3633.12,3660.6 67 | 2017-12-04,3681.29,3691.85,3658.19,3675.25 68 | 2017-12-01,3723.87,3736.75,3668.92,3677.43 69 | 2017-11-30,3729.49,3733.07,3704.67,3711.99 70 | 2017-11-29,3753.92,3760.3,3732.89,3738.94 71 | 2017-11-28,3772.47,3774.14,3728.73,3744.71 72 | 2017-11-27,3749.27,3768.38,3733.78,3764.67 73 | 2017-11-24,3746.35,3756.2,3744.97,3748.85 74 | 2017-11-23,3742.34,3757.39,3721.62,3742.5 75 | 2017-11-22,3746.25,3751.9,3720.7,3738.85 76 | 2017-11-21,3764.34,3768.73,3730.24,3738.41 77 | 2017-11-20,3738.74,3759.22,3720.52,3751.84 78 | 2017-11-17,3745.45,3764.86,3718.45,3723.21 79 | 2017-11-16,3686.8,3714.2,3676.92,3707.41 80 | 2017-11-15,3716.89,3718.21,3659.08,3674.2 81 | 2017-11-14,3745.39,3752.07,3705.31,3711.3 82 | 2017-11-13,3796.67,3800.18,3746.2,3751.81 83 | 2017-11-10,3755.55,3804.24,3736.94,3793.45 84 | 2017-11-09,3766.35,3790.02,3725.96,3750.32 85 | 2017-11-08,3787.69,3791.57,3744.02,3756.53 86 | 2017-11-07,3832.17,3849.6,3766.12,3772.59 87 | 2017-11-06,3833.32,3840.59,3812.34,3819.88 88 | 2017-11-03,3820.89,3836.69,3803.31,3828.31 89 | 2017-11-02,3825.1,3826.94,3799.33,3805.34 90 | 2017-11-01,3817.08,3838.12,3812.47,3815.67 91 | 2017-10-31,3789.96,3803.9,3775.38,3795.97 92 | 2017-10-30,3779.63,3805.59,3769.54,3774.11 93 | 2017-10-27,3784.73,3799.41,3755.92,3761.57 94 | 2017-10-26,3747.0,3785.53,3745.93,3772.24 95 | 2017-10-25,3623.63,3740.61,3623.63,3734.97 96 | 2017-10-24,3543.79,3575.78,3542.24,3573.52 97 | 2017-10-23,3545.03,3568.72,3527.79,3537.37 98 | 2017-10-19,3582.87,3583.99,3534.15,3542.66 99 | 2017-10-18,3567.44,3574.5,3557.3,3567.23 100 | 2017-10-17,3580.59,3599.2,3573.35,3585.2 101 | 2017-10-16,3570.7,3595.11,3570.69,3577.07 102 | 2017-10-13,3572.13,3580.31,3562.38,3568.14 103 | 2017-10-12,3545.74,3569.78,3531.52,3567.24 104 | 2017-10-11,3557.25,3568.22,3521.57,3536.33 105 | 2017-10-10,3537.34,3552.58,3535.47,3542.56 106 | 2017-10-09,3553.08,3564.42,3531.84,3534.34 107 | 2017-10-06,3506.25,3552.13,3505.62,3548.65 108 | 2017-10-05,3514.85,3525.94,3496.97,3500.45 109 | 2017-10-04,3515.92,3526.13,3508.76,3516.36 110 | 2017-10-03,3509.35,3521.51,3484.2,3494.12 111 | 2017-09-29,3482.8,3507.41,3476.87,3483.19 112 | 2017-09-28,3447.41,3475.21,3425.87,3463.76 113 | 2017-09-27,3511.53,3517.47,3431.92,3442.82 114 | 2017-09-26,3492.01,3511.11,3476.02,3496.51 115 | 2017-09-25,3522.28,3526.29,3457.44,3485.24 116 | 2017-09-22,3586.45,3586.45,3511.7,3519.45 117 | 2017-09-21,3623.32,3630.94,3566.75,3593.11 118 | 2017-09-20,3621.95,3631.34,3612.76,3618.76 119 | 2017-09-19,3623.92,3624.13,3593.75,3610.8 120 | -------------------------------------------------------------------------------- /OutOfCoursePractice/SharePrediction3Months.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/OutOfCoursePractice/SharePrediction3Months.xlsx -------------------------------------------------------------------------------- /OutOfCoursePractice/SharesPrediction.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/OutOfCoursePractice/SharesPrediction.xlsx -------------------------------------------------------------------------------- /OutOfCoursePractice/oneMonthData.csv: -------------------------------------------------------------------------------- 1 | DATE,Future Index Long FII,Future Index Short FII,Option Index Call Long FII,Option Index Put Long FII,Option Index Call Short FII,Option Index Put Short FII,Future Index Long PRO,Future Index Short PRO,Option Index Call Long PRO,Option Index Put Long PRO,Option Index Call Short PRO,Option Index Put Short PRO,Future Index Long CLIENTS,Future Index Short CLIENTS,Option Index Call Long CLIENTS,Option Index Put Long CLIENTS,Option Index Call Short CLIENTS,Option Index Put Short CLIENTS,ACTUAL 2 | 23-02-2018,69441.00,79021.00,183383.00,264919.00,86845.00,111480.00,20632.00,18905.00,139394.00,152384.00,203732.00,181494.00,222689.00,178454.00,375805.00,581393.00,468931.00,771058.00,BULLISH 3 | 26-02-2018,82284.00,79312.00,188695.00,281843.00,88012.00,117379.00,20479.00,18829.00,133212.00,151958.00,209666.00,211901.00,221968.00,189077.00,412362.00,655109.00,497517.00,826298.00,BULLISH 4 | 27-02-2018,90876.00,79274.00,193113.00,293639.00,88885.00,121054.00,21397.00,22438.00,131698.00,165524.00,241660.00,209898.00,221750.00,193131.00,500391.00,639892.00,555584.00,836871.00,BEARISH 5 | 28-02-2018,87879.00,80942.00,200697.00,305923.00,88054.00,127073.00,21340.00,25420.00,132226.00,174034.00,268331.00,216171.00,228097.00,193438.00,570581.00,648818.00,608046.00,854949.00,BULLISH 6 | 01-03-2018,82864.00,84604.00,208838.00,300873.00,92974.00,126181.00,24174.00,30283.00,125610.00,162588.00,260738.00,175851.00,247887.00,197418.00,501669.00,561607.00,543331.00,795055.00,BEARISH 7 | 05-03-2018,77376.00,97787.00,221559.00,314324.00,101847.00,125512.00,24205.00,31754.00,135461.00,170657.00,296488.00,191591.00,259914.00,190073.00,581165.00,584293.00,600776.00,824639.00,BEARISH 8 | 06-03-2018,84617.00,100442.00,230580.00,330959.00,114766.00,126235.00,25848.00,37530.00,149901.00,174936.00,344670.00,191452.00,273254.00,202205.00,684823.00,569619.00,666794.00,830995.00,BEARISH 9 | 07-03-2018,98122.00,111267.00,225401.00,338544.00,124292.00,127937.00,25951.00,35902.00,177291.00,173512.00,398731.00,198225.00,261660.00,203602.00,789425.00,602929.00,730020.00,863524.00,BEARISH 10 | 08-03-2018,106181.00,115830.00,219617.00,339274.00,117915.00,125248.00,20165.00,33721.00,152499.00,148389.00,315510.00,193021.00,252912.00,203676.00,597456.00,575846.00,597073.00,833810.00,BULLISH 11 | 09-03-2018,106815.00,113652.00,226599.00,349983.00,129808.00,131111.00,19270.00,36784.00,160863.00,152551.00,329242.00,207200.00,248688.00,211019.00,649240.00,594325.00,638578.00,847649.00,BEARISH 12 | 12-03-2018,128228.00,104101.00,240300.00,346421.00,128982.00,143434.00,21218.00,38287.00,188026.00,165885.00,306046.00,270774.00,224242.00,218911.00,576490.00,726217.00,630714.00,911463.00,BULLISH 13 | 13-03-2018,129669.00,107921.00,247987.00,347639.00,131682.00,154550.00,23477.00,32331.00,169842.00,168028.00,311968.00,254436.00,214520.00,215240.00,594684.00,722376.00,629789.00,915806.00,BEARISH 14 | 14-03-2018,135546.00,116962.00,247590.00,353041.00,133640.00,153671.00,25478.00,30711.00,180413.00,179649.00,322014.00,276302.00,217123.00,215951.00,623833.00,771648.00,657108.00,961115.00,BULLISH 15 | 15-03-2018,134118.00,124535.00,236695.00,357439.00,131844.00,156459.00,30542.00,27151.00,152911.00,164780.00,307625.00,216604.00,224024.00,216336.00,582131.00,632554.00,593194.00,868845.00,BEARISH 16 | 16-03-2018,134390.00,153757.00,229213.00,361514.00,136526.00,144174.00,30194.00,31526.00,166812.00,185079.00,368528.00,214768.00,243041.00,206800.00,703860.00,623446.00,655757.00,899357.00,BEARISH 17 | 19-03-2018,136140.00,156996.00,224517.00,397270.00,170257.00,145858.00,30809.00,40269.00,172391.00,199535.00,396746.00,241369.00,240393.00,200125.00,807589.00,626875.00,698420.00,918046.00,BEARISH 18 | 20-03-2018,127827.00,166917.00,224927.00,391165.00,172880.00,150072.00,30925.00,42643.00,179050.00,195338.00,401409.00,244930.00,251852.00,193679.00,827635.00,662742.00,718249.00,936378.00,BULLISH 19 | 21-03-2018,121809.00,177552.00,230953.00,394004.00,170890.00,156717.00,31140.00,38156.00,175953.00,201401.00,389005.00,251217.00,254483.00,188447.00,817707.00,686969.00,725644.00,951341.00,BULLISH 20 | 22-03-2018,126313.00,179976.00,229138.00,389385.00,168344.00,144915.00,29065.00,43755.00,161412.00,184371.00,373915.00,231509.00,265158.00,189795.00,752405.00,640457.00,661622.00,914691.00,BEARISH 21 | 23-03-2018,111849.00,190868.00,239863.00,390398.00,178770.00,144596.00,30170.00,41629.00,173299.00,175175.00,402051.00,222944.00,274668.00,182498.00,795503.00,660245.00,688770.00,936180.00,BEARISH 22 | 26-03-2018,102365.00,206835.00,241997.00,398704.00,181978.00,141548.00,30355.00,41769.00,194798.00,194309.00,369581.00,289215.00,271613.00,169364.00,721441.00,739217.00,667603.00,979974.00,BULLISH 23 | 27-03-2018,108088.00,210127.00,238035.00,405083.00,189197.00,135145.00,25688.00,43793.00,201903.00,206471.00,378870.00,306593.00,281857.00,169938.00,752814.00,756064.00,685611.00,1005737.00,BEARISH 24 | 28-03-2018,31607.00,141966.00,144762.00,290971.00,90743.00,101208.00,26699.00,18557.00,108480.00,133975.00,154163.00,141922.00,239304.00,147880.00,378820.00,456129.00,448082.00,718539.00,BEARISH 25 | 02-04-2018,31784.00,140254.00,168471.00,304625.00,94593.00,103887.00,24848.00,18277.00,123976.00,148459.00,183093.00,178018.00,240728.00,151025.00,405639.00,532568.00,481326.00,784694.00,BULLISH 26 | 03-04-2018,30548.00,147037.00,182507.00,315077.00,96191.00,104124.00,24778.00,14126.00,140793.00,158654.00,201829.00,194983.00,242270.00,140967.00,417769.00,589687.00,503975.00,845258.00,BULLISH 27 | 04-04-2018,38448.00,172454.00,195585.00,327593.00,104233.00,108159.00,23834.00,22187.00,138521.00,207326.00,267714.00,220087.00,276056.00,153713.00,575588.00,589995.00,600339.00,877615.00,BEARISH 28 | 05-04-2018,38970.00,156465.00,201902.00,332409.00,97151.00,107850.00,23050.00,23074.00,153223.00,155987.00,205361.00,225581.00,263292.00,152331.00,396931.00,603206.00,510470.00,837383.00,BULLISH 29 | 06-04-2018,37361.00,157362.00,203506.00,341729.00,93793.00,111824.00,22526.00,26690.00,152807.00,163024.00,207920.00,249010.00,272846.00,151316.00,419337.00,663800.00,534863.00,886931.00,BEARISH 30 | 09-04-2018,37478.00,159439.00,215927.00,343414.00,89922.00,112946.00,23533.00,24782.00,159566.00,164842.00,228440.00,260700.00,277062.00,154482.00,441849.00,715546.00,559906.00,929368.00,BULLISH 31 | 10-04-2018,43787.00,151353.00,220540.00,350172.00,80271.00,118351.00,23079.00,30225.00,170180.00,173363.00,239670.00,280040.00,282620.00,158452.00,452553.00,767097.00,584258.00,972773.00,BULLISH 32 | 11-04-2018,50614.00,149940.00,220230.00,372689.00,82464.00,131624.00,21756.00,40716.00,178693.00,172045.00,275365.00,307563.00,290979.00,163287.00,502392.00,800383.00,604412.00,986462.00,BEARISH 33 | 12-04-2018,51027.00,145879.00,224979.00,374699.00,80220.00,154897.00,24029.00,49063.00,172686.00,155344.00,228188.00,297641.00,304932.00,174212.00,381495.00,736742.00,531678.00,894779.00,BULLISH 34 | 13-04-2018,53787.00,152009.00,236652.00,382329.00,83060.00,169218.00,24752.00,42480.00,171131.00,175075.00,246379.00,303665.00,309836.00,175551.00,417095.00,779843.00,556725.00,946896.00,BEARISH 35 | 16-04-2018,58099.00,156206.00,240655.00,389851.00,88176.00,172389.00,25617.00,41594.00,180786.00,180104.00,250096.00,322485.00,310206.00,179280.00,422104.00,824358.00,566559.00,981603.00,BULLISH 36 | 17-04-2018,64811.00,159424.00,244404.00,396491.00,88417.00,176317.00,26079.00,40622.00,173877.00,174013.00,249799.00,309908.00,313400.00,179923.00,449111.00,836206.00,590462.00,1002649.00,BEARISH 37 | 18-04-2018,83500.00,150274.00,241949.33,399425.00,90792.33,180366.00,22276.00,47751.00,185190.67,181905.00,284137.00,314660.00,304185.00,185936.00,517594.00,834993.33,631091.33,1003661.33,BULLISH 38 | 19-04-2018,91849.00,148373.00,241238.00,400176.00,89709.00,187460.00,21931.00,48556.00,171927.00,161086.00,238136.00,305725.00,301846.00,187424.00,412474.00,786880.00,559080.00,937325.00,BULLISH 39 | 20-04-2018,98670.00,152062.00,242730.00,398303.00,87676.00,189458.00,20034.00,48538.00,174088.00,171365.00,250937.00,286306.00,305439.00,187142.00,436918.00,791876.00,576409.00,968148.00,BULLISH 40 | 23-04-2018,102052.00,153537.00,237125.00,412192.00,93624.00,191552.00,18137.00,52846.00,162000.00,171486.00,247344.00,302547.00,312300.00,186808.00,477440.00,832435.00,596883.00,1004382.00,BULLISH 41 | 24-04-2018,95758.00,143079.00,232080.00,418583.00,83021.00,174204.00,18811.00,54669.00,161067.00,175258.00,248597.00,319787.00,311137.00,188883.00,477283.00,834025.00,600098.00,1017376.00,BEARISH 42 | 25-04-2018,105295.00,150799.00,227564.00,426395.00,90535.00,168772.00,21298.00,54040.00,161542.00,195735.00,269650.00,302486.00,314958.00,194415.00,552615.00,798965.00,642822.00,1033338.00,BEARISH 43 | 26-04-2018,72754.00,61094.00,174905.00,275645.00,72583.00,92173.00,11331.00,54749.00,146634.00,128758.00,113712.00,162644.00,254450.00,180009.00,262268.00,448929.00,457458.00,676617.00,BULLISH 44 | 27-04-2018,84868.00,64375.00,192614.00,282240.00,77619.00,112069.00,15978.00,55581.00,148636.00,147895.00,125721.00,208846.00,262306.00,191963.00,303303.00,578820.00,501159.00,766928.00,BULLISH 45 | -------------------------------------------------------------------------------- /Pandas_DataFrames/WritingWeatherToCsv.csv: -------------------------------------------------------------------------------- 1 | day,temperature,windspeed,event 2 | 1/1/2017,32,6,Rain 3 | 1/2/2017,35,7,Sunny 4 | 1/3/2017,28,2,Snow 5 | 1/4/2017,24,7,Snow 6 | 1/5/2017,32,4,Rain 7 | 1/6/2017,31,2,Sunny 8 | -------------------------------------------------------------------------------- /Pandas_DataFrames/WritingWeatherToExcel.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/Pandas_DataFrames/WritingWeatherToExcel.xls -------------------------------------------------------------------------------- /Pandas_DataFrames/nyc_weather.csv: -------------------------------------------------------------------------------- 1 | EST,Temperature,DewPoint,Humidity,Sea Level PressureIn,VisibilityMiles,WindSpeedMPH,PrecipitationIn,CloudCover,Events,WindDirDegrees 2 | 1/1/2016,38,23,52,30.03,10,8,0,5,,281 3 | 1/2/2016,36,18,46,30.02,10,7,0,3,,275 4 | 1/3/2016,40,21,47,29.86,10,8,0,1,,277 5 | 1/4/2016,25,9,44,30.05,10,9,0,3,,345 6 | 1/5/2016,20,-3,41,30.57,10,5,0,0,,333 7 | 1/6/2016,33,4,35,30.5,10,4,0,0,,259 8 | 1/7/2016,39,11,33,30.28,10,2,0,3,,293 9 | 1/8/2016,39,29,64,30.2,10,4,0,8,,79 10 | 1/9/2016,44,38,77,30.16,9,8,T,8,Rain,76 11 | 1/10/2016,50,46,71,29.59,4,,1.8,7,Rain,109 12 | 1/11/2016,33,8,37,29.92,10,,0,1,,289 13 | 1/12/2016,35,15,53,29.85,10,6,T,4,,235 14 | 1/13/2016,26,4,42,29.94,10,10,0,0,,284 15 | 1/14/2016,30,12,47,29.95,10,5,T,7,,266 16 | 1/15/2016,43,31,62,29.82,9,5,T,2,,101 17 | 1/16/2016,47,37,70,29.52,8,7,0.24,7,Rain,340 18 | 1/17/2016,36,23,66,29.78,8,6,0.05,6,Fog-Snow,345 19 | 1/18/2016,25,6,53,29.83,9,12,T,2,Snow,293 20 | 1/19/2016,22,3,42,30.03,10,11,0,1,,293 21 | 1/20/2016,32,15,49,30.13,10,6,0,2,,302 22 | 1/21/2016,31,11,45,30.15,10,6,0,1,,312 23 | 1/22/2016,26,6,41,30.21,9,,0.01,3,Snow,34 24 | 1/23/2016,26,21,78,29.77,1,16,2.31,8,Fog-Snow,42 25 | 1/24/2016,28,11,53,29.92,8,6,T,3,Snow,327 26 | 1/25/2016,34,18,54,30.25,10,3,0,2,,286 27 | 1/26/2016,43,29,56,30.03,10,7,0,2,,244 28 | 1/27/2016,41,22,45,30.03,10,7,T,3,Rain,311 29 | 1/28/2016,37,20,51,29.9,10,5,0,1,,234 30 | 1/29/2016,36,21,50,29.58,10,8,0,4,,298 31 | 1/30/2016,34,16,46,30.01,10,7,0,0,,257 32 | 1/31/2016,46,28,52,29.9,10,5,0,0,,241 33 | -------------------------------------------------------------------------------- /Pandas_DataFrames/weather_data.csv: -------------------------------------------------------------------------------- 1 | day,temperature,windspeed,event 2 | 1/1/2017,32,6,Rain 3 | 1/2/2017,35,7,Sunny 4 | 1/3/2017,28,2,Snow 5 | 1/4/2017,24,7,Snow 6 | 1/5/2017,32,4,Rain 7 | 1/6/2017,31,2,Sunny 8 | 9 | -------------------------------------------------------------------------------- /Pandas_DataFrames/weather_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/Pandas_DataFrames/weather_data.xlsx -------------------------------------------------------------------------------- /Pandas_DataFrames/weather_data_cities.csv: -------------------------------------------------------------------------------- 1 | day,city,temperature,windspeed,event 2 | 1/1/2017,new york,32,6,Rain 3 | 1/2/2017,new york,36,7,Sunny 4 | 1/3/2017,new york,28,12,Snow 5 | 1/4/2017,new york,33,7,Sunny 6 | 1/1/2017,mumbai,90,5,Sunny 7 | 1/2/2017,mumbai,85,12,Fog 8 | 1/3/2017,mumbai,87,15,Fog 9 | 1/4/2017,mumbai,92,5,Rain 10 | 1/1/2017,paris,45,20,Sunny 11 | 1/2/2017,paris,50,13,Cloudy 12 | 1/3/2017,paris,54,8,Cloudy 13 | 1/4/2017,paris,42,10,Cloudy 14 | -------------------------------------------------------------------------------- /Practice_py.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Practice" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "## practice\n", 15 | "### practice\n", 16 | "#### practice" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "sbddjb" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 1, 29 | "metadata": {}, 30 | "outputs": [ 31 | { 32 | "data": { 33 | "text/plain": [ 34 | "'aka'" 35 | ] 36 | }, 37 | "execution_count": 1, 38 | "metadata": {}, 39 | "output_type": "execute_result" 40 | } 41 | ], 42 | "source": [ 43 | "a= 5\n", 44 | "a= 5.2\n", 45 | "a =\"aka\"\n", 46 | "a" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 2, 52 | "metadata": {}, 53 | "outputs": [ 54 | { 55 | "data": { 56 | "text/plain": [ 57 | "str" 58 | ] 59 | }, 60 | "execution_count": 2, 61 | "metadata": {}, 62 | "output_type": "execute_result" 63 | } 64 | ], 65 | "source": [ 66 | "type(a)" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": 3, 72 | "metadata": {}, 73 | "outputs": [ 74 | { 75 | "data": { 76 | "text/plain": [ 77 | "int" 78 | ] 79 | }, 80 | "execution_count": 3, 81 | "metadata": {}, 82 | "output_type": "execute_result" 83 | } 84 | ], 85 | "source": [ 86 | "b=10\n", 87 | "type(b)" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 4, 93 | "metadata": {}, 94 | "outputs": [ 95 | { 96 | "data": { 97 | "text/plain": [ 98 | "bool" 99 | ] 100 | }, 101 | "execution_count": 4, 102 | "metadata": {}, 103 | "output_type": "execute_result" 104 | } 105 | ], 106 | "source": [ 107 | "a = False\n", 108 | "type(a)" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 6, 114 | "metadata": {}, 115 | "outputs": [ 116 | { 117 | "data": { 118 | "text/plain": [ 119 | "6" 120 | ] 121 | }, 122 | "execution_count": 6, 123 | "metadata": {}, 124 | "output_type": "execute_result" 125 | } 126 | ], 127 | "source": [ 128 | "li = [1,2,3]\n", 129 | "sum=0;\n", 130 | "for i in li:\n", 131 | " sum= sum+i\n", 132 | "sum" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": 7, 138 | "metadata": {}, 139 | "outputs": [ 140 | { 141 | "name": "stdout", 142 | "output_type": "stream", 143 | "text": [ 144 | "20\n" 145 | ] 146 | } 147 | ], 148 | "source": [ 149 | "a =10;\n", 150 | "b=20\n", 151 | "if(a>b):\n", 152 | " print(a)\n", 153 | "else:\n", 154 | " print(b)\n" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 9, 160 | "metadata": {}, 161 | "outputs": [ 162 | { 163 | "name": "stdout", 164 | "output_type": "stream", 165 | "text": [ 166 | "20\n" 167 | ] 168 | } 169 | ], 170 | "source": [ 171 | "a =10\n", 172 | "b=20\n", 173 | "c=5\n", 174 | "\n", 175 | "if(a>b):\n", 176 | " print(a)\n", 177 | "elif(b>c):\n", 178 | " print(b)\n", 179 | " \n", 180 | "else:\n", 181 | " print(c)" 182 | ] 183 | }, 184 | { 185 | "cell_type": "code", 186 | "execution_count": 13, 187 | "metadata": {}, 188 | "outputs": [ 189 | { 190 | "name": "stdout", 191 | "output_type": "stream", 192 | "text": [ 193 | "0\n", 194 | "1\n", 195 | "2\n", 196 | "3\n", 197 | "4\n" 198 | ] 199 | } 200 | ], 201 | "source": [ 202 | "for i in range(5):\n", 203 | " print(i)" 204 | ] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": 16, 209 | "metadata": {}, 210 | "outputs": [ 211 | { 212 | "data": { 213 | "text/plain": [ 214 | "100" 215 | ] 216 | }, 217 | "execution_count": 16, 218 | "metadata": {}, 219 | "output_type": "execute_result" 220 | } 221 | ], 222 | "source": [ 223 | "a=10\n", 224 | "a**2" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": 17, 230 | "metadata": {}, 231 | "outputs": [ 232 | { 233 | "data": { 234 | "text/plain": [ 235 | "True" 236 | ] 237 | }, 238 | "execution_count": 17, 239 | "metadata": {}, 240 | "output_type": "execute_result" 241 | } 242 | ], 243 | "source": [ 244 | "a=10\n", 245 | "b=20\n", 246 | "a != b" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": 18, 252 | "metadata": {}, 253 | "outputs": [], 254 | "source": [ 255 | "li = [1,2,3]\n", 256 | "\n", 257 | "li.append(4)" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": 19, 263 | "metadata": {}, 264 | "outputs": [ 265 | { 266 | "data": { 267 | "text/plain": [ 268 | "[1, 2, 3, 4]" 269 | ] 270 | }, 271 | "execution_count": 19, 272 | "metadata": {}, 273 | "output_type": "execute_result" 274 | } 275 | ], 276 | "source": [ 277 | "li" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": null, 283 | "metadata": {}, 284 | "outputs": [], 285 | "source": [] 286 | } 287 | ], 288 | "metadata": { 289 | "kernelspec": { 290 | "display_name": "Python 3", 291 | "language": "python", 292 | "name": "python3" 293 | }, 294 | "language_info": { 295 | "codemirror_mode": { 296 | "name": "ipython", 297 | "version": 3 298 | }, 299 | "file_extension": ".py", 300 | "mimetype": "text/x-python", 301 | "name": "python", 302 | "nbconvert_exporter": "python", 303 | "pygments_lexer": "ipython3", 304 | "version": "3.6.4" 305 | } 306 | }, 307 | "nbformat": 4, 308 | "nbformat_minor": 2 309 | } 310 | -------------------------------------------------------------------------------- /ProbabilityAndStatistics/Capture.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/Capture.PNG -------------------------------------------------------------------------------- /ProbabilityAndStatistics/HypothesisTesting_9.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Hypothesis Testing" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "" 15 | ] 16 | }, 17 | { 18 | "cell_type": "markdown", 19 | "metadata": {}, 20 | "source": [ 21 | "" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "" 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "Here we are using conditional probability p(observed from exp | assumption (h0)) the value of this indicates the the probability of the experiment with H0 as true." 36 | ] 37 | }, 38 | { 39 | "cell_type": "markdown", 40 | "metadata": {}, 41 | "source": [ 42 | "" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "" 50 | ] 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "metadata": {}, 55 | "source": [ 56 | "Generally if p-value is <5% then we consider it as small" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "That implies H0 is not true that mean Alternate Hypothesis(H1) is true i.e coin is biased towards head" 71 | ] 72 | }, 73 | { 74 | "cell_type": "markdown", 75 | "metadata": {}, 76 | "source": [ 77 | "### Example 2:" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "metadata": {}, 83 | "source": [ 84 | "Here we are considering 3 flips" 85 | ] 86 | }, 87 | { 88 | "cell_type": "markdown", 89 | "metadata": {}, 90 | "source": [ 91 | "" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "as 12.5 is greater than 5% we accept H0" 99 | ] 100 | }, 101 | { 102 | "cell_type": "markdown", 103 | "metadata": {}, 104 | "source": [ 105 | "" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "metadata": {}, 111 | "source": [ 112 | "always consider these points befor the test" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": null, 118 | "metadata": {}, 119 | "outputs": [], 120 | "source": [] 121 | } 122 | ], 123 | "metadata": { 124 | "kernelspec": { 125 | "display_name": "Python 3", 126 | "language": "python", 127 | "name": "python3" 128 | }, 129 | "language_info": { 130 | "codemirror_mode": { 131 | "name": "ipython", 132 | "version": 3 133 | }, 134 | "file_extension": ".py", 135 | "mimetype": "text/x-python", 136 | "name": "python", 137 | "nbconvert_exporter": "python", 138 | "pygments_lexer": "ipython3", 139 | "version": "3.6.4" 140 | } 141 | }, 142 | "nbformat": 4, 143 | "nbformat_minor": 2 144 | } 145 | -------------------------------------------------------------------------------- /ProbabilityAndStatistics/Rand Num Generator(Uniform Distribution).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Rand Num Generator(Uniform Distribution)" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import random" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 45, 22 | "metadata": {}, 23 | "outputs": [ 24 | { 25 | "data": { 26 | "text/plain": [ 27 | "0.6821676325754673" 28 | ] 29 | }, 30 | "execution_count": 45, 31 | "metadata": {}, 32 | "output_type": "execute_result" 33 | } 34 | ], 35 | "source": [ 36 | "# generates unifor rand num between 0-1\n", 37 | "random.random() " 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 46, 43 | "metadata": {}, 44 | "outputs": [ 45 | { 46 | "data": { 47 | "text/plain": [ 48 | "(150, 4)" 49 | ] 50 | }, 51 | "execution_count": 46, 52 | "metadata": {}, 53 | "output_type": "execute_result" 54 | } 55 | ], 56 | "source": [ 57 | "from sklearn import datasets\n", 58 | "\n", 59 | "iris = datasets.load_iris()\n", 60 | "\n", 61 | "d = iris.data\n", 62 | "\n", 63 | "d.shape" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 83, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "# converting numpy array to data frames\n", 73 | "import pandas as pd\n", 74 | "df = pd.DataFrame(data=d, # values\n", 75 | " index=range(0,150), \n", 76 | " columns=['pl','pw','sl','sw']) # 1st row as the column names" 77 | ] 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "metadata": {}, 82 | "source": [ 83 | "Note: above is for my practice" 84 | ] 85 | }, 86 | { 87 | "cell_type": "markdown", 88 | "metadata": {}, 89 | "source": [ 90 | "### Creating sample of 30 pts from 150 pts Randomly" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": 87, 96 | "metadata": {}, 97 | "outputs": [ 98 | { 99 | "data": { 100 | "text/plain": [ 101 | "31" 102 | ] 103 | }, 104 | "execution_count": 87, 105 | "metadata": {}, 106 | "output_type": "execute_result" 107 | } 108 | ], 109 | "source": [ 110 | "n = 150\n", 111 | "\n", 112 | "m = 30\n", 113 | "\n", 114 | "p = m/n\n", 115 | "\n", 116 | "sample = [];\n", 117 | "\n", 118 | "for i in range(0,n):\n", 119 | " if random.random() <= p:\n", 120 | " sample.append(d[i,:])\n", 121 | "len(sample) #it might not be exactly 30" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": null, 127 | "metadata": {}, 128 | "outputs": [], 129 | "source": [] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "metadata": {}, 135 | "outputs": [], 136 | "source": [] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": null, 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [] 144 | } 145 | ], 146 | "metadata": { 147 | "kernelspec": { 148 | "display_name": "Python 3", 149 | "language": "python", 150 | "name": "python3" 151 | }, 152 | "language_info": { 153 | "codemirror_mode": { 154 | "name": "ipython", 155 | "version": 3 156 | }, 157 | "file_extension": ".py", 158 | "mimetype": "text/x-python", 159 | "name": "python", 160 | "nbconvert_exporter": "python", 161 | "pygments_lexer": "ipython3", 162 | "version": "3.6.4" 163 | } 164 | }, 165 | "nbformat": 4, 166 | "nbformat_minor": 2 167 | } 168 | -------------------------------------------------------------------------------- /ProbabilityAndStatistics/Rand Num Generator(Uniform Distribution)_2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Rand Num Generator(Uniform Distribution)" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import random" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 2, 22 | "metadata": {}, 23 | "outputs": [ 24 | { 25 | "data": { 26 | "text/plain": [ 27 | "0.9252182376522041" 28 | ] 29 | }, 30 | "execution_count": 2, 31 | "metadata": {}, 32 | "output_type": "execute_result" 33 | } 34 | ], 35 | "source": [ 36 | "# generates unifor rand num between 0-1\n", 37 | "random.random() " 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 3, 43 | "metadata": {}, 44 | "outputs": [ 45 | { 46 | "data": { 47 | "text/plain": [ 48 | "(150, 4)" 49 | ] 50 | }, 51 | "execution_count": 3, 52 | "metadata": {}, 53 | "output_type": "execute_result" 54 | } 55 | ], 56 | "source": [ 57 | "from sklearn import datasets\n", 58 | "\n", 59 | "iris = datasets.load_iris()\n", 60 | "\n", 61 | "d = iris.data\n", 62 | "\n", 63 | "d.shape" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "# converting numpy array to data frames\n", 73 | "import pandas as pd\n", 74 | "df = pd.DataFrame(data=d, # values\n", 75 | " index=range(0,150), \n", 76 | " columns=['pl','pw','sl','sw']) # 1st row as the column names" 77 | ] 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "metadata": {}, 82 | "source": [ 83 | "Note: above is for my practice" 84 | ] 85 | }, 86 | { 87 | "cell_type": "markdown", 88 | "metadata": {}, 89 | "source": [ 90 | "### Creating sample of 30 pts from 150 pts Randomly" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": 5, 96 | "metadata": {}, 97 | "outputs": [ 98 | { 99 | "data": { 100 | "text/plain": [ 101 | "29" 102 | ] 103 | }, 104 | "execution_count": 5, 105 | "metadata": {}, 106 | "output_type": "execute_result" 107 | } 108 | ], 109 | "source": [ 110 | "n = 150\n", 111 | "\n", 112 | "m = 30\n", 113 | "\n", 114 | "p = m/n\n", 115 | "\n", 116 | "sample = [];\n", 117 | "\n", 118 | "for i in range(0,n):\n", 119 | " if random.random() <= p:\n", 120 | " sample.append(d[i,:])\n", 121 | "len(sample) #it might not be exactly 30" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": 9, 127 | "metadata": {}, 128 | "outputs": [ 129 | { 130 | "data": { 131 | "text/plain": [ 132 | "(0.2,\n", 133 | " [array([5.4, 3.9, 1.7, 0.4]),\n", 134 | " array([5. , 3.4, 1.5, 0.2]),\n", 135 | " array([4.8, 3. , 1.4, 0.1]),\n", 136 | " array([5.8, 4. , 1.2, 0.2]),\n", 137 | " array([5.1, 3.5, 1.4, 0.3]),\n", 138 | " array([4.7, 3.2, 1.6, 0.2]),\n", 139 | " array([5.5, 4.2, 1.4, 0.2]),\n", 140 | " array([5.1, 3.8, 1.9, 0.4]),\n", 141 | " array([5. , 3.3, 1.4, 0.2]),\n", 142 | " array([6.4, 3.2, 4.5, 1.5]),\n", 143 | " array([4.9, 2.4, 3.3, 1. ]),\n", 144 | " array([5. , 2. , 3.5, 1. ]),\n", 145 | " array([5.9, 3. , 4.2, 1.5]),\n", 146 | " array([6. , 2.2, 4. , 1. ]),\n", 147 | " array([6.1, 2.9, 4.7, 1.4]),\n", 148 | " array([5.6, 2.9, 3.6, 1.3]),\n", 149 | " array([6.3, 2.5, 4.9, 1.5]),\n", 150 | " array([6.4, 2.9, 4.3, 1.3]),\n", 151 | " array([6.6, 3. , 4.4, 1.4]),\n", 152 | " array([6. , 2.7, 5.1, 1.6]),\n", 153 | " array([7.1, 3. , 5.9, 2.1]),\n", 154 | " array([6.5, 3.2, 5.1, 2. ]),\n", 155 | " array([6.8, 3. , 5.5, 2.1]),\n", 156 | " array([5.7, 2.5, 5. , 2. ]),\n", 157 | " array([7.7, 3.8, 6.7, 2.2]),\n", 158 | " array([6.4, 3.1, 5.5, 1.8]),\n", 159 | " array([6. , 3. , 4.8, 1.8]),\n", 160 | " array([6.3, 2.5, 5. , 1.9]),\n", 161 | " array([5.9, 3. , 5.1, 1.8])])" 162 | ] 163 | }, 164 | "execution_count": 9, 165 | "metadata": {}, 166 | "output_type": "execute_result" 167 | } 168 | ], 169 | "source": [ 170 | "p,sample" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": null, 176 | "metadata": {}, 177 | "outputs": [], 178 | "source": [] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": null, 183 | "metadata": {}, 184 | "outputs": [], 185 | "source": [] 186 | } 187 | ], 188 | "metadata": { 189 | "kernelspec": { 190 | "display_name": "Python 3", 191 | "language": "python", 192 | "name": "python3" 193 | }, 194 | "language_info": { 195 | "codemirror_mode": { 196 | "name": "ipython", 197 | "version": 3 198 | }, 199 | "file_extension": ".py", 200 | "mimetype": "text/x-python", 201 | "name": "python", 202 | "nbconvert_exporter": "python", 203 | "pygments_lexer": "ipython3", 204 | "version": "3.6.4" 205 | } 206 | }, 207 | "nbformat": 4, 208 | "nbformat_minor": 2 209 | } 210 | -------------------------------------------------------------------------------- /ProbabilityAndStatistics/hypothesistest1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/hypothesistest1.PNG -------------------------------------------------------------------------------- /ProbabilityAndStatistics/hypothesistest2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/hypothesistest2.PNG -------------------------------------------------------------------------------- /ProbabilityAndStatistics/hypothesistest3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/hypothesistest3.PNG -------------------------------------------------------------------------------- /ProbabilityAndStatistics/hypothesistest4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/hypothesistest4.PNG -------------------------------------------------------------------------------- /ProbabilityAndStatistics/hypothesistest5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/hypothesistest5.PNG -------------------------------------------------------------------------------- /ProbabilityAndStatistics/hypothesistest6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/hypothesistest6.PNG -------------------------------------------------------------------------------- /ProbabilityAndStatistics/hypothesistest7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/hypothesistest7.PNG -------------------------------------------------------------------------------- /ProbabilityAndStatistics/hypothesistest8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/hypothesistest8.PNG -------------------------------------------------------------------------------- /ProbabilityAndStatistics/kstest1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaquarkhan/Applied-AI-Course/388cc4d260f0e3ca6aac17b8b2a63916f7ea3076/ProbabilityAndStatistics/kstest1.PNG -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | https://www.appliedaicourse.com/course/applied-ai-course-online/ 2 | -------------------------------------------------------------------------------- /SpaceAndTimeComplexity/TimeNspaceComplexity.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 67, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "#li = np.array([4,1,5,2,6,3,7,1,8,10,31,22,12]);\n", 19 | "li = np.arange(1000000);" 20 | ] 21 | }, 22 | { 23 | "cell_type": "markdown", 24 | "metadata": {}, 25 | "source": [ 26 | "# Linear Search" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 70, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "name": "stdout", 36 | "output_type": "stream", 37 | "text": [ 38 | "found\n", 39 | "Time Taken: 0.21156048774719238\n" 40 | ] 41 | } 42 | ], 43 | "source": [ 44 | "import time\n", 45 | "\n", 46 | "start_time = time.time();\n", 47 | "\n", 48 | "flag=False;\n", 49 | "for ele in li:\n", 50 | " if(ele==999999):\n", 51 | " print(\"found\");\n", 52 | " flag=True\n", 53 | " break;\n", 54 | "if(flag==False):\n", 55 | " print(\"NotFound\");\n", 56 | "end_time = time.time();\n", 57 | "\n", 58 | "print(\"Time Taken: \",end_time - start_time);" 59 | ] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "metadata": {}, 64 | "source": [ 65 | "# Binary Search" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 74, 71 | "metadata": {}, 72 | "outputs": [ 73 | { 74 | "name": "stdout", 75 | "output_type": "stream", 76 | "text": [ 77 | "Found\n", 78 | "Time Taken: 0.0010025501251220703\n" 79 | ] 80 | } 81 | ], 82 | "source": [ 83 | "li = np.arange(1000000000);\n", 84 | "\n", 85 | "start_time = time.time();\n", 86 | "flag=False;\n", 87 | "def binSearch(li,start,end,key):\n", 88 | " global flag\n", 89 | " mid=int((start+end)/2);\n", 90 | " if(li[mid]==key):\n", 91 | " flag=True;\n", 92 | " return flag;\n", 93 | " elif(li[mid]\n", 105 | "\n" 106 | ] 107 | } 108 | ], 109 | "source": [ 110 | "t = (\"akarsh\");\n", 111 | "\n", 112 | "print(type(t));\n", 113 | "\n", 114 | "t = (\"akarsh\" , );\n", 115 | "\n", 116 | "print(type(t));" 117 | ] 118 | }, 119 | { 120 | "cell_type": "markdown", 121 | "metadata": {}, 122 | "source": [ 123 | "# Tuple is Immutable, but if it has list or dict or set we can modify them." 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 20, 129 | "metadata": {}, 130 | "outputs": [ 131 | { 132 | "name": "stdout", 133 | "output_type": "stream", 134 | "text": [ 135 | "([1, 2, 3], {'a': 'akarsh'}, {1, 2, 3, 4})\n" 136 | ] 137 | } 138 | ], 139 | "source": [ 140 | "t = ([1,2], {\"a\":\"akarsh\"}, {1,2,3,4} );\n", 141 | "\n", 142 | "t[0].append(3);\n", 143 | "\n", 144 | "print(t);" 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "metadata": {}, 150 | "source": [ 151 | "Observation: the list inside the tuple is modified not tuple" 152 | ] 153 | }, 154 | { 155 | "cell_type": "markdown", 156 | "metadata": {}, 157 | "source": [ 158 | "# Concat" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": 21, 164 | "metadata": {}, 165 | "outputs": [ 166 | { 167 | "name": "stdout", 168 | "output_type": "stream", 169 | "text": [ 170 | "(1, 2, 3, 4, 5, 6)\n" 171 | ] 172 | } 173 | ], 174 | "source": [ 175 | "t= (1,2,3) + (4,5,6);\n", 176 | "\n", 177 | "print(t)" 178 | ] 179 | }, 180 | { 181 | "cell_type": "markdown", 182 | "metadata": {}, 183 | "source": [ 184 | "# Repeating ele in tuple" 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": 22, 190 | "metadata": {}, 191 | "outputs": [ 192 | { 193 | "name": "stdout", 194 | "output_type": "stream", 195 | "text": [ 196 | "('ML', 'ML', 'ML')\n" 197 | ] 198 | } 199 | ], 200 | "source": [ 201 | "t = (\"ML\", ) * 3;\n", 202 | "\n", 203 | "print(t);" 204 | ] 205 | }, 206 | { 207 | "cell_type": "markdown", 208 | "metadata": {}, 209 | "source": [ 210 | "# Deletion" 211 | ] 212 | }, 213 | { 214 | "cell_type": "markdown", 215 | "metadata": {}, 216 | "source": [ 217 | "We cant remove single ele\n" 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "execution_count": 25, 223 | "metadata": {}, 224 | "outputs": [ 225 | { 226 | "ename": "NameError", 227 | "evalue": "name 't' is not defined", 228 | "output_type": "error", 229 | "traceback": [ 230 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 231 | "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", 232 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;32mdel\u001b[0m \u001b[0mt\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mt\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", 233 | "\u001b[1;31mNameError\u001b[0m: name 't' is not defined" 234 | ] 235 | } 236 | ], 237 | "source": [ 238 | "t = (1,2,3)\n", 239 | "\n", 240 | "del t;\n", 241 | "\n", 242 | "print(t);" 243 | ] 244 | }, 245 | { 246 | "cell_type": "markdown", 247 | "metadata": {}, 248 | "source": [ 249 | "# Count" 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": 26, 255 | "metadata": {}, 256 | "outputs": [ 257 | { 258 | "name": "stdout", 259 | "output_type": "stream", 260 | "text": [ 261 | "3\n" 262 | ] 263 | } 264 | ], 265 | "source": [ 266 | "t = (1,1,1,2,3,2,3,4,5);\n", 267 | "\n", 268 | "print(t.count(1));" 269 | ] 270 | }, 271 | { 272 | "cell_type": "markdown", 273 | "metadata": {}, 274 | "source": [ 275 | "# Index" 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": 27, 281 | "metadata": {}, 282 | "outputs": [ 283 | { 284 | "name": "stdout", 285 | "output_type": "stream", 286 | "text": [ 287 | "0\n" 288 | ] 289 | } 290 | ], 291 | "source": [ 292 | "t = (1,4,1,2,5,6);\n", 293 | "\n", 294 | "#Returns the index of first occurance of the element\n", 295 | "\n", 296 | "print(t.index(1));" 297 | ] 298 | }, 299 | { 300 | "cell_type": "markdown", 301 | "metadata": {}, 302 | "source": [ 303 | "# Tuple Membership" 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": 28, 309 | "metadata": {}, 310 | "outputs": [ 311 | { 312 | "name": "stdout", 313 | "output_type": "stream", 314 | "text": [ 315 | "True\n" 316 | ] 317 | } 318 | ], 319 | "source": [ 320 | "t = (1,2,3);\n", 321 | "\n", 322 | "print(1 in t);" 323 | ] 324 | }, 325 | { 326 | "cell_type": "markdown", 327 | "metadata": {}, 328 | "source": [ 329 | "# Some of the builtin fns" 330 | ] 331 | }, 332 | { 333 | "cell_type": "code", 334 | "execution_count": 29, 335 | "metadata": {}, 336 | "outputs": [ 337 | { 338 | "name": "stdout", 339 | "output_type": "stream", 340 | "text": [ 341 | "1 6 21\n" 342 | ] 343 | } 344 | ], 345 | "source": [ 346 | "t=(1,2,3,4,5,6);\n", 347 | "\n", 348 | "print(min(t), max(t), sum(t));" 349 | ] 350 | }, 351 | { 352 | "cell_type": "code", 353 | "execution_count": null, 354 | "metadata": { 355 | "collapsed": true 356 | }, 357 | "outputs": [], 358 | "source": [] 359 | } 360 | ], 361 | "metadata": { 362 | "kernelspec": { 363 | "display_name": "Python 3", 364 | "language": "python", 365 | "name": "python3" 366 | }, 367 | "language_info": { 368 | "codemirror_mode": { 369 | "name": "ipython", 370 | "version": 3 371 | }, 372 | "file_extension": ".py", 373 | "mimetype": "text/x-python", 374 | "name": "python", 375 | "nbconvert_exporter": "python", 376 | "pygments_lexer": "ipython3", 377 | "version": "3.6.4" 378 | } 379 | }, 380 | "nbformat": 4, 381 | "nbformat_minor": 2 382 | } 383 | -------------------------------------------------------------------------------- /ViewingSourceCodeAndDocumentation.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Checking Documentation And Source code of any Predefined Methods" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "### To Check Doc prefix '?' before method then execute, we will get Popup" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 5, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "import pandas as pd" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 6, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "?pd.DataFrame()" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "### To get Source code prefix with '??', we wil get popup if we execute" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 10, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "from sklearn.cross_validation import train_test_split\n", 49 | "??train_test_split()" 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.6.4" 77 | } 78 | }, 79 | "nbformat": 4, 80 | "nbformat_minor": 2 81 | } 82 | -------------------------------------------------------------------------------- /populations.txt: -------------------------------------------------------------------------------- 1 | # year hare lynx carrot 2 | 1900 30e3 4e3 48300 3 | 1901 47.2e3 6.1e3 48200 4 | 1902 70.2e3 9.8e3 41500 5 | 1903 77.4e3 35.2e3 38200 6 | 1904 36.3e3 59.4e3 40600 7 | 1905 20.6e3 41.7e3 39800 8 | 1906 18.1e3 19e3 38600 9 | 1907 21.4e3 13e3 42300 10 | 1908 22e3 8.3e3 44500 11 | 1909 25.4e3 9.1e3 42100 12 | 1910 27.1e3 7.4e3 46000 13 | 1911 40.3e3 8e3 46800 14 | 1912 57e3 12.3e3 43800 15 | 1913 76.6e3 19.5e3 40900 16 | 1914 52.3e3 45.7e3 39400 17 | 1915 19.5e3 51.1e3 39000 18 | 1916 11.2e3 29.7e3 36700 19 | 1917 7.6e3 15.8e3 41800 20 | 1918 14.6e3 9.7e3 43300 21 | 1919 16.2e3 10.1e3 41300 22 | 1920 24.7e3 8.6e3 47300 23 | --------------------------------------------------------------------------------