{"id":243902,"date":"2021-10-15T11:43:06","date_gmt":"2021-10-15T11:43:06","guid":{"rendered":"https:\/\/imarticus.org\/?p=243902"},"modified":"2024-03-21T05:26:24","modified_gmt":"2024-03-21T05:26:24","slug":"complete-guide-to-vectors-in-linear-algebra-with-implementation-in-python","status":"publish","type":"post","link":"https:\/\/imarticus.org\/blog\/complete-guide-to-vectors-in-linear-algebra-with-implementation-in-python\/","title":{"rendered":"Complete Guide To Vectors in Linear Algebra With Implementation in Python!"},"content":{"rendered":"<p>Mathematical implementation and mathematical functionality play a key role in understanding the workings of various physical entities. Creating mathematical models and mathematical measurements is essential to give shape to the theories and concepts. It also plays a vital role in writing code and new-age Machine learning algorithms.<\/p>\n<p><strong>Measurement:<\/strong><\/p>\n<p>Any attribute of an object that can be assigned with a meaningful number to observe, assess or understand the item is called Measurement. This measurement can be broadly divided into two types:<\/p>\n<ol>\n<li>Scalars<\/li>\n<li>Vectors<\/li>\n<\/ol>\n<p><strong>Scalars:<\/strong><\/p>\n<p>The measurement of the attribute of the objects doesn&#8217;t depend on the direction of the item.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-243903 size-full\" src=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/kqflqfq.png\" alt=\"Sclar\" width=\"220\" height=\"173\" \/>To illustrate the definition let us consider the length between two points. The span between these two points doesn&#8217;t change depending on the direction as the size remains the same.<\/p>\n<p><strong>Vectors:<\/strong><\/p>\n<p>The measurements of the attribute of the objects depend on the direction of the attribute too.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-243904 size-full\" src=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/jljjwljljg.jpg\" alt=\"Vector\" width=\"500\" height=\"338\" srcset=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/jljjwljljg.jpg 500w, https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/jljjwljljg-300x203.jpg 300w, https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/jljjwljljg-400x269.jpg 400w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<p>This can be understood by taking the example of force. Force needs a path with the numerical to comprehend the measurement<\/p>\n<p>Vectors are denoted by an Arrow (entirely\u2192).<\/p>\n<p>The direction where the vector points are called the vector&#8217;s direction.<\/p>\n<p><strong>Types of Vectors:<\/strong><\/p>\n<ol>\n<li>Zero Vector or Null Vector: A zero vector is the vector consisting Zero-Length and no direction<\/li>\n<li>Unit Vector: A vector that has a magnitude of 1 with a set direction.<\/li>\n<li>Collinear Vector: If the vectors are parallel to each other or on the same line irrespective of their direction.<\/li>\n<li>Coplanar Vector: All vectors that lie in the same plane<\/li>\n<li>Equal Vector: If the vectors have the same magnitude and direction<\/li>\n<li>Position Vector: A point that can be constituted as a constant point regarding other vectors<\/li>\n<\/ol>\n<p><strong>Implementation of vectors in Python:\u00a0<\/strong><\/p>\n<p>Vectors are a beneficial component not only in computer languages but also in machine learning. Decision-making is one of the most critical aspects of machine learning and vectors, in particular, is used in one such algorithm called Support Vector Machine (SVM). An SVM is used to analyze the given dimensional space for finding optimal hyperplane. The concept of vector\/Euclidean distance is used to know the distance between data points and hyperplane.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-243905 size-full\" src=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/hhfhw.jpg\" alt=\"Python Training\" width=\"348\" height=\"145\" srcset=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/hhfhw.jpg 348w, https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/hhfhw-300x125.jpg 300w\" sizes=\"auto, (max-width: 348px) 100vw, 348px\" \/>To achieve this through machine learning, we use Python as the programming language using libraries such as NumPy, Pandas. Python and the array operations in Python are useful to perform many algorithms such as SVM.<\/p>\n<p>Therefore, having a prior <a href=\"https:\/\/imarticus.org\/certification-in-artificial-intelligence-and-machine-learning-by-e-ict-iit-guwahati\/\"><strong>Python Training<\/strong><\/a> is valuable and essential to get a grip on how vector functionalities are applied in more advanced topics such as Machine Learning.<\/p>\n<p><strong>Implementation in Python:<\/strong><\/p>\n<p>Vector Implementation can happen through arrays in Python. All the vector functionality can be done through libraries like NumPy. Using a simple code, we can implement various basic vector functionalities such as<\/p>\n<ol>\n<li><strong>Vector Addition: The addition<\/strong>\u00a0of two vectors through Python can be seen here:<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-243906 size-full\" src=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/bjkbkb.gif\" alt=\"Vector\" width=\"710\" height=\"453\" \/><\/p>\n<p>import numpy as np #pip install numpy<\/p>\n<p>a=np.array([2,1,3])<\/p>\n<p>b=np.array([4,5,3])<\/p>\n<p>print(a+b)<\/p>\n<p>Output: [6,6,6]<\/p>\n<ol start=\"2\">\n<li><strong>Vector Subtraction: <\/strong>Subtraction of two vectors through Python can be seen here:<img loading=\"lazy\" decoding=\"async\" class=\"wp-image-243907 size-full alignright\" src=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nnwng.jpg\" alt=\"Vector Subtraction\" width=\"480\" height=\"360\" srcset=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nnwng.jpg 480w, https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nnwng-300x225.jpg 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/li>\n<\/ol>\n<p>import numpy as np<\/p>\n<p>a=np.array([2,3])<\/p>\n<p>b=np.array([1,-1])<\/p>\n<p>print(a-b)<\/p>\n<p>Output: [1,4]<\/p>\n<ol start=\"3\">\n<li><strong>Scalar Multiplication:<\/strong> Multiplying a scalar to vector is given below:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-243908 size-full\" src=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nnwg.png\" alt=\"Scalar Multiplication\" width=\"527\" height=\"469\" srcset=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nnwg.png 527w, https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nnwg-300x267.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/li>\n<\/ol>\n<p>import numpy as np<\/p>\n<p>a=np.array([3,5])<\/p>\n<p>print(3*a)<\/p>\n<p>Output: [9, 15]<\/p>\n<ol start=\"4\">\n<li><strong>Euclidean Distance calculations:<\/strong> In Euclidean distance calculation the distance is measured between two points and can be done in Python as follows:<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-243909 size-full\" src=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nng.png\" alt=\"Euclidean Distance calculations\" width=\"1200\" height=\"827\" srcset=\"https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nng.png 1200w, https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nng-300x207.png 300w, https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nng-1024x706.png 1024w, https:\/\/imarticus.org\/blog\/wp-content\/uploads\/2021\/03\/nng-768x529.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/li>\n<\/ol>\n<p>import NumPy as np #pip install NumPy<\/p>\n<p>a=np.array([4,6])<\/p>\n<p>b=np.array([7,-2])<\/p>\n<p>print(np.linalg.norm(a-b))<\/p>\n<p><strong>Output<\/strong>: 8.0622577<\/p>\n<p>These are some of the implementations of vectors in linear algebra using Python. Python is an essential language to understand advanced topics such as machine learning. Therefore, basic <a href=\"https:\/\/imarticus.org\/certification-in-artificial-intelligence-and-machine-learning-by-e-ict-iit-guwahati\/\"><strong>Python Training <\/strong><\/a>is the best step to ensure a great career.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mathematical implementation and mathematical functionality play a key role in understanding the workings of various physical entities. Creating mathematical models and mathematical measurements is essential to give shape to the theories and concepts. It also plays a vital role in writing code and new-age Machine learning algorithms. Measurement: Any attribute of an object that can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":243910,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_mo_disable_npp":"","_lmt_disableupdate":"no","_lmt_disable":"","footnotes":""},"categories":[23],"tags":[2068,2069,2070,2071,2072,2862,1037],"class_list":["post-243902","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-python-training","tag-analytics-and-artificial-intelligence-courses","tag-linear-regression-in-python","tag-vector-implementation-in-python","tag-python-online-tutorial","tag-linear-algebra-with-python","tag-python-courses"],"acf":[],"aioseo_notices":[],"modified_by":"Imarticus Learning","_links":{"self":[{"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/posts\/243902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/comments?post=243902"}],"version-history":[{"count":2,"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/posts\/243902\/revisions"}],"predecessor-version":[{"id":261105,"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/posts\/243902\/revisions\/261105"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/media\/243910"}],"wp:attachment":[{"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/media?parent=243902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/categories?post=243902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imarticus.org\/blog\/wp-json\/wp\/v2\/tags?post=243902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}