Breaking News

Linear Algebra for Machine Learning A-Z – DataDrivenInvestor

Briefly Explained with Python CodesPhoto by Roman Mager on UnsplashContent Table· Introduction· Linear Transformation· Vectors and Operations∘ 1 Dimensional Vector∘ 2 Dimensional Vector∘ 3 Dimensional Vector∘ Scaling∘ Scaling Formula∘ Scaling Python Implementation∘ Scaler∘ L1 Norm∘ L2 Norm∘ L2 Norm Formula∘ L2 Norm Python Implementation∘ Vector Multiplication∘ Vector Multiplication Formula∘ Vector Multiplication Python Implementation∘ Vector Dot Operation∘ Vector Dot Formula∘ Vector Dot Python Implementation· Matrix Operations∘ Vector Matrix Multipication∘ Vector Matrix Multiplication Formula∘ Vector Matrix Python Implementation∘ Matrix Scalar Multiplication∘ Matrix Scalar Multiplication Formula∘ Matrix Scalar Multiplication Python Implementation∘ Matrix Matrix Multiplication∘ Matrix-Matrix Multiplication Formula∘ Matrix-Matrix Multiplication Python Implementation∘ Matrix Transpose∘ Matrix Transpose Formula∘ Matrix Transpose Python Implementation∘ Matrix Inverse∘ Matrix Inverse Formula∘ Matrix Inverse Python Implementation∘ Matrix Determinant∘ Matrix Determinant Python Implementation· Special Matrices∘ Square Matrix∘ Square Matrix Python Implementation∘ Identity Matrix∘ Identity Matrix Python Implementation∘ Orthogonal Matrix∘ Orthogonal Matrix Formula∘ Diagonal Matrix∘ Diagonal Matrix Formula∘ Diagonal Matrix Python Implementation· Reshaping Dimension∘ 1D to 2D∘ 1D to 2D Python Implementation∘ 2D to 3D∘ 2D to 3D Python Implementation· ConclusionHi to all.In this article, I try to indicate to you guys Linear Algebra terms, briefly.There are tons of really good videos and books, which will explain Linear Algebra A-Z.In my opinion, one of the most valuable ones is the following;Now, I took the class linear algebra at University, that’s why I already had prior knowledge, on the other hand, if you do not have prior knowledge of Linear Algebra and you love the visual stuff, this course is totally for you.And also this one is really good too.Honestly, after viewing too many courses + reading books, and taking notes, I again want to explain to you guys briefly, so in approximately 6–7 minutes, you will figure out much of these terms.If you are newly reading my article, I also have many A-Z articles about Statistic- Regression, Classification, and Machine Learning terms.Here are examples;I am writing these articles because I struggled while learning Machine Learning and I can not reach the right sources by writing that article, I am refreshing my knowledge about Linear Algebra.Repetition is the mother of learning, the father of action, which makes it the architect of accomplishment.” Zig ZiglarAfter many years, I have now discovered the things you should learn to master in Machine Learning.You can read my previous articles but briefly, you should be good in the following termsLinear AlgebraCalculusStatistics and ProbabilityProgramming – my choice is PythonGeneral Logic of Machine LearningAnd after knowing these things, it is good to test your skills in real-life data sets.You can find good data sets and also brief courses on Kaggle.Now let’s dive into the terms.Operations are made in the same linear space.1 Dimensional VectorVector, which has only 1 dimension.Shape: (x, )Image by Author2 Dimensional VectorVector, which only has 2 dimensions.Shape: (x,y)Image by Author3 Dimensional VectorVector, which has 3 Dimensions.Shape : (x,y,z)Image by AuthorScalingMultiplying vector with a number.Scaling FormulaImage by AuthorScaling Python ImplementationImage by AuthorScalerNow, z is a scaler.L1 NormThe length of a vector.(Manhattan Norm)Image by Author0.2,0.3,0.5 = 1Image by AuthorL2 Norm(Euclidean Norm)The euclidian calculation of a vector.L2 Norm FormulaImage by Author5,12 = 13 (square root(5’’2 + 12’’2 ))L2 Norm Python ImplementationImage by AuthorVector MultiplicationIf the length of both vectors is equal then we can do multiplication.Vector Multiplication FormulaWe simply multiply the corresponding elements of both vectors and then create a new vector.Image by AuthorVector Multiplication Python ImplementationImage by AuthorVector Dot OperationDot operations name come from the symbol we used to show this process.Image by AuthorVector Dot FormulaWhen calculating the dot product of a vector, we simply chose every element of both vectors and then calculate the sum.Image by AuthorLet us see the Python implementation of these actions.Vector Dot Python ImplementationImage by AuthorVector Matrix MultipicationAgain dot method.Vector Matrix Multiplication FormulaVector Matrix Python ImplementationImage by AuthorMatrix Scalar MultiplicationNow, let us multiply the vector with a scalar.Matrix Scalar Multiplication FormulaImage by AuthorMatrix Scalar Multiplication Python ImplementationImage by AuthorMatrix Matrix MultiplicationWhen we’ll do Matrix-matrix multiplication, we will use the dot method.Matrix-Matrix Multiplication FormulaImage by AuthorMatrix-Matrix Multiplication Python ImplementationImage by AuthorMatrix TransposeWe will use .T method.Matrix Transpose FormulaImage by AuthorMatrix Transpose Python ImplementationImage by AuthorMatrix InverseWhen the multiplication of two matrices results in the Identity matrix, one matrix will be another inverse.Matrix Inverse FormulaImage by AuthorMatrix Inverse Python ImplementationImage by AuthorMatrix DeterminantWe will use .det method to calculate a result.The result of the determinant of the matrix tells you if the matrix is invertible or not.When the end result is zero, which means the matrix has no inverse.Matrix Determinant Python ImplementationImage by AuthorSquare MatrixRow number = column numberSquare Matrix Python ImplementationImage by AuthorIdentity MatrixAll values from top left to right bottom, in the main diagonal are 1.Identity Matrix Python ImplementationImage by AuthorOrthogonal MatrixIf the result of the dot products of two vectors is zero, these two vectors are orthogonal.Orthogonal Matrix FormulaImage by AuthorDiagonal MatrixWhen the values except the main diagonal are zero, that will be a diagonal Matrix.Diagonal Matrix FormulaImage by AuthorDiagonal Matrix Python ImplementationImage by AuthorNow let’s look up dimension transformations.One dimension to two dimensions and two to three.Not if you read here it is important to remind that the .shape method returns a tuple (x,y).x = Number of Rowsy = Number of Columns1D to 2DNow here, a one-dimensional array is created, as we can see the shape.After that, we can use reshape method to create a 2d dimension.1D to 2D Python ImplementationImage by Author2D to 3DFirst, we define a 2D dimension array that transforms it into 3 as we use the first 2 dimensions according to our 2D dimension.2D to 3D Python ImplementationImage by AuthorOf course, there are many terms that can be related to Linear Algebra, however knowing these terms can give you a quick insight into Linear Algebra.Now you are familiar with Linear Algebra, you can develop your skills by reading books or watching courses.All codes used in these article are here;If you want to see other articles like this one and machine learning applications like Face Recognition & Loan Application Analysis, please subscribe to me;See you next time.“Machine learning is the last invention that humanity will ever need to make.” Nick Bostrom
Source: https://medium.datadriveninvestor.com/linear-algebra-a-z-for-machine-learning-68dadcd0b757