{"id":26896060,"url":"https://github.com/sofiasawczenko/linear_algebra_using_python","last_synced_at":"2026-02-10T21:04:01.150Z","repository":{"id":180000145,"uuid":"664429408","full_name":"sofiasawczenko/linear_algebra_using_python","owner":"sofiasawczenko","description":"The primary motivation behind establishing this repository was to disseminate knowledge about Linear Algebra through Python.","archived":false,"fork":false,"pushed_at":"2024-12-18T11:32:12.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-02T04:26:24.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sofiasawczenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-10T00:33:32.000Z","updated_at":"2024-12-18T11:33:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"d6bc099d-c1c7-4c97-96e8-e7ba97b1261c","html_url":"https://github.com/sofiasawczenko/linear_algebra_using_python","commit_stats":null,"previous_names":["sofiasawczenko/algebra_linear","sofiasawczenko/linear_algebra_using_python"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sofiasawczenko/linear_algebra_using_python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofiasawczenko%2Flinear_algebra_using_python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofiasawczenko%2Flinear_algebra_using_python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofiasawczenko%2Flinear_algebra_using_python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofiasawczenko%2Flinear_algebra_using_python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sofiasawczenko","download_url":"https://codeload.github.com/sofiasawczenko/linear_algebra_using_python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofiasawczenko%2Flinear_algebra_using_python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29316439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T20:44:44.282Z","status":"ssl_error","status_checked_at":"2026-02-10T20:44:43.393Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-01T02:59:31.867Z","updated_at":"2026-02-10T21:04:01.111Z","avatar_url":"https://github.com/sofiasawczenko.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Applied Linear Algebra in Data Analysis: A Practical Guide\n\nThe primary motivation behind establishing this repository was to disseminate knowledge about Linear Algebra through Python.\n\nLinear algebra serves as the foundation of machine learning, providing a mathematical framework for various algorithms. For example, considering a machine learning model that classifies images of handwritten digits. Linear algebra allows us to represent each image as a matrix of pixel values, enabling manipulation of the data for processing and analysis.\n\nDimensionality reduction is another important aspect where linear algebra techniques shine. For instance, Principal Component Analysis (PCA) utilizes linear algebra to identify the most significant features in a high-dimensional dataset. By reducing the dimensionality while preserving the essential information, PCA enhances computational efficiency and helps avoid the curse of dimensionality.\n\nMatrix operations play a vital role in machine learning algorithms. Suppose we have a dataset with multiple features and want to find the optimal weights for a linear regression model. By using linear algebra operations like matrix multiplication and solving systems of linear equations, we can efficiently calculate the weights that minimize the prediction errors.\n\nEigenvectors and eigenvalues are valuable concepts for understanding the underlying structure of data. For example, in the field of computer vision, eigenvectors and eigenvalues can be employed in techniques like Eigenfaces for face recognition. By analyzing the eigenvectors associated with the largest eigenvalues, relevant facial features can be extracted, enabling effective pattern detection and classification.\n\n## 1. **Vectors**\nVectors represent data points, feature sets, or results in many data analysis tasks.\n\n### Operations:\n- **Vector Addition**: Combine two vectors element-wise.\n\n```python\n  import numpy as np\n  v1 = np.array([1, 2, 3])\n  v2 = np.array([4, 5, 6])\n  result = v1 + v2  # [5, 7, 9]\n  print(result)\n```\n\n- **Dot Product:** Measure the similarity between two vectors.\n```python\ndot_product = np.dot(v1, v2)  # 1*4 + 2*5 + 3*6 = 32\nprint(dot_product)\n```\n- **Norm (Magnitude):** Calculate the length of a vector.\n```python\nnorm_v1 = np.linalg.norm(v1)  # √(1^2 + 2^2 + 3^2) = √14\nprint(norm_v1)\n```\n### Application in Data Analysis:\n- Feature Representation: Data points are often represented as vectors.\n- Similarity Calculation: Dot product is commonly used in calculating the similarity between data points (e.g., cosine similarity).\n\n## 2. Matrices\nMatrices are used to store data and perform transformations. Each row typically represents a data point, and each column represents a feature.\n\n### Operations:\n- **Matrix Multiplication:** Multiply two matrices (e.g., dataset by weights in machine learning).\n\n```python\nA = np.array([[1, 2], [3, 4]])\nB = np.array([[5, 6], [7, 8]])\nproduct = np.dot(A, B)  # Multiply matrices A and B\nprint(product)\n```\n- **Transpose:** Swap the rows and columns of a matrix.\n\n```python\ntranspose_A = A.T  # [[1, 3], [2, 4]]\nprint(transpose_A)\n```\n- **Inverse:** Solve systems of linear equations (if the matrix is invertible).\n\n```python\nA_inv = np.linalg.inv(A)  # Compute the inverse of matrix A\nprint(A_inv)\n```\n### Application in Data Analysis:\n- **Linear Regression:** Solve for model coefficients using matrix multiplication (normal equation).\n\n```python\nX = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])  # Feature matrix\ny = np.dot(X, np.array([1, 2])) + 3  # Target variable\ntheta = np.linalg.inv(X.T @ X) @ X.T @ y  # Normal equation solution\nprint(theta)\n```\n- **Data Transformation:** Matrices represent data transformations, like scaling or rotating data.\n\n## 3. Eigenvalues and Eigenvectors\nEigenvalues and eigenvectors help identify the directions of maximum variance in datasets, especially in dimensionality reduction techniques.\n\n### Operations:\n- **Eigen Decomposition:** Compute eigenvalues and eigenvectors of a covariance matrix.\n```python\ncovariance_matrix = np.cov(X.T)  # Covariance matrix of features\neigenvalues, eigenvectors = np.linalg.eig(covariance_matrix)\nprint(\"Eigenvalues:\", eigenvalues)\nprint(\"Eigenvectors:\", eigenvectors)\n```\n- **Application in Data Analysis:**\nPrincipal Component Analysis (PCA): Reducing the dimensionality of data while preserving as much variance as possible.\n```python\nfrom sklearn.decomposition import PCA\n```\n\npca = PCA(n_components=2)\nX_reduced = pca.fit_transform(X)  # Reduce features to 2 components\nprint(X_reduced)\n\n## 4. Singular Value Decomposition (SVD)\nSVD is a matrix factorization technique commonly used in dimensionality reduction and recommendation systems.\n\n### Operations:\nSVD: Decompose a matrix into three components (U, Σ, V).\n```python\nU, S, Vt = np.linalg.svd(X, full_matrices=False)  # Singular Value Decomposition\nprint(\"U:\", U)\nprint(\"S:\", S)\nprint(\"Vt:\", Vt)\n```\n- **Application in Data Analysis:**\nLatent Semantic Analysis (LSA): In text mining, SVD is used to reduce the dimensionality of term-document matrices.\n```python\nfrom sklearn.decomposition import TruncatedSVD\n```\n\nsvd = TruncatedSVD(n_components=2)\nreduced_matrix = svd.fit_transform(X)  # Reduce the matrix using SVD\nprint(reduced_matrix)\n\n\n## Conclusion\nLinear algebra provides essential tools for manipulating, transforming, and analyzing data. From simple operations like matrix multiplication to complex methods like PCA and SVD, these concepts are widely applied in data analysis and machine learning. Understanding and using these operations enables efficient data manipulation, transformation, and feature extraction, which are central to the data science workflow.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofiasawczenko%2Flinear_algebra_using_python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsofiasawczenko%2Flinear_algebra_using_python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofiasawczenko%2Flinear_algebra_using_python/lists"}