diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Computer Vision & Image Processing/Modules/Module 1 - Introduction to Computer Vision/Module 1 - Introduction to Computer Vision.md b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Computer Vision & Image Processing/Modules/Module 1 - Introduction to Computer Vision/Module 1 - Introduction to Computer Vision.md index 00089e442..5beca6376 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Computer Vision & Image Processing/Modules/Module 1 - Introduction to Computer Vision/Module 1 - Introduction to Computer Vision.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Computer Vision & Image Processing/Modules/Module 1 - Introduction to Computer Vision/Module 1 - Introduction to Computer Vision.md @@ -22,7 +22,7 @@ Computer vision is making significant waves in various industries due to its abi - **Scalability**: Enabling scalable solutions for various applications. #### Groundbreaking Change Self-driving cars are a notable example of computer vision's impact, automating driving and potentially saving lives. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d2ff3738-322b-4bed-b884-e286566efb94/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=79bfc673b70ff7b1f28f837f486cb599c465543a01f8779f75fdcdffafac6b1c&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d2ff3738-322b-4bed-b884-e286566efb94/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=59084633bc94cc28335e213a3b10bc2823d3fa6a8e886354a785885586299d13&X-Amz-SignedHeaders=host&x-id=GetObject) ### Applications Across Industries Computer vision has transformative applications in multiple sectors, including: - **Automotive** @@ -32,10 +32,10 @@ Computer vision has transformative applications in multiple sectors, including: - **Healthcare** #### Case Study: ADNOC ADNOC (Abu Dhabi National Oil Company) produces around 3 million barrels of oil and 10.5 billion cubic feet of raw gas daily. Traditionally, classifying rock samples was labor-intensive. By using IBM Watson for analyzing high-resolution rock images, ADNOC can classify up to 25,000 thin-section rock images per day, significantly saving time and resources. -![merlin_190903830_f0aa9789-8002-4443-889b-cf52a2291890-articleLarge.webp](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/00c2a896-0042-4cbe-a1e6-6bcda9bea64c/merlin_190903830_f0aa9789-8002-4443-889b-cf52a2291890-articleLarge.webp?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=ba3c256cfabfe89c36b8a9bcf0a3e899ca4dddb6f28fff8c60e906afc1c5df70&X-Amz-SignedHeaders=host&x-id=GetObject) +![merlin_190903830_f0aa9789-8002-4443-889b-cf52a2291890-articleLarge.webp](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/00c2a896-0042-4cbe-a1e6-6bcda9bea64c/merlin_190903830_f0aa9789-8002-4443-889b-cf52a2291890-articleLarge.webp?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=8bf70a88fd75e68f6c88aee6272d39916db92f07cd9595060ca2fe94c24b32cd&X-Amz-SignedHeaders=host&x-id=GetObject) #### Case Study: Knockri In the HR sector, Knockri, a Canadian startup, is revolutionizing hiring with an AI video soft skill assessment tool. By leveraging computer vision, machine learning, and data science, Knockri quantifies soft skills and assists in early candidate assessments, streamlining the hiring process for large companies. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4f485c63-f28c-48ae-b5ae-758411aae60b/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=4aca2c7546f0a9b88e3f8cf29798bc28ad6a08aadb49b89b29e8b611c5aa5937&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4f485c63-f28c-48ae-b5ae-758411aae60b/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=0bc478269d7caba9fd569fb48ff4cca29676b93f912616f4d5352dd03b9757f1&X-Amz-SignedHeaders=host&x-id=GetObject) ### Summary Computer vision is rapidly transforming industries by enhancing automation, cost-efficiency, and scalability. Its applications are broad, impacting everything from oil classification to hiring processes. ___ @@ -44,7 +44,7 @@ ___ In this section, we explore various applications of computer vision and discuss how you can develop your own applications. ### Searching Through Videos One common challenge is searching through videos to find specific scenes. Traditionally, this requires fast-forwarding and manual searching. IBM has addressed this by tagging videos with keywords based on the objects present in each scene. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/6611b4b5-7716-4238-9394-371b7f97dd8d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=6c67af320890a1a6db52f02b064cc729a8a0d753ce7444db69682494038867d6&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/6611b4b5-7716-4238-9394-371b7f97dd8d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=9944a3302029fc7070a6a385fbf9069f2d145abf2ac14ba3ce540ec21b3ff14f&X-Amz-SignedHeaders=host&x-id=GetObject) ### Security and Object Recognition Imagine a security company needing to find a suspect in a blue van among hours of footage. With computer vision and object recognition, this task becomes manageable and efficient, eliminating the need for extensive manual searching. ### Maintenance of Electric Towers @@ -56,7 +56,7 @@ By dividing high-resolution images into smaller segments, you can develop custom - **Grade 1 Rust**: Minimal rust - **Grade 6 Rust**: Severe rust This approach can save significant costs for industries like insurance by automating the analysis of thousands or millions of images. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/16d9e2cd-921b-4673-9544-fd20224f176c/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=3a140a2b6a230dc1cc0ee778d34e48a80a3c386d10702b8de768b9cff2af45bf&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/16d9e2cd-921b-4673-9544-fd20224f176c/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=04a621ec08192bbd591e3ce367a000a2481dfca6670db956affe74d01d0e373f&X-Amz-SignedHeaders=host&x-id=GetObject) ### Insurance Claims Processing Computer vision can also streamline the processing of insurance claims by automatically classifying damage, such as hail or ice pellet damage from storms. This improves efficiency and accuracy, reducing the time and cost associated with claim processing. ### Summary @@ -67,13 +67,13 @@ ___ This section covers recent advancements and ongoing research in the field of computer vision over the past decade. ### Object Detection Researchers at Facebook are focusing on detecting objects in images. Accurate and efficient object detection is crucial for making meaningful inferences from images and video streams. This capability is particularly important for applications such as self-driving cars, where real-time object detection from camera feeds is necessary to avoid obstacles and prevent collisions. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4abd25e4-e758-4223-b0a0-c40adde5fd3d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=29881fb40f688462da55b75b27a4262faa8fcea75ccde65bbf5d234dc7fa140a&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4abd25e4-e758-4223-b0a0-c40adde5fd3d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=3d94dda93de3fc1358ad1a2fd94685c83ffcb076962b5ad4cd6072662fc10f7f&X-Amz-SignedHeaders=host&x-id=GetObject) ### Image to Image Translation Image to image translation involves converting an image from one representation to another. For example, transforming an image of a horse into a zebra or changing the scene of an image from summer to winter. Researchers at UC Berkeley are working on techniques for this kind of transformation, allowing for significant modifications in image content. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f4c69140-8edb-4b9c-9a3e-3ea01fdcda90/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=eee09d06b4f05a7ad6f86707cde4a95cb3921f5dfd18c83cead2f81d061a8921&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f4c69140-8edb-4b9c-9a3e-3ea01fdcda90/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=453b4bff18d340dce41bca235e5223dc32ab37745fe80eb60959438ffbe039cf&X-Amz-SignedHeaders=host&x-id=GetObject) ### Motion Transfer The "Everybody Dance Now" project demonstrates computer vision techniques for motion transfer. This project allows the dance moves of a person in a video to be transferred to another person, enabling the target to perform the same dance moves as the original subject. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e5b2060e-a889-4469-90bd-3920e03b6e3d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=4afd40b50946ddbfa0b206e2b11be6ae0db18d69e55b138f3e648717d805aa9c&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e5b2060e-a889-4469-90bd-3920e03b6e3d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=6d61db63e5179b93e72c00904da2d7445f6dec1ba3f9614d13c1763ac236f7b9&X-Amz-SignedHeaders=host&x-id=GetObject) ### Summary Recent research in computer vision includes advancements in object detection, image to image translation, and motion transfer. These innovations are enhancing the capabilities of computer vision systems and expanding their applications in various domains. ___ diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Computer Vision & Image Processing/Modules/Module 2 - Image Processing with OpenCV and Pillow/Module 2 - Image Processing with OpenCV and Pillow.md b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Computer Vision & Image Processing/Modules/Module 2 - Image Processing with OpenCV and Pillow/Module 2 - Image Processing with OpenCV and Pillow.md index 6e8f06cbb..91e61dad1 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Computer Vision & Image Processing/Modules/Module 2 - Image Processing with OpenCV and Pillow/Module 2 - Image Processing with OpenCV and Pillow.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Computer Vision & Image Processing/Modules/Module 2 - Image Processing with OpenCV and Pillow/Module 2 - Image Processing with OpenCV and Pillow.md @@ -9,28 +9,28 @@ Each pixel is represented by a **numerical intensity value**: - **Intensity values** range between **0 and 255**, where: - **0** represents **black**. - **255** represents **white**. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fa1bb4aa-313a-44c2-a7b3-7fa4a8432b08/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=f959fce37d8841e4d65de9239d7e15606c0550631b111df014f08822007bee1a&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fa1bb4aa-313a-44c2-a7b3-7fa4a8432b08/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=9fd05e022e68ff91e926df59e6f5569fedcc94975ad5112d32ccb787591a1f06&X-Amz-SignedHeaders=host&x-id=GetObject) The number of intensity values directly impacts the **contrast** of the image: - Higher intensity values provide better **contrast**. - Reducing intensity values can result in visual changes, as seen in the following steps: - **256 intensity values**: The image appears clear and accurate. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0de7dfb4-99dc-4b87-8932-5165b3c3b775/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=3f67d0b791774622c6e6a2830af9a3f7db37af5456e5aca0c0253795f212e311&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0de7dfb4-99dc-4b87-8932-5165b3c3b775/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=35bda3eb456479934e38dbf96beca9c90ac4f22bbea722736332edff3c0652ce&X-Amz-SignedHeaders=host&x-id=GetObject) - **32 intensity values:** -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7eb81f08-b190-4c5a-ba2b-2a498a15b2c4/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=f899c12710194dbb10f8286d6de59b33878fc4ca09116e3896bfa50458164be5&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7eb81f08-b190-4c5a-ba2b-2a498a15b2c4/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=37e97c1a6fe0894569320b9931f1727153735db2ad9f2f86f387313876637a30&X-Amz-SignedHeaders=host&x-id=GetObject) - **16 intensity values**: Differences are noticeable in low-contrast areas. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/6bf56d44-9a14-4b7b-98c2-1f00b8630f0c/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=b5f88c355ea13a24b9dd82bd42348716f0080c353309e4d98e2810e9c5ee5ded&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/6bf56d44-9a14-4b7b-98c2-1f00b8630f0c/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=607cd1a21d48a3b826d60adc9ab8755405a1f8a423d9e3f065beb6a0cd911053&X-Amz-SignedHeaders=host&x-id=GetObject) - **8 intensity values**: The image begins to lose definition. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cca05878-ca1a-43e0-8bec-1d146756f9ae/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=510473065aa315dff386ac6e9a1e9c236f32efe7323a5868d10c00d63ec1b4e2&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cca05878-ca1a-43e0-8bec-1d146756f9ae/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=b86f926a610fb9c8f99cd9e595ffea687e61fcdf8809567395aab2a45283cc8d&X-Amz-SignedHeaders=host&x-id=GetObject) - **2 intensity values**: The image looks cartoonish. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/12da64d7-6b97-44e0-bc2c-52b9c47ce212/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=e45dcf60046ac01acd26645b65d30d96c717ca2b87241a26639a630a2b77cacf&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/12da64d7-6b97-44e0-bc2c-52b9c47ce212/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=3effe4f9f34534703f07674fef860c7109d592ee7de0a8576089a3aeb79c5ecb&X-Amz-SignedHeaders=host&x-id=GetObject) #### Image Dimensions - The **height** represents the number of **rows**. - The **width** represents the number of **columns**. - Each pixel is indexed based on its position in the row and column. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ff056335-e79e-4491-b508-30cd45b6c194/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=e3e9533cdbc1fe0dcb57d318f824043388f6b14086a96abd88945f91b7be92f2&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ff056335-e79e-4491-b508-30cd45b6c194/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=24331ddae876a3a86a75c086de97933b0f48b42eba81a83a590454ec02fc921f&X-Amz-SignedHeaders=host&x-id=GetObject) #### Image Composition In **real-world images**, each pixel value comes from a grid of **sensors** that capture light. These values are then **quantized** into digital samples to form the image. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c721ea0-409b-4d32-b630-a00d6f170d18/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=4974fd0a839aed61015d1f45456093464d07725399c4b6293c255bc5a80ab676&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c721ea0-409b-4d32-b630-a00d6f170d18/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=803864d5e262b6f0de60055ed16c98a5a8fe3f32b2a2e11ac6e9d6aa252b325e&X-Amz-SignedHeaders=host&x-id=GetObject) ### Color Images and Channels A **color image** is composed of different **color channels** (e.g., **red**, **green**, and **blue**): - Each channel is essentially a **gray-scale image** representing intensity values for that color. @@ -39,11 +39,11 @@ For example: - **Red channel**: Represents red intensities. - **Green channel**: Represents green intensities. - **Blue channel**: Represents blue intensities. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c0cc17c9-842f-413f-82e8-f3f44278cf74/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=ee279a64ae44e87370c11ae7ea929e18a0ee3c17dffb75c9abf82dfac9db37eb&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c0cc17c9-842f-413f-82e8-f3f44278cf74/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=5bb90615bb1364c6d5b45c395e8da1684e9daca3eb9812e4c123f58c2c2dd59e&X-Amz-SignedHeaders=host&x-id=GetObject) #### Image Masks - A **binary mask** can be used to identify specific objects in an image. - Pixels corresponding to the object are represented as **1**, while the rest are **0**. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/667eab4d-d19d-4618-81d0-663b6beb002c/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=0013c0f9cecdd9052005b15e7ecaaf57ab817c38a70d0977cd6ebee724d683b6&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/667eab4d-d19d-4618-81d0-663b6beb002c/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=5c0b7d1cfb6d5dec45fbc244f8218df2ad97beee2bfd96f1aae079fc55f12c47&X-Amz-SignedHeaders=host&x-id=GetObject) ### Video Sequences A **video** can be viewed as a sequence of multiple **images** or **frames**. ### Image Formats @@ -102,7 +102,7 @@ gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) ```python cv2.imwrite('output.png', img) ``` -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/25fcc977-54ea-484c-997e-9b6bd016f347/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=3561af665ff6e1fea15f178ec34c0e8da7c0cbebfe81ab10503d430590e5f8b7&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/25fcc977-54ea-484c-997e-9b6bd016f347/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=0fbc2a7d51e8debc31dcf8fe7d98f23eca913cbdbceb53544ffb1a9f895f7e4e&X-Amz-SignedHeaders=host&x-id=GetObject) ### Working with Color Channels Using **slices**, individual color channels (e.g., **blue**, **green**, **red**) can be extracted: ```python diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Helpers/Achievements/Achievements.md b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Helpers/Achievements/Achievements.md index bc19f75c0..77a37a6de 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Helpers/Achievements/Achievements.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Helpers/Achievements/Achievements.md @@ -2,6 +2,6 @@ # Achievements ## Certificate -[Deep_Learning_Essentials_with_Keras_Certificate.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f5cf1405-8a02-49a4-beb6-3d50b033ba6e/Deep_Learning_Essentials_with_Keras_Certificate.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=d7208972715b74ba4b9fdddeff9522ad395581a5cd27bc6159db7eb10e71a549&X-Amz-SignedHeaders=host&x-id=GetObject) +[Deep_Learning_Essentials_with_Keras_Certificate.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f5cf1405-8a02-49a4-beb6-3d50b033ba6e/Deep_Learning_Essentials_with_Keras_Certificate.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=cb7f07c66eabb3176c0c02ba64a19723db9966ff1203c70ddfdff735f287e2ae&X-Amz-SignedHeaders=host&x-id=GetObject) ## Badge -[Deep_Learning_Essentials_with_Keras_Badge.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5c209097-6d96-477f-a031-edc11aa6225f/Deep_Learning_Essentials_with_Keras_Badge.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=e8c5ae5038726ac48c221405a8a847083820a2d25c6a384a45a06aa1dcb90466&X-Amz-SignedHeaders=host&x-id=GetObject) +[Deep_Learning_Essentials_with_Keras_Badge.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5c209097-6d96-477f-a031-edc11aa6225f/Deep_Learning_Essentials_with_Keras_Badge.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=cc0fc6f3f3f8ad5d66f2c775235211271d39516063e08330240d02aab5b8ac1c&X-Amz-SignedHeaders=host&x-id=GetObject) diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 1 - Introduction to Neural Networks and Deep Learning/Module 1 - Introduction to Neural Networks and Deep Learning.md b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 1 - Introduction to Neural Networks and Deep Learning/Module 1 - Introduction to Neural Networks and Deep Learning.md index 9239b3423..b0fc9f59e 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 1 - Introduction to Neural Networks and Deep Learning/Module 1 - Introduction to Neural Networks and Deep Learning.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 1 - Introduction to Neural Networks and Deep Learning/Module 1 - Introduction to Neural Networks and Deep Learning.md @@ -5,15 +5,15 @@ Deep learning has emerged as one of the most exciting fields in data science, with recent advancements leading to groundbreaking applications that were once considered nearly impossible. This note explores some of these remarkable applications and provides insights into why deep learning is currently experiencing such rapid growth. ### Color Restoration Color restoration is a fascinating application where grayscale images are automatically transformed into color. Researchers in Japan developed a system using Convolutional Neural Networks (CNNs) to achieve this. The system takes grayscale images and adds color to them, bringing them to life. This technology demonstrates the impressive capabilities of deep learning in image processing. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/de1ebdcc-ed41-4a91-9f79-4632dc723c89/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=ff565e7aa2cf7b11343f0b229e4d7e3bb7c07a18267108624793afa6ef6a5d6b&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/de1ebdcc-ed41-4a91-9f79-4632dc723c89/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b7d8a28c4cfa8dc5e2501f5b5878370841bfe651a112b671da7699642b63d90a&X-Amz-SignedHeaders=host&x-id=GetObject) ### Speech Enactment Speech enactment involves synthesizing audio clips with video and synchronizing lip movements with the spoken words. A notable advancement in this area was achieved by researchers at the University of Washington, who trained a Recurrent Neural Network (RNN) on a large dataset of video clips featuring a single person. Their system, demonstrated with a video of former President Barack Obama, produces realistic results where lip movements match the audio accurately. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/93a191f0-d690-489c-86db-10d8d79d6eb6/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=9395466530b84f85c846f763647a1e0ec411205914798b08dded635bc09f972c&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/93a191f0-d690-489c-86db-10d8d79d6eb6/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=5e9f50c845e1e6d436801fb3c6b4c01135eb52dbd8d4a822d4c3f661123019bb&X-Amz-SignedHeaders=host&x-id=GetObject) The system can also extract audio from one video and sync it with lip movements in another, showcasing the versatility of this technology. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0acad1f2-660b-42b0-a6a5-271476be67f2/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=49cfdc733f1170c80cdd3080b44efbe802fec195d6d83f124ef2aab7cb89fc75&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0acad1f2-660b-42b0-a6a5-271476be67f2/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=3377390b35955771aab703da5cc5c1d5f857e508f645375ce3074f492c7ed996&X-Amz-SignedHeaders=host&x-id=GetObject) ### Automatic Handwriting Generation Alex Graves from the University of Toronto designed an algorithm using RNNs for automatic handwriting generation. This algorithm can rewrite text in highly realistic cursive handwriting across various styles. Users can input text and either select a specific handwriting style or let the algorithm choose one randomly. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f465b5fe-6e89-4df1-9bda-c23bd9e0e9fe/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=abaf89b65929463bd8669fac4e3a36cb40a25f3c90b2c02e3567c6019e1021ab&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f465b5fe-6e89-4df1-9bda-c23bd9e0e9fe/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=d72f92bd802ec3704dd5295fde1036b96cbb610b389340ea8220a77f6f337969&X-Amz-SignedHeaders=host&x-id=GetObject) ### Other Applications Deep learning encompasses a wide range of applications, including: - **Automatic Machine Translation**: Using CNNs to translate text in images in real-time. @@ -36,7 +36,7 @@ Neurons are the fundamental units of the brain, responsible for processing and t - **Synapses (Terminal Buttons)**: The endings of the axon, which pass the impulses (short electrical signals that carries information) to the dendrites of adjacent neurons. #### Functioning of a Biological Neuron Neurons receive electrical impulses through dendrites, process these impulses in the soma, and transmit the processed information through the axon to other neurons via synapses. Learning in the brain occurs by reinforcing certain neural connections through repeated activation, which strengthens these connections and makes them more likely to produce a desired outcome. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0dd23e6a-8e6b-4b90-ab92-b198a36f7f9e/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=532dbebe2f60097f45d7ca440fd06cb24850c2eac9aaa23f8c44725f5809c067&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0dd23e6a-8e6b-4b90-ab92-b198a36f7f9e/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=81f9df344499f87abde3fde7fc6a6bf6ab93caec9f4d02e5bef13d2d706f1217&X-Amz-SignedHeaders=host&x-id=GetObject) ### Artificial Neurons: Mimicking the Brain Artificial neurons are modeled after biological neurons, incorporating similar components and processes: - **Artificial Dendrites**: Receive input data from other neurons. @@ -45,7 +45,7 @@ Artificial neurons are modeled after biological neurons, incorporating similar c - **Artificial Synapse**: The connection point where the output of one neuron becomes the input to another. #### Learning in Artificial Neural Networks The learning process in artificial neural networks closely resembles that of the brain. Through repeated activation and adjustment, the connections between artificial neurons are strengthened, enabling the network to produce more accurate outputs given specific inputs. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/21c84c18-4b2b-4801-9395-3704469dc902/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=cabf2af02cd8813420c9e4fb5fd0cd0abdb543303e7a296e226b67e972e301b7&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/21c84c18-4b2b-4801-9395-3704469dc902/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=179419837e5b621cd5d2ace1655f2c15a4c379e1c3bde27066074d050c97cd66&X-Amz-SignedHeaders=host&x-id=GetObject) ### Summary Neural networks, both biological and artificial, operate on the principle of processing inputs and transmitting outputs through interconnected neurons. The design of artificial neurons, inspired by the structure and function of biological neurons, allows deep learning models to emulate the learning processes of the human brain. Understanding this connection between biology and artificial intelligence provides a foundation for further exploration into the workings of neural networks. *Additional Notes*: The detailed understanding of both biological and artificial neurons is essential for grasping the complexities of deep learning models and their applications. Further study on how these artificial systems learn and adapt will be covered in subsequent videos. @@ -60,7 +60,7 @@ This note discusses the mathematical formulation of neural networks, focusing on - **Input Layer**: The first layer that feeds input into the network. - **Output Layer**: The final layer that provides the output of the network. - **Hidden Layers**: Layers between the input and output layers. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5e6fffd9-92d0-419c-8e5d-3ad04d1b89bd/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=42bab328194161fd87c26620767901075903875da083cea9f157d8c85dc20c06&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5e6fffd9-92d0-419c-8e5d-3ad04d1b89bd/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=6349b1276dcb9003531b3abd02c420d8d172949a04400dccc673d5fb6671a00a&X-Amz-SignedHeaders=host&x-id=GetObject) ### Forward Propagation #### Definition Forward propagation is the process through which data passes through the layers of neurons in a neural network, moving from the input layer to the output layer. @@ -95,7 +95,7 @@ $$ z_2 = w_2 \cdot a_1 + b_2 = 0.25 \cdot 0.6023 + 0.5 = 0.6506 $$ **Step 2: Apply Sigmoid Function** $$ a_2 = \sigma(z_2) \approx 0.7153 $$ This is the predicted output for the given input. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/97c4b922-6cf5-4a71-95cf-068db25c64b9/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=ffea1bdd84e903ad53dd1890c9867540f1a1fa80c4d985687b706fcad7a149b1&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/97c4b922-6cf5-4a71-95cf-068db25c64b9/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=a41f4eadf57ba008b6e4be0192590b1c8b9f05c97c4d34715b75f65cdbc117b5&X-Amz-SignedHeaders=host&x-id=GetObject) ### Activation Functions #### Importance - Activation functions introduce non-linearity into the network, enabling it to learn and perform complex tasks. diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 2 - Artificial Neural Networks/Module 2 - Artificial Neural Networks.md b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 2 - Artificial Neural Networks/Module 2 - Artificial Neural Networks.md index b11ee3860..fab756085 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 2 - Artificial Neural Networks/Module 2 - Artificial Neural Networks.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 2 - Artificial Neural Networks/Module 2 - Artificial Neural Networks.md @@ -10,34 +10,34 @@ Suppose we have a dataset where $ z $ is twice the value of $ x $. Our goal is The cost function measures the difference between the actual values of $ z $ and the values predicted by the model, i.e., $ wx $. It is given by: $$ J(w) = \sum_{i=1}^{n} \left( z_i - w \cdot x_i \right)^2 $$ The objective is to find the value of $ w $ that minimizes this cost function, leading to the best fit line for the data. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/bd20068e-2350-4c53-ba35-db137540515b/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=c370a773662da13baca79f92e8b0cd05279d93eae6a1ed231577b5bc1077a475&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/bd20068e-2350-4c53-ba35-db137540515b/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=4f1633536d4d8d6205adae020ee547e721ae517fe3d2b484b807f88e84fe17f0&X-Amz-SignedHeaders=host&x-id=GetObject) #### Example: Simple Linear Data For simplicity, consider the case where $ z=2x $. The optimal value of $ w $ that minimizes the cost function is $ w=2 $, as it perfectly fits the line $ z=2x $. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ce186573-efd7-45c0-81e8-d88b278d76c0/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=cdc6c61878de71e11f0740f64ceb60a4602783ab618a1a691e90c540253f587e&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ce186573-efd7-45c0-81e8-d88b278d76c0/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b2dea01ca9ab4c085a191cbfb666725a614454aa4a4a001157f74f73b58ce05e&X-Amz-SignedHeaders=host&x-id=GetObject) ### Introduction to Gradient Descent Gradient descent is an iterative optimization algorithm used to find the minimum value of a function. It is particularly useful for minimizing the cost function in neural networks. #### How Gradient Descent Works 1. **Initialization**: Start with a random initial value of $ w $, denoted as $ w_0 $. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/3a4b2b9f-74fe-40ea-bd5f-b6da8e8a1b53/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=81dbd27b6285ef43b8db24403cd72f776847006415443a30df72df8f9d28f8e7&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/3a4b2b9f-74fe-40ea-bd5f-b6da8e8a1b53/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=3cf193f5078611d971738a2a02651b6c08f4f73f9bbe6420656617af580e4de1&X-Amz-SignedHeaders=host&x-id=GetObject) 2. **Compute the Gradient**: Calculate the gradient (slope OR derivative) of the cost function at the current value of $ w $. The gradient indicates the direction in which the cost function is increasing. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8bba6cc9-bbcb-4ba7-a8b7-d5c36ae63437/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=85e38df78900bd09a37773f7d11588b2f9b7f26ad0f1acc1c6f14861fb3873da&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8bba6cc9-bbcb-4ba7-a8b7-d5c36ae63437/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=8c986533beb523f48c8c504e653e42a8719404a3bc7ae1094ddf40f9673592ff&X-Amz-SignedHeaders=host&x-id=GetObject) 3. **Update Rule**: Adjust the value of $ w $ by moving in the direction opposite to the gradient. This is done using the formula: $$ w_{i+1} = w_i - \alpha \cdot \text{gradient}(J(w_i)) $$ Here, $ \alpha $ is the learning rate, controlling the step size. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/42a2d642-6adb-46de-883a-9c979db13be1/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=9a9a6e016281bbe4a0c7aa6564eec33a4b36fcad533a76be6d393ed5bfa6bdfd&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/42a2d642-6adb-46de-883a-9c979db13be1/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=94edb9a653d393640ddfe27afdb1f4305c975b04693450201f05b0e0df392136&X-Amz-SignedHeaders=host&x-id=GetObject) 4. **Iteration**: Repeat the process until the algorithm converges to the minimum value of the cost function or a value close to it. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/045d3977-5b07-4e2d-a476-fe683b0708a1/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=a6cf80811a49a90de911b86399c7a3687312882ad57c707363a2b31dba92516d&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/045d3977-5b07-4e2d-a476-fe683b0708a1/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=71085e796e56064a280891c9edd1ef1c28b982f41024ed98ab324a769097f6fc&X-Amz-SignedHeaders=host&x-id=GetObject) #### Choosing the Learning Rate - **Large Learning Rate**: Can cause the algorithm to overshoot the minimum, leading to divergence. - **Small Learning Rate**: Can result in slow convergence, making the algorithm take a long time to reach the minimum. #### Example with Iterations Assume we start with $ w_0=0.2 $ and use a learning rate $ \alpha = 0.4 $: - **1st Iteration**: $ w_1 $ moves closer to the optimal value $ w=2 $, causing a significant drop in the cost function. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/2ec0fa27-9d1b-46d9-9353-5593db897df3/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=635d36359114883b5d3f58ea7b4ca218cf9cd8c09545e7a61bc3ce8fc24b90d9&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/2ec0fa27-9d1b-46d9-9353-5593db897df3/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=69aedaf0bbf29aec9cfeb3e297dc8ab371120f3c34051df36c3686a87aaa51c6&X-Amz-SignedHeaders=host&x-id=GetObject) - **2nd Iteration**: $ w_2 $ continues to move towards $ w=2 $, with a smaller step as the slope decreases. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/3162cdb0-ddff-47b5-ada6-d09807f482dd/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=e896cf7946894edc27f4e34a0f9fd3559ecd813fd36794ae95e0781e1663e5f0&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/3162cdb0-ddff-47b5-ada6-d09807f482dd/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=ba8c4d38fb5d8b972f1d4b8e2855169cbee7da933270fcb0f620c8d3212db41f&X-Amz-SignedHeaders=host&x-id=GetObject) - **Subsequent Iterations**: The steps become smaller as the algorithm approaches the minimum, with the cost function value decreasing steadily. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ff65aa88-841b-4a86-8b66-352055ba85a8/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=5fc6514ebd4585c42f6696b7cd1fdd2f2edf64844628c6b76bacc498ffc11ebd&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ff65aa88-841b-4a86-8b66-352055ba85a8/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=8f01f0fcccef49785012a764412de4c3ba1eae77f6ac84579aa5508cb1aa02a1&X-Amz-SignedHeaders=host&x-id=GetObject) ### Application in Neural Networks In neural networks, gradient descent is used to optimize multiple weights and biases simultaneously. The algorithm updates each parameter in a way that minimizes the overall cost function, which measures how well the network's predictions match the actual data. #### Forward Propagation and Gradient Descent @@ -67,9 +67,9 @@ Backpropagation is the method used to calculate the gradients of the error with #### Example with One Input and Two Neurons Consider a network with two neurons: - **Forward Propagation:** Compute the weighted sums $ z_1, z_2, $ and the outputs $ a_1, a_2 $. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a695635c-0446-4714-a226-718ac9577549/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=bce92dcd37ef8999d81eabbd6a19dba31afd28dbd973a7b88226f15c9c16095e&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a695635c-0446-4714-a226-718ac9577549/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=4aa06de642b682e891acd39896ae2bb17919e61f86fe271d715405649c4abec8&X-Amz-SignedHeaders=host&x-id=GetObject) - **Backpropagation:** If the ground truth is known (e.g., 0.25), the error between the prediction and ground truth is calculated. The weights and biases are then updated using the gradients and a learning rate of 0.4. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fd5117c8-af5b-46ec-857b-f6ad4622631f/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=b3d3da63adc8ad4dadef7318c18a39eb0382b71432939c97c488428342f7df7b&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fd5117c8-af5b-46ec-857b-f6ad4622631f/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171423Z&X-Amz-Expires=3600&X-Amz-Signature=dbedf16e21277e13dd73f33a4d23f380af42560939dad853e766745c6337844e&X-Amz-SignedHeaders=host&x-id=GetObject) #### Weight Update Equations For the second neuron: - **Derivative of Error (E) with Respect to Weight **$ w_2 $**:** @@ -77,8 +77,8 @@ $$ \frac{\partial E}{\partial w_2} = -(T - a_2) \times a_2 \times (1 - a_2) \tim - **Update Rule for Weight **$ w_2 $**:** $$ w_2 = w_2 - \text{learning rate} \times \frac{\partial E}{\partial w_2} $$ Similarly, the biases are updated using the derivatives with respect to the biases. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/3ed6542e-ad49-481c-bce8-115e2cb8faf9/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=a646075108e45a104179bcd5d473e42e76a9ec39197c47b3532e3b5899bd3d28&X-Amz-SignedHeaders=host&x-id=GetObject) -[NaQwXc72EemgrQ4z3gANog_5cdaec1e385342c1a8095e8b6c3eb7ad_Partial_Derivatives_Backpropagation.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/038b0865-3aac-462b-bab6-083877527b3b/NaQwXc72EemgrQ4z3gANog_5cdaec1e385342c1a8095e8b6c3eb7ad_Partial_Derivatives_Backpropagation.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=2e735b6a71a072d76799600f6933e2fc96c3ab7168b1e39f3e1271439c8ca3f3&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/3ed6542e-ad49-481c-bce8-115e2cb8faf9/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=f00d99c60c9286e9eaf49576c52362e3eb5b3f7f8a8bf80295de20adab2aede5&X-Amz-SignedHeaders=host&x-id=GetObject) +[NaQwXc72EemgrQ4z3gANog_5cdaec1e385342c1a8095e8b6c3eb7ad_Partial_Derivatives_Backpropagation.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/038b0865-3aac-462b-bab6-083877527b3b/NaQwXc72EemgrQ4z3gANog_5cdaec1e385342c1a8095e8b6c3eb7ad_Partial_Derivatives_Backpropagation.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=41e939c8ef0afa82b3e9753d4bf985d75db65ece5c1db5c4402cd85506c18520&X-Amz-SignedHeaders=host&x-id=GetObject) #### Iterative Training Process Training involves repeatedly performing the following steps until the error is minimized: 8. **Forward Propagation:** Calculate the network output. @@ -93,12 +93,12 @@ The **vanishing gradient problem** is a significant issue associated with using ### Problem Description - **Sigmoid Activation Function**: The sigmoid function maps input values to a range between 0 and 1. While this can be useful, it leads to problems during backpropagation. - **Gradients in Backpropagation**: During backpropagation, the gradients of the error with respect to the weights are computed. For the sigmoid function, the gradient (derivative) of the activation function is always between 0 and 1. This causes the gradients to become very small as they are propagated backward through the network. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1300f8d7-31e2-4054-a375-dd0677d27731/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=d07f0135a3a1cf600e4b0c47599f653b902622585da38e07e9dab25d6a748d16&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1300f8d7-31e2-4054-a375-dd0677d27731/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=e812ad8a208f2a01c8e3dd4e6f226f661a0fcaf4c75118f60aeb3331614fa7fa&X-Amz-SignedHeaders=host&x-id=GetObject) - **Effect on Learning**: In a neural network with multiple layers, gradients of weights in earlier layers become very small. This results in: - **Slow Learning**: Neurons in earlier layers learn very slowly compared to neurons in later layers. - **Long Training Time**: Training takes significantly longer. - **Compromised Accuracy**: The prediction accuracy of the network may be affected due to inefficient learning in earlier layers. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5eeb41c8-279a-4556-a186-f41c06da54f6/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=e4a4526a54275365b967645074b6651789d39f7fe6cc90c43f9b232690a31170&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5eeb41c8-279a-4556-a186-f41c06da54f6/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=f37ca54386cd69659bcc808939816515437a4a68495246160f26faab0567f578&X-Amz-SignedHeaders=host&x-id=GetObject) ### Mathematical Insight When using the sigmoid function, the derivatives of the activation function can be very small. During backpropagation, the gradient of the error with respect to the weights is calculated as a product of these derivatives. Thus, gradients tend to diminish as they propagate backward through the network: $$ \text{Gradient} = \frac{\partial E}{\partial w_i} = \frac{\partial E}{\partial a_n} \cdot \frac{\partial a_n}{\partial z_n} \cdot \frac{\partial z_n}{\partial w_i} $$ @@ -129,7 +129,7 @@ Activation functions are crucial for the learning process of neural networks. Th $$ \sigma(z) = \frac{1}{1 + e^{-z}} $$ #### Range $$ (0, 1) $$ -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/20bb4bb6-02a5-4a68-8fe0-6a70da31ed6a/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=3c273f6b0210740278f1ba26d4accf813c5c203558b8c2994c2b282e1c128908&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/20bb4bb6-02a5-4a68-8fe0-6a70da31ed6a/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=030157f52b588df03da33714950a463c4be6ebbc13079089e35f6f2f6be4e0e7&X-Amz-SignedHeaders=host&x-id=GetObject) #### Characteristics - Outputs values between 0 and 1. - Gradients become very small in the regions where $ z $ is very large or very small, leading to the vanishing gradient problem. @@ -141,7 +141,7 @@ Previously popular, but avoided in deep networks due to vanishing gradients. $$ \tanh(z) = \frac{e^z - e^{-z}}{e^z + e^{-z}} $$ #### Range $$ (-1, 1) $$ -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/db2f9c8f-51aa-4db6-aa8c-3855d0b93b08/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=c91703b31ddb2ffda2b3f657897a4e751d3d3363925cc5b76e7b75adc8bf97c5&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/db2f9c8f-51aa-4db6-aa8c-3855d0b93b08/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=9365addb697843875c1a4d04a9f730b8fef2dcdfb77d9fa7c8ee67992d19d833&X-Amz-SignedHeaders=host&x-id=GetObject) #### Characteristics - Similar to the sigmoid function but symmetric around the origin. - Gradients can still become very small in deep networks, leading to the vanishing gradient problem. @@ -152,7 +152,7 @@ Used in some applications but also limited by vanishing gradients in very deep n $$ \text{ReLU}(z) = \max(0, z) $$ #### Range $$ [ 0, \infty) $$ -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5d06c921-b0fd-40ec-b681-15be7e883d76/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=90c185b59bda98e9d68beb5e591aeb4bdf1a6490e36baea56dbde3add9730e59&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5d06c921-b0fd-40ec-b681-15be7e883d76/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=2de6caa18e2db59d4f4c4514849f9e1d0965c245f5d2efd7c7f97891469c37f1&X-Amz-SignedHeaders=host&x-id=GetObject) #### Characteristics - Non-linear activation function that only activates neurons with positive input values. - Helps overcome the vanishing gradient problem by ensuring that gradients are not zero for positive inputs. @@ -164,7 +164,7 @@ Widely used in hidden layers of deep networks due to its efficiency and effectiv $$ \text{Softmax}(z_i) = \frac{e^{z_i}}{\sum_{j} e^{z_j}} $$ #### Range $$ (0, 1) \text{ (sums to 1 across the output layer)} $$ -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7df121d3-29b2-4c62-801d-b1a78e0a433c/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=bd91fcd5e04e529330edccab9e255e3d63eb3edb3a736cfb67c5e9ed3673ca25&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7df121d3-29b2-4c62-801d-b1a78e0a433c/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=1ddbff960d38488ad50239cfde253c5222215c361f9da6cae86f26da91344eb4&X-Amz-SignedHeaders=host&x-id=GetObject) #### Characteristics - Converts raw output scores into probabilities that sum to 1. - Useful for classification tasks where we need to determine the probability of each class. diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 3 - Keras and Deep Learning Libraries/Module 3 - Keras and Deep Learning Libraries.md b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 3 - Keras and Deep Learning Libraries/Module 3 - Keras and Deep Learning Libraries.md index 02361e07a..07309b255 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 3 - Keras and Deep Learning Libraries/Module 3 - Keras and Deep Learning Libraries.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 3 - Keras and Deep Learning Libraries/Module 3 - Keras and Deep Learning Libraries.md @@ -17,7 +17,7 @@ TensorFlow is the most widely used deep learning library, developed by Google an - Support for deployment on multiple platforms - Large, active community *Additional Note:* GitHub link for TensorFlow - -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/74e41980-5708-4dc2-8b36-6fa847d6b94d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=bf89f4967529a2bee6facec52044cd34100af5f8e7d96494ffdd073e711a6d45&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/74e41980-5708-4dc2-8b36-6fa847d6b94d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=4d25d09c826e92d84bc7127559c568b41445a315f70ab0ab3b14fd329866d998&X-Amz-SignedHeaders=host&x-id=GetObject) ### 2. PyTorch #### Description PyTorch, developed by Facebook in 2016, has gained popularity in academic and research settings. It emphasizes flexibility and dynamic computation graphs, making it ideal for applications requiring custom deep learning models. PyTorch is a cousin of the Lua-Based Torch Framework, and is a strong competitor @@ -25,7 +25,7 @@ PyTorch, developed by Facebook in 2016, has gained popularity in academic and re - Dynamic computational graph - Strong academic presence - Easier debugging and optimization -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f420ac7a-3545-4ca4-807d-b1f088e34f6b/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=9646663850ed5359449e0887c9b5e75700566a6a9274feb8d4a3dc77e12cbe98&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f420ac7a-3545-4ca4-807d-b1f088e34f6b/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=d5d2e17233418cebedd334836c575304294ac86f64bc2594c57c6619ea881bd4&X-Amz-SignedHeaders=host&x-id=GetObject) ### 3. Keras #### Description Keras is a high-level API for building neural networks. It runs on top of TensorFlow and simplifies model building with a user-friendly interface, making it a great option for beginners and rapid prototyping. @@ -33,7 +33,7 @@ Keras is a high-level API for building neural networks. It runs on top of Tensor - Simplified syntax for rapid development - Can run on top of TensorFlow or Theano - User-friendly and easy to learn -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/18d63fa6-e71d-4007-b06a-fdde1fc12b03/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=5cb881a9fa43d4d335d5282baf5addd24e0379360fb55925dc066b15823d602d&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/18d63fa6-e71d-4007-b06a-fdde1fc12b03/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b7c0da77666e4f0b79b90717d624822bb3f2eb354de2f168a7a7dc4ad5df715d&X-Amz-SignedHeaders=host&x-id=GetObject) ### Comparison of Libraries - **TensorFlow**: Best for large-scale production environments. - **PyTorch**: Ideal for research and academic settings. @@ -63,7 +63,7 @@ print("Keras Backend:", keras.backend.backend()) predictors = concrete_data[['cement', 'slag', 'flyash', 'water', 'superplasticizer', 'coarseaggregate', 'fineaggregate']] target = concrete_data['strength'] ``` -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1307e63c-51d4-4bc0-954a-ff8ae7a3e2e1/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=a978d57c10265fa9535eac6b720161a0699a6142763a9090b549d8e3fe5fbdd0&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1307e63c-51d4-4bc0-954a-ff8ae7a3e2e1/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=427271fa169875a68bc99199e5f4534cac9628ebb9181d936458d1f19c23a858&X-Amz-SignedHeaders=host&x-id=GetObject) ### Building a Regression Model 7. **Creating the Model:** - Import necessary modules: @@ -90,7 +90,7 @@ model.add(Dense(1)) - `units`: Number of neurons in the layer. - `input_shape`: Shape of input data (only needed for the first layer). For example, `input_shape=(8,)` indicates 8 features. - `activation`: Activation function used by the layer. 'relu' is used for hidden layers, and no activation function is specified for the output layer to allow continuous output. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e6193001-64de-41d3-8624-a8f8d5f99f66/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162017Z&X-Amz-Expires=3600&X-Amz-Signature=ee04cf8ddb4bf0e909c6f35523304ae2b290b909c1852e1b6e3865200ba85ff2&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e6193001-64de-41d3-8624-a8f8d5f99f66/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=d987785453138b7e5c9a900f3ce1a13f2c60aae165d39be90bc8e42f246f9928&X-Amz-SignedHeaders=host&x-id=GetObject) 9. **Compiling the Model:** - Define the optimizer and loss function: ```python @@ -116,7 +116,7 @@ predictions = model.predict(new_data) - **Parameters Explained:** - `**new_data**`: New input data for which predictions are to be made. - `**predictions**`: The output from the model for the new data. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/eac113a6-c35b-46e8-a33e-827216ab294a/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=381f68e4cf02ac5e4ebc97fb45504f4441b7eb3afc1d81ebf37f1c14a38c4d6b&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/eac113a6-c35b-46e8-a33e-827216ab294a/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b5eee292e2b4194b621f0cb0ab52a055c489ad6f69b342e0275c26d21a1d8583&X-Amz-SignedHeaders=host&x-id=GetObject) ### Conclusion Keras simplifies the process of building and training neural networks. For regression tasks, a basic model can be built with just a few lines of code, making it accessible and efficient for rapid development. For more detailed information, refer to the Keras documentation on optimizers, models, and methods. @@ -151,7 +151,7 @@ target = car_data['decision'] ```python target = to_categorical(target) ``` -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b1126cec-3993-4fb3-82c4-d7f67fbc1e81/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=f828a3829daed4f9a91d6d0a06a7a1719903fbf4b5b6daec250afcc4378916d3&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b1126cec-3993-4fb3-82c4-d7f67fbc1e81/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=c3c77579249fc1e1a43b9037edb972660b7aecc69399ffeaec5c9de5872037b8&X-Amz-SignedHeaders=host&x-id=GetObject) ### **Building a Classification Model** 14. **Creating the Model**: - Initialize the Sequential model: @@ -196,8 +196,8 @@ predictions = model.predict(new_data) **Parameters Explained**: - `**new_data**`: New input data for which predictions are to be made. - `**predictions**`: The output from the model for the new data. Each prediction will be a probability distribution over the classes. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8e3957d0-609f-4d84-a6b2-bd48b5c3562e/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=30d7e5c2a70344270dd9cf8c469dfae25b28a8658347e43d00e55bcf6707c93c&X-Amz-SignedHeaders=host&x-id=GetObject) -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b9a0b3fa-70ea-45e5-9593-7351d697026d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=18ac53dec643471fcad46ffa85d47a0ca5ca4e81c65b051834bbac7899180370&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8e3957d0-609f-4d84-a6b2-bd48b5c3562e/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=98d4c1595c0ad3f9963e813301c99f084488245392995fc1f8af221f7675d565&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b9a0b3fa-70ea-45e5-9593-7351d697026d/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=57736f7697d1aad23b4d57c3d974767dbfda20749872647451d254e7825621d1&X-Amz-SignedHeaders=host&x-id=GetObject) ### **Conclusion** Keras provides a straightforward approach to building and training classification models. For classification tasks, the model architecture and training process are similar to those used for regression, with the key differences being the activation functions and loss functions used. For more detailed information, refer to the Keras documentation on optimizers, models, and methods. ___ diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 4 - Deep Learning Models/Module 4 - Deep Learning Models.md b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 4 - Deep Learning Models/Module 4 - Deep Learning Models.md index e5e256bd6..406740bf8 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 4 - Deep Learning Models/Module 4 - Deep Learning Models.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 4 - Deep Learning Models/Module 4 - Deep Learning Models.md @@ -44,11 +44,11 @@ ___ Convolutional Neural Networks (CNNs) are a specialized type of neural network designed for processing structured grid data such as images. This note covers the fundamental architecture of CNNs, their operational mechanisms, and how to build them using the Keras library. #### Convolutional Neural Networks (CNNs) ### Architecture -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a856b76b-1241-47c1-a61e-debae39d7c40/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=8ba67d60ad7de7cc9be2a38e149b4764830ef6c6d318f6c08a161af3da2cc362&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a856b76b-1241-47c1-a61e-debae39d7c40/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b3f773e570e73278d45763421d22195295f29b97d4e7070684b0ca961fa1006a&X-Amz-SignedHeaders=host&x-id=GetObject) #### Image Input Dimensions - **Grayscale Images**: (n x m x 1) - **Colored Images**: (n x m x 3), where 3 represents RGB channels. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c425f6cf-48e6-47ec-a267-b9616abf9492/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=6e2c54a6072a50358fd0dc31ec8501ef21d8b676b47153fb5aeb01aeefd89aac&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c425f6cf-48e6-47ec-a267-b9616abf9492/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=da225f0b8a7b696ce3f0a521c71edcc047929f450381fcb67993abe77a23ae71&X-Amz-SignedHeaders=host&x-id=GetObject) ### Key Components of CNNs #### 1. Convolutional Layer - **Purpose**: Applies filters to the input image to produce feature maps. @@ -57,12 +57,12 @@ Convolutional Neural Networks (CNNs) are a specialized type of neural network de - **Filter Size**: e.g., (2 x 2) - **Stride**: The number of pixels by which the filter moves across the image. - **Output**: An empty matrix filled with results from the convolution process -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f46f7f48-ccab-4a7b-adb0-4b63dbd530da/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=0208a838f78d0bf759921f1a1a2a18e329b5ee2eb0ba9eaaf9d7987b17b8b0bd&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f46f7f48-ccab-4a7b-adb0-4b63dbd530da/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=ea61f746df0359b84cfb35b678498e9d7662035a801cdca3eedc3418819f7c3f&X-Amz-SignedHeaders=host&x-id=GetObject) #### 2. Activation Function (ReLU) - **Purpose**: Introduces non-linearity into the model. - **Operation**: Applies the ReLU (Rectified Linear Unit) function to the output of the convolutional layer. - **ReLU Function**: Outputs the input directly if it is positive; otherwise, it outputs zero. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7660e416-eb44-4488-b210-c6c586e99cc4/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=94b7662c7876020f1a43bc03f3a4ef372e48a79be74c11a8212f57343f497155&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7660e416-eb44-4488-b210-c6c586e99cc4/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=ef08505ee7239b664fb1e3dbdb6771f0289231694f1353173dcf9475f56d8323&X-Amz-SignedHeaders=host&x-id=GetObject) #### 3. Pooling Layer - **Purpose**: Reduces the spatial dimensions of the feature maps. - **Types**: @@ -71,13 +71,13 @@ Convolutional Neural Networks (CNNs) are a specialized type of neural network de - **Stride**: The number of pixels by which the pooling filter moves. - **Average-Pooling**: Computes the average value from each section of the feature map. - **Benefit**: Reduces computational complexity and helps prevent overfitting. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8791e5e6-af9f-45eb-a433-23a7c733feb1/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=b339b4248e1c7816085109553c8b8519c8e18fceb8333b9c896d2456ab2e8668&X-Amz-SignedHeaders=host&x-id=GetObject) -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4c528212-221a-47dc-9d7c-9ae194171597/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=69586b1de886f37a18c5e9472621f970991523c33433b7f92ca09327a7cff107&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8791e5e6-af9f-45eb-a433-23a7c733feb1/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=f9c9a0166dbf3712d8467b4f74854d80de567e90ec506f65019c8bff842a7e6c&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4c528212-221a-47dc-9d7c-9ae194171597/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=a0396890620a12917193db097a6bbad77582f71134bc0db57ea30eb810e50c99&X-Amz-SignedHeaders=host&x-id=GetObject) #### 4. Fully Connected Layer - **Purpose**: Connects every node from the previous layer to every node in the current layer. - **Operation**: Flattens the output from the previous layers and produces an n-dimensional vector, where n corresponds to the number of classes. - **Activation Function**: Typically uses the softmax function to convert the outputs into probabilities. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/51e84329-f1c0-4784-a080-d1fbd5c4d0ae/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=830b983716c5c04a942fd694a25c17f66f5185d0b74c7aecf4e95129f5ae1707&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/51e84329-f1c0-4784-a080-d1fbd5c4d0ae/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=1101c3070b94581716bb33bfbbf902fa28b4c0239a4623d09f6195f8bbf54f37&X-Amz-SignedHeaders=host&x-id=GetObject) ### CNN Architecture - **Input Layer**: Defines the size of the input images (e.g., 128 x 128 x 3 for color images). - **Convolutional Layers**: Apply multiple filters and include ReLU activation. @@ -148,7 +148,7 @@ model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accur - `metrics=['accuracy']`: Evaluation metric used to measure the performance of the model. 6. **Training and Validation**: - Train the model using the `fit` method and validate using a test set. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/47b54c06-9f0d-49d3-9183-2d29bfa51d80/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=a4c3aabeb7866223e7f091e8afc9ab45cd93bd59df5c0460315e5e90d321c459&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/47b54c06-9f0d-49d3-9183-2d29bfa51d80/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=97fefefa78474698e15733ffb0ed62e3828a95c1c3ef947d187a389e0f774003&X-Amz-SignedHeaders=host&x-id=GetObject) ### Conclusion CNNs are powerful for image processing tasks due to their ability to automatically extract and learn features from images. The architecture involves convolutional, activation, pooling, and fully connected layers, which collectively enable the network to perform tasks such as image recognition and object detection. ___ @@ -161,7 +161,7 @@ ___ - At time `t = 0`, the network takes in input $ x_0 $ and outputs $ a_0 $. - At time `t = 1`, the network takes in input $ x_1 $` `and the previous output $ a_0 $, weighted by $ w_{1,2} $. - This process continues, incorporating previous outputs into the computation at each step. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/88d6b2af-f6f0-4932-984c-b68479fb8ab5/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=9f1f9c7be8bba9b9126df5e8fae8e49932aae90e9bc4d4c3ee15f11cf51bb772&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/88d6b2af-f6f0-4932-984c-b68479fb8ab5/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=fa3e0d4f16a3e4be0e606b534a9190e36bbcd3c1aa8db08fffa0c3bd881fd387&X-Amz-SignedHeaders=host&x-id=GetObject) ### Applications of RNNs - **Text Analysis**: Suitable for processing and modeling sequential text data. - **Genomic Data**: Can analyze sequences in genetic information. @@ -188,7 +188,7 @@ ___ - Compresses the input data into a lower-dimensional representation. - **Decoder**: - Reconstructs the original data from the compressed representation. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/13d5eb4d-dac0-40e6-97fb-d5688c6a13e7/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=d9bf5e4b3c89a9114ba0d0e6cbdd40d98de45f0a20f6de2b8b9e38ab167eaef3&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/13d5eb4d-dac0-40e6-97fb-d5688c6a13e7/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=32465c855e3a53dfff89c892323e62d5a720877bf3ab1d209f2ba79df30f4e88&X-Amz-SignedHeaders=host&x-id=GetObject) ### Applications of Autoencoders - **Data Denoising**: Removing noise from data to recover the original signal. - **Dimensionality Reduction**: Reducing the number of features in the data for visualization purposes. @@ -199,7 +199,7 @@ ___ - **Fixing Imbalanced Datasets**: Generating more data points for minority classes to balance datasets. - **Estimating Missing Values**: Predicting missing feature values in datasets. - **Automatic Feature Extraction**: Learning features from unstructured data. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e56b5c68-d1d6-4a40-986f-30aa54ab7681/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=78dc540d23f50c458af8209edd6dae9562b7cf3b500b04267fb9b533fbbb320a&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e56b5c68-d1d6-4a40-986f-30aa54ab7681/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=3e7ec50699501136a89d0642e01b2d9c3a320b99aac8ed960460ff22aaf41925&X-Amz-SignedHeaders=host&x-id=GetObject) ### Summary - **Autoencoders**: Useful for data compression, denoising, and dimensionality reduction. - **RBMs**: Specialized autoencoders effective for handling imbalanced datasets, estimating missing values, and feature extraction. diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 5 - Object Detection and Summary/Module 5 - Object Detection and Summary.md b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 5 - Object Detection and Summary/Module 5 - Object Detection and Summary.md index 74595695f..60ce75818 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 5 - Object Detection and Summary/Module 5 - Object Detection and Summary.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Introduction to Deep Learning & Neural Networks with Keras/Modules/Module 5 - Object Detection and Summary/Module 5 - Object Detection and Summary.md @@ -2,10 +2,10 @@ # Module 5: Object Detection and Summary ## Module 1: Introduction to Neural Networks and Deep Learning -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a8d40bcb-c482-4026-8872-311e16b2dc63/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=9c9c8d45631ea2a467dda34e25985519f7ec2f847a19ca0e4712a72b1609673a&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a8d40bcb-c482-4026-8872-311e16b2dc63/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=82297ea2bd69c81ebc168b36351a21c83b4ef2920737070ec36d2eed78fb0ec0&X-Amz-SignedHeaders=host&x-id=GetObject) ## Module 2: Artificial Neural Networks -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5157ca89-62da-41d9-a98f-6432b71047a9/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=00c5b776c250a564a906bbc31ff53a52fdef38a7d70651ff4224f8b5f6b8656b&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5157ca89-62da-41d9-a98f-6432b71047a9/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=86eac05fca22960d1c2cae16403c3741d9ba68562ae958a1792ac0b9a9110f12&X-Amz-SignedHeaders=host&x-id=GetObject) ## Module 3: Keras and Deep Learning Libraries -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5089ce50-05f1-470d-ad42-42503bf1df5f/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=f86a0ae4b2156faffb4a879c7395bd43673170e04557bef30a2765d88e389e96&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5089ce50-05f1-470d-ad42-42503bf1df5f/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=63b9342dd4547611c5dcaa7420ac1e69e462f468c21db5226336040ab0d6ef5b&X-Amz-SignedHeaders=host&x-id=GetObject) ## Module 4: Deep Learning Models -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4e22fcb0-cfbc-4d28-b961-b9b8fde071f0/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=e1b67cbc20dee8db281248daa9c7d24c9274eb8a0f60fbdcec6c5b6a582ea60e&X-Amz-SignedHeaders=host&x-id=GetObject) \ No newline at end of file +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4e22fcb0-cfbc-4d28-b961-b9b8fde071f0/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=341b1e9510f4b63d4dbd3f14f3a5e7c41a5b6213e0445d5fd6c0e702b920debc&X-Amz-SignedHeaders=host&x-id=GetObject) \ No newline at end of file diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Helpers/Achievements/Achievements.md b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Helpers/Achievements/Achievements.md index f74e004f5..94972adc3 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Helpers/Achievements/Achievements.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Helpers/Achievements/Achievements.md @@ -2,6 +2,6 @@ # Achievements ## Certificate -[Machine_Learning_with_Python_Certificate.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0f35a87e-0c16-48ac-af62-4e4cc34c6a19/Machine_Learning_with_Python_Certificate.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=60d3508fd2182d44f13797523836b57f780c32913372db3e6f0ff2bb9159c954&X-Amz-SignedHeaders=host&x-id=GetObject) +[Machine_Learning_with_Python_Certificate.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0f35a87e-0c16-48ac-af62-4e4cc34c6a19/Machine_Learning_with_Python_Certificate.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=213b45b4c4a7d374cea7f7d761ba040d3f439e1e95b4bb8762f16fd03a349fef&X-Amz-SignedHeaders=host&x-id=GetObject) ## Badge -[Machine_Learning_with_Python_Badge.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ff622a22-73d6-44e3-9c7b-e89a8e61b7aa/Machine_Learning_with_Python_Badge.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=dbf34f6d837afc8e2a8b8d2da16420173725269ad4108f72a9b976a09664849d&X-Amz-SignedHeaders=host&x-id=GetObject) \ No newline at end of file +[Machine_Learning_with_Python_Badge.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ff622a22-73d6-44e3-9c7b-e89a8e61b7aa/Machine_Learning_with_Python_Badge.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=8b5c28d03cd21aa56efa6d4d42100654d9fde73a2fa7e2e42a88144973b39419&X-Amz-SignedHeaders=host&x-id=GetObject) \ No newline at end of file diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 1 - Introduction to Machine Learning/Module 1 - Introduction to Machine Learning.md b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 1 - Introduction to Machine Learning/Module 1 - Introduction to Machine Learning.md index d4757acc3..cf72e008c 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 1 - Introduction to Machine Learning/Module 1 - Introduction to Machine Learning.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 1 - Introduction to Machine Learning/Module 1 - Introduction to Machine Learning.md @@ -6,7 +6,7 @@ Machine Learning is a subfield of computer science that gives computers the abil ### How Does Machine Learning Work? Machine Learning algorithms, inspired by the human learning process, iteratively learn from data. These algorithms allow computers to discover hidden insights and patterns within large datasets. The models created through Machine Learning can assist in a variety of tasks, such as object recognition, text summarization, recommendation systems, and more. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f70e0ef3-5da8-43ee-97c7-307c710790ce/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=194daf05dbeffd2f7a73fb7646c84fdcf554233aa0edbc120200bbd2830e81f2&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f70e0ef3-5da8-43ee-97c7-307c710790ce/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=2f9fcc46dffd88187f68a70650474d09eefd66f069fbefbdc8bc7dcdd34c3799&X-Amz-SignedHeaders=host&x-id=GetObject) ### Major Machine Learning Techniques ___ @@ -97,7 +97,7 @@ ___ - **Outcome**: The system suggests movies that users are likely to enjoy. - **Benefit**: Enhances user experience and increases engagement. ___ -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f3682ae8-1011-4662-9f34-0e5b8ac9951f/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=3e78ae4b0148a90b78965a3b5f0c917e70aa5a3c2a1aa12d033d75e3c79e1182&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f3682ae8-1011-4662-9f34-0e5b8ac9951f/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=13642ef641a0287d060667489171a02285bcf3c96f4616f73f010b2a871e4e7e&X-Amz-SignedHeaders=host&x-id=GetObject) #### Note Sequence mining identifies patterns based on the order of events, while association rule learning focuses on identifying co-occurrence patterns without considering the order of items. @@ -130,11 +130,11 @@ SciKit Learn is a comprehensive machine learning library that integrates seamles - **Evaluation**: Assessing accuracy with metrics like a confusion matrix, visualizing model performance. - **Model Exporting**: Saving trained models for future use, enabling easy deployment. A typical workflow with SciKit Learn involves pre-processing the data, splitting it into training and testing sets, building and training a classifier, making predictions, evaluating the model, and saving it for future use. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b437e049-e272-41b4-bb95-e2807ba514ca/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=9876c94710a30f847f3301ea26312bd1e4e6ceda6fb7871cf1066ca06114cb34&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b437e049-e272-41b4-bb95-e2807ba514ca/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=5b6981d4a0b5f432b6a3230a92a016b1f21787cf2faeb59999fbfc44da1eec67&X-Amz-SignedHeaders=host&x-id=GetObject) ___ -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cea31c5d-b49d-4d39-8566-ec7e66e033b4/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=02bf838bbc08dfdd20479dfc366c4f98a75b7639ecaeafd029514cfa492e807c&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cea31c5d-b49d-4d39-8566-ec7e66e033b4/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=a4570ddb4fef5104647342b7410dcb5a38be9235d522bb514ce5f0554160d046&X-Amz-SignedHeaders=host&x-id=GetObject) ___ -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a7c7fcb1-e868-4073-9392-bd1424f11933/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=5595f91af777bc092e8a4f487e7d6b6558f72f6b2b107e04a3e8f506314330a9&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a7c7fcb1-e868-4073-9392-bd1424f11933/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=eff24fe82f30a26383f5697987a59b54641b827f43e4eaa21d11fdbadd9da049&X-Amz-SignedHeaders=host&x-id=GetObject) Understanding and leveraging these packages, especially SciKit Learn, simplifies the machine learning process and reduces the amount of coding required compared to using pure Python or other individual packages. @@ -146,7 +146,7 @@ Supervised learning involves teaching a machine learning model using a labeled d - **Types of Supervised Learning**: - **Classification**: Predicts discrete class labels. For example, classifying emails as spam or not spam. - **Regression**: Predicts continuous values. For example, predicting the CO2 emission of a car based on its engine size and number of cylinders. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d97478ab-3688-44b7-9ac9-b31943e9e39a/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=bc7012583b6e4023d99a252dae819b52762181c8a946c91bb03c7592652a4240&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d97478ab-3688-44b7-9ac9-b31943e9e39a/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=67c050958c9e93ec4c9d8b71474c29ab6e00dc5dfb03b866fe4752ab3bcdaac3&X-Amz-SignedHeaders=host&x-id=GetObject) #### **Unsupervised Learning** Unsupervised learning involves training a model on data without labeled responses. The model tries to learn the underlying structure of the data on its own. - **Common Unsupervised Learning Techniques**: @@ -154,7 +154,7 @@ Unsupervised learning involves training a model on data without labeled response - **Dimensionality Reduction**: Reducing the number of features in the data to simplify the model and make the classification easier. - **Market Basket Analysis**: Identifying items that frequently co-occur in transactions. - **Density Estimation**: Exploring the data to find some underlying structure. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/efcaecea-9440-472e-8abf-cb0ac379999a/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=58f544517f4d73ce4b0c5971f155915c5c6b3f2eefe11eeeb6dcc377c7353a26&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/efcaecea-9440-472e-8abf-cb0ac379999a/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=840fd367ac44c004fbb3e2d18ad74c8b721e93a6bf525036850e97bddf2e54fc&X-Amz-SignedHeaders=host&x-id=GetObject) #### **Key Differences Between Supervised and Unsupervised** - **Data**: diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 2 - Regression/Module 2 - Regression.md b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 2 - Regression/Module 2 - Regression.md index 1c606bab0..8283fe2b9 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 2 - Regression/Module 2 - Regression.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 2 - Regression/Module 2 - Regression.md @@ -4,7 +4,7 @@ ## Introduction to Regression ### Overview Regression is the process of predicting a continuous value using other variables. It involves two types of variables: dependent (target) and independent (explanatory) variables. The dependent variable is the value being predicted, while the independent variables are the factors used to make the prediction. In regression, the dependent variable should be continuous, whereas the independent variables can be either categorical or continuous. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/048d582c-bb2d-4876-8db6-48170b4c3cd2/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=8dcf2403a4c187b046507f80ceac34f03b16ade720eabd3cfe49a561873190c8&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/048d582c-bb2d-4876-8db6-48170b4c3cd2/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=c9d838aae2cfa344e5df854d287f7d26d97326ae341d093623c3c8b1c77b8c8b&X-Amz-SignedHeaders=host&x-id=GetObject) ### Example Dataset Consider a dataset related to CO2 emissions from different cars. The dataset includes: - Engine size @@ -15,7 +15,7 @@ Consider a dataset related to CO2 emissions from different cars. The dataset inc Given this dataset, is it possible to predict the CO2 emission of a car using other fields such as engine size or cylinders? → Yes ### Historical Data and Prediction Assume there is historical data from different cars. The goal is to estimate the CO2 emission of a new or unknown car, such as the one in row 9, which hasn't been manufactured yet. Regression methods can be used to make this prediction. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/bf5ae032-3b83-43fa-bf50-0b398a6a3696/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=39825b9fecbfe76698d40d7ccd3abea77500cedb4fe8d978b7ffd1f07d529152&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/bf5ae032-3b83-43fa-bf50-0b398a6a3696/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=aa0071daa134241783a641857041c656d520ac1ea1a1ecef4d3afedc833ced5a&X-Amz-SignedHeaders=host&x-id=GetObject) ### Types of Variables in Regression - **Dependent Variable (Y):** The state, target, or final goal to be predicted. - **Independent Variables (X):** The causes or explanatory variables. @@ -41,7 +41,7 @@ Predicting employment income using variables such as hours of work, education, o Regression analysis is also useful in finance, healthcare, retail, and more. ### Conclusion Regression analysis has numerous applications across various fields. It helps in estimating continuous values using historical data and independent variables. Various regression algorithms exist, each suited to specific conditions, providing a foundation for exploring different regression techniques. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/461b9fe5-0f07-4808-8900-af2da1b81f37/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=280622207828842327302ad568c3acf965fc82e8599bae13e1a2be7af04e7c45&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/461b9fe5-0f07-4808-8900-af2da1b81f37/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=c7b0df5c6df96d5e8e7a381028839970394360f4c6bb2922a5287b547887e3dc&X-Amz-SignedHeaders=host&x-id=GetObject) ___ ## Introduction to Linear Regression Linear regression is an effective method for predicting a continuous value using other variables. This introduction provides the necessary background to use linear regression effectively. @@ -52,7 +52,7 @@ Consider a dataset related to CO2 emissions of different cars. The dataset inclu - Fuel consumption - CO2 emissions The goal is to predict the CO2 emission of a car using another field, such as engine size. Linear regression can be used for this purpose. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/578ec272-487c-41e1-a17c-3aa0f08a47b9/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=2b327b4e86ad9dbc3d10f99fa831af8ed072ae0086c43929f614220a26ff7f31&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/578ec272-487c-41e1-a17c-3aa0f08a47b9/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b18c56e4608ab568d58ee7eb3cfc686b84bd745ec4c0962d912c96459426b749&X-Amz-SignedHeaders=host&x-id=GetObject) ### Linear Regression Basics Linear regression is the approximation of a linear model to describe the relationship between two or more variables. #### Variables in Linear Regression @@ -70,10 +70,10 @@ Linear regression is the approximation of a linear model to describe the relatio A scatter plot can be used to visualize the relationship between variables, such as engine size (independent variable) and CO2 emission (dependent variable). The plot helps to identify if the variables are linearly related. #### Fitting a Line Linear regression fits a line through the data points. For example, as the engine size increases, the CO2 emissions also increase. The objective is to find a line that best fits the data, which can be used to predict CO2 emissions. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4e7d7e03-a08b-4932-8307-1f2a23dccc4d/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=49b85dc48be7f0f1ba69880570389ab29d2ae3f4f87a8a16cb40374d243087ac&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4e7d7e03-a08b-4932-8307-1f2a23dccc4d/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=4bd2171e4d357c4a4a099e77c79904db347c580b45df5395fe21701a53df398e&X-Amz-SignedHeaders=host&x-id=GetObject) #### Prediction Using the Line Assuming the line is a good fit, it can be used to predict the CO2 emission of an unknown car. For example, for a car with an engine size of 2.4, the predicted CO2 emission is 214. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/26c9b8fd-e224-438c-8bab-1b5558e8d558/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=c38b4db652bb93eaac56e637536d168c3bcac93f4f62009a733485d4d16a37c5&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/26c9b8fd-e224-438c-8bab-1b5558e8d558/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=6ff26f18019c71edd13382f7de601a8b74f6f778f0e409a819892d8922593ea5&X-Amz-SignedHeaders=host&x-id=GetObject) ### Mathematical Representation The fitted line in linear regression is represented as a polynomial. For a simple linear regression with one independent variable , the model is: $ \hat{y} = \theta_0 + \theta_1 x_1 $ @@ -84,7 +84,7 @@ $ \hat{y} = \theta_0 + \theta_1 x_1 $ #### Estimating Coefficients - $ \theta_0 $ (intercept) and $ θ_1 $ (slope) are the parameters of the line that need to be adjusted to minimize the error. - The goal is to minimize the mean squared error (MSE), which is the mean of all residual errors (the distance from data points to the fitted line). -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/58b7831d-084a-4eef-bfdf-3cb97ef6723e/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=0ed0206ba81eb89e38630342c66a8cd4555baab4dfea5c8ca67b59be40e6c74a&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/58b7831d-084a-4eef-bfdf-3cb97ef6723e/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=a8e639bd340494db7cc1c96429dfbcb9289694da611f255802f7aa8b46ebd66a&X-Amz-SignedHeaders=host&x-id=GetObject) #### Calculating $ θ_0 $ and $ θ_1 $ 3. **Calculate the Mean:** - Calculate the mean of the independent variable ($ \bar{x} $) and the dependent variable ($ \hat{y} $). @@ -92,7 +92,7 @@ $ \hat{y} = \theta_0 + \theta_1 x_1 $ $$ \theta_1 = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sum (x_i - \bar{x})^2} $$ 5. **Estimate **$ \theta_0 $** (intercept):** $$ \theta_0 = \bar{y} - \theta_1 \bar{x} $$ -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/771eaaa6-b44a-4958-b185-0146fb685012/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=df054f84f26ea66fcc089dd8934d1bc9d34cdba6c29e557a0c9ea99b96dab6f8&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/771eaaa6-b44a-4958-b185-0146fb685012/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=d3d953c20db607d7edb9767f979171c6ea29ff64d8319fa670d0176b1897427f&X-Amz-SignedHeaders=host&x-id=GetObject) #### Example Calculation For a dataset with known values: - If $ θ_1 $= 43.98 and $ θ_0 $ = 92.94, the linear model is: @@ -123,7 +123,7 @@ Model evaluation in regression aims to assess how well a model can predict unkno - Simple and straightforward. - **Disadvantages:** - High training accuracy but low out-of-sample accuracy due to overfitting. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cc20ddcb-2279-4e79-bcfe-8205d0fa76e4/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162017Z&X-Amz-Expires=3600&X-Amz-Signature=85101c4f0a580e90e297497c1ef90d1868cbe1a8b5c3d1b430ca207a36a35645&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cc20ddcb-2279-4e79-bcfe-8205d0fa76e4/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=73794e36f85360f44e49de484e95aff921efde979c66c14d5db6db50484dd8e1&X-Amz-SignedHeaders=host&x-id=GetObject) #### **Code Example:** ```python from sklearn.linear_model import LinearRegression @@ -155,7 +155,7 @@ print(f'Mean Squared Error: {mse}') - More realistic for real-world problems. - **Disadvantages:** - Dependent on the specific split of the dataset, which can introduce variation. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ee9c0838-a391-45b2-a788-d0c8854fbdee/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=46ddaedfef3da028a2d6a3310f2f95b2302299ded220671b8b55dccefa64ccfa&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ee9c0838-a391-45b2-a788-d0c8854fbdee/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=cd224ae324fde610704d0262971975d4bb6ff19fa8d09a8f2119cf3c6374b6df&X-Amz-SignedHeaders=host&x-id=GetObject) #### **Code Example:** ```python from sklearn.model_selection import train_test_split @@ -197,7 +197,7 @@ K-fold cross-validation is a method to address the dependency and variation issu **Advantages of K-Fold Cross-Validation:** - Reduces the dependency on a specific train/test split. - Provides a more reliable estimate of out-of-sample accuracy. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/daf007d4-8db8-4c38-bf21-80ebc37f3976/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=ee83a6511d90c68e126225dff1f03c91772af27c4c544dcf69fc3a98b82e17cb&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/daf007d4-8db8-4c38-bf21-80ebc37f3976/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=6ce0531c934a49efd888902d381f72d50f188eb3ba679453a04c1a6c6df5084d&X-Amz-SignedHeaders=host&x-id=GetObject) #### **Code Example:** ```python from sklearn.model_selection import cross_val_score @@ -320,7 +320,7 @@ ___ ### **Model Representation** - **Equation**: The model can be expressed as $ \hat{y}=θ_0+θ_1x_1+θ_2x_2+…+θ_nx_n $. - **Vector Form**: In multidimensional space, the model is represented as $ \theta^T x $, where $ θ $ is the vector of parameters and $ x $ is the feature set. The first element of $ x $ is set to one to account for the intercept ($ \theta_0 $). -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/97c57813-1dc2-4a92-93ef-7edea66e3447/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=d94238b6d2aec5fc89d1666634d6b691ce60d8fff66023194685434d28f4f3cd&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/97c57813-1dc2-4a92-93ef-7edea66e3447/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=d9e0ccb20da773f6577919475aee0dc48f02ba8ba4fc1e4d8db60ef938966f01&X-Amz-SignedHeaders=host&x-id=GetObject) #### **Code Example:** Here’s an example of implementing Multiple Linear Regression in Python using `scikit-learn`: ```python diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 3 - Classification/Module 3 - Classification.md b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 3 - Classification/Module 3 - Classification.md index c2e15fdfc..51a86a182 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 3 - Classification/Module 3 - Classification.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 3 - Classification/Module 3 - Classification.md @@ -5,7 +5,7 @@ Classification is a supervised learning approach used to categorize items into discrete classes. It aims to learn the relationship between feature variables and a target variable, which is categorical. ### How Classification Works Given training data with target labels, a classification model predicts the class label for new, unlabeled data. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ebd9db3c-b793-47e8-9f00-a93662961e2a/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=a5a749dee3a56ff3b0a5717294baa5fbb3196d48e732ba2d6705ba6714b669d8&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ebd9db3c-b793-47e8-9f00-a93662961e2a/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=3da6615bc810f293bde966d3cd80bb12376837aa54192c4ccb761c83d50a38f4&X-Amz-SignedHeaders=host&x-id=GetObject) #### Example: A loan default predictor uses historical data (e.g., age, income) to classify customers as defaulters or non-defaulters. ### Types of Classification @@ -13,7 +13,7 @@ A loan default predictor uses historical data (e.g., age, income) to classify cu Predicts one of two possible classes (e.g., defaulter vs. non-defaulter). #### Multi-class Classification Predicts among more than two classes (e.g., which medication is appropriate for a patient). -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d0a87923-2ee4-4428-9a12-9e906d1d7355/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=2ce5859e134a5ecc64a17ed176c4780cec6bd35c2967b79f8447a9c36a44e54f&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d0a87923-2ee4-4428-9a12-9e906d1d7355/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=70a0bc980a76a51cd1fbf5d666bed07a2ff6747a58282e8ecf650823990282a2&X-Amz-SignedHeaders=host&x-id=GetObject) ### Applications #### Business Use Cases - Churn detection @@ -39,7 +39,7 @@ ___ The **K-Nearest Neighbors (KNN)** algorithm is a supervised learning classification technique used to classify a data point based on how its neighbors are classified. It is based on the concept that data points that are close to each other are more likely to belong to the same class. KNN can also be used for regression tasks. ### Example Scenario Consider a telecommunications provider that has segmented its customer base into four groups based on service usage patterns. The goal is to predict which group a new customer belongs to using demographic data such as age and income. This is a classification problem, where the goal is to assign a class label to a new, unknown case based on the known labels of other cases. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e36aac8a-7cd7-46a1-abe2-4cec9840fab1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=0cce20563cf467b9e85efcb34ce1524fd913f7cea73d5bc9adca97f036187b24&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e36aac8a-7cd7-46a1-abe2-4cec9840fab1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=4881ba3b7bbb8a965d863aef9c0e2d75b1451c358090f296b84a5d8d22e5a02e&X-Amz-SignedHeaders=host&x-id=GetObject) ### How K-Nearest Neighbors Works 1. **Choosing the Number of Neighbors (K)**: The number of neighbors (K) to consider is specified by the user. 2. **Calculating Distance**: For a new data point, the algorithm calculates the distance between this point and all other points in the dataset. Common distance metrics include Euclidean distance. @@ -49,9 +49,9 @@ Consider a telecommunications provider that has segmented its customer base into - **Scenario**: A new customer’s demographic data (e.g., age and income) is available. The goal is to classify this customer into one of four service groups. - **Process**: - If K=1, the new customer is assigned the same class as the closest existing customer. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/52e428c2-67d2-47dc-9e61-836eccce6be2/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=74801f981605c49d4e1616141160d605b674281084f78ddb2d06ef74de0e79a3&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/52e428c2-67d2-47dc-9e61-836eccce6be2/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=7d38f8fc29ea82872f1fcc84bf8740ed6d88b04068a7c2a468b0afbbe5f52c09&X-Amz-SignedHeaders=host&x-id=GetObject) - If K=5, the new customer is assigned the class that is most frequent among the 5 nearest neighbors. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/43d3ac68-3aef-49d9-8585-3354324ac454/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=15a4f39f125ceae08ede94c96590b1c1c3abccbbc71565e1b4bf651779fb75a4&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/43d3ac68-3aef-49d9-8585-3354324ac454/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=b1b2085fea9adb543a5676463af3eb54ad62d2cf9178910a8f5f7f9846f6bf11&X-Amz-SignedHeaders=host&x-id=GetObject) ### Example Code for KNN: ```python from sklearn.neighbors import KNeighborsClassifier @@ -122,7 +122,7 @@ $$ \text{Jaccard Index} = \frac{8}{10 + (10 - 8)} = 0.6 $$ #### Interpretation - A Jaccard index of 1.0 indicates a perfect match between predicted and true labels. - A value closer to 0 indicates a poor match. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/70cad103-c369-453a-a601-9beda28c647e/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=afc1d160c20a865370505e3062c8ecf96cd135972f4c173861a4093c0c331914&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/70cad103-c369-453a-a601-9beda28c647e/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=09b467a45be053224f05c27b72491011c985cf4b6adf89407c5d5b08507d38c3&X-Amz-SignedHeaders=host&x-id=GetObject) #### Code Example ```python from sklearn.metrics import jaccard_score diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 4 - Linear Classification/Module 4 - Linear Classification.md b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 4 - Linear Classification/Module 4 - Linear Classification.md index 87c811086..8ef49e023 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 4 - Linear Classification/Module 4 - Linear Classification.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 4 - Linear Classification/Module 4 - Linear Classification.md @@ -11,7 +11,7 @@ Logistic Regression is a statistical and machine learning technique used for cla **Logistic Regression** is a classification algorithm that models the probability of a binary outcome based on one or more predictor variables. Unlike linear regression, which predicts continuous values, logistic regression is used to predict binary or categorical outcomes, often represented as 0 or 1, yes/no, true/false, etc. Note that logistic regression can be used both for binary classification and multiclass classification. #### Example: Consider a telecommunication dataset where the goal is to predict customer churn. Here, logistic regression can be used to build a model that predicts whether a customer will leave the company based on features such as tenure, age, and income. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f598c0c7-f8ed-46d4-a4f7-2fc1ce95c8e5/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=fb39bb011729cc7844b38e1af90d6e10cf522b6ed926c124f105da18bfbadcbd&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f598c0c7-f8ed-46d4-a4f7-2fc1ce95c8e5/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=d815172bf23c1ea44ff501ed3527af94108ccc171088e46911cd61324563ada3&X-Amz-SignedHeaders=host&x-id=GetObject) Note: Independent variables should be numerical (continuous value). ### 2. Problems Solved by Logistic Regression Logistic regression is widely used for various classification tasks, including: @@ -24,7 +24,7 @@ Logistic regression is an ideal choice in the following scenarios: 2. **Probability Prediction**: When you need the probability of the prediction, such as estimating the likelihood of a customer buying a product. 3. **Linearly Separable Data**: When the data is linearly separable, meaning that the decision boundary can be represented as a line or hyperplane. 4. **Feature Impact Analysis**: When you need to understand the impact of each feature on the outcome, using the model's coefficients.\ -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/eaad42ca-7ab6-4d54-92a5-531423c67ee8/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=d9880a19967252b2aa51dfa717e090d1d407ed0d5d5cb7456bfa367dfc4b7e1f&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/eaad42ca-7ab6-4d54-92a5-531423c67ee8/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=47de2cd7bc6ebea2127410ca4f6a00edb3c20d9faafd19e7a3935bdf884f999c&X-Amz-SignedHeaders=host&x-id=GetObject) ### 4. How Logistic Regression Works In logistic regression, the relationship between the independent variables (X) and the probability of the dependent variable (Y) is modeled using a logistic function. The logistic function maps any real-valued number into a value between 0 and 1, which can be interpreted as a probability. #### Decision Boundary: @@ -34,7 +34,7 @@ In logistic regression, the relationship between the independent variables (X) a - **Dataset (X)**: Features such as tenure, age, and income. - **Target (Y)**: Whether the customer churns (0 or 1). - **Model**: The logistic regression model predicts the probability of a customer churning based on the given features. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9ea7e826-4da2-40c4-a846-440ea47fb25f/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=cd670b3bcbb7fe643f96cc5061ee0aab23db806a87f54ee8cf59dd63489eed85&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9ea7e826-4da2-40c4-a846-440ea47fb25f/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=a90c2031623873860174d3584f0362957fb8b9deeeb1468be6ef450ef771c703&X-Amz-SignedHeaders=host&x-id=GetObject) ### 5. Formalizing the Problem Given a dataset $ X $of $ m $ dimensions (features) and $ n $ records, and a target variable $ Y $(which can be 0 or 1), the logistic regression model predicts the class of each sample and the probability of it belonging to a particular class. - $ X $: Independent variables (features). @@ -83,7 +83,7 @@ Logistic regression is specifically designed for classification problems. It mod $$ \text{Sigmoid}(\Theta^T x) = \frac{1}{1 + e^{-\Theta^T x}} $$ Here, $ \Theta^T x $ represents the linear combination of features, and the sigmoid function outputs a value between 0 and 1, representing the probability that the input belongs to the positive class (e.g., churn = yes). -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/27bbc765-0150-428f-8bb8-d7e441ee6497/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=e45538056b0e115aa01401404fc669643c441848b3978c6f6d9bdf2addac9b8a&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/27bbc765-0150-428f-8bb8-d7e441ee6497/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=fad9c2452102e3a8f5ddc30d7177ab855a83fcfdd4f658586c320be74bf8231e&X-Amz-SignedHeaders=host&x-id=GetObject) #### Python Example: Logistic Regression ```python import numpy as np @@ -122,7 +122,7 @@ Training a logistic regression model involves finding the optimal values of the 8. **Cost Function:** Aggregate the errors across all samples to calculate the total cost. 9. **Parameter Update:** Adjust $ \Theta $ to minimize the cost using optimization techniques like gradient descent. 10. **Iteration:** Repeat the process until the cost is sufficiently low and the model accuracy is satisfactory. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fafd48ce-1a29-4fbe-ab1c-86866a783c1e/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=b88753f90d6ca896c802c72c542fae69ce78f6e809b9900f9233b1a95cd8dc39&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fafd48ce-1a29-4fbe-ab1c-86866a783c1e/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=00dd310a28616f8f11907f7df65d85f830b913aaac8766cf8c40dec55f8505b5&X-Amz-SignedHeaders=host&x-id=GetObject) ### Conclusion Logistic regression is a powerful tool for binary and multi-class classification problems. By applying the sigmoid function to a linear model, logistic regression transforms it into a probabilistic model, making it highly effective for tasks that require predicting the likelihood of an outcome. ___ @@ -167,7 +167,7 @@ The learning rate $ \mu $ determines how quickly or slowly the model converges t 19. **Update Parameters:** Adjust the parameters to move towards minimizing the cost. 20. **Repeat:** Continue iterating until the cost is minimized. Once the parameters are optimized, the model is ready to predict outcomes, such as the probability of a customer churning. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5da76204-4adc-452e-ad75-7224230b3e07/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=aa172e7f96f93172a13d1de7a3332f93cdc1f3384d609587f4aab4a47a6294e6&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/5da76204-4adc-452e-ad75-7224230b3e07/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=274e2f0fa2c92dced52444bc67810fc6193a594bf5a3cb3cd45474455ab78828&X-Amz-SignedHeaders=host&x-id=GetObject) ### Example Code ```python import numpy as np @@ -228,7 +228,7 @@ The goal of SVM is to find the hyperplane that maximizes the margin between the Support vectors are the data points that are closest to the hyperplane and are critical in defining the hyperplane. The optimization problem of finding the hyperplane with the maximum margin can be solved using various techniques, including gradient descent. #### Equation of the Hyperplane The hyperplane is represented by an equation involving the parameters $ w $ and $ b $. The SVM algorithm outputs the values of $ w $ and $ b $, which can then be used to classify new data points. By plugging the input values into the hyperplane equation, the classification can be determined based on whether the result is above or below the hyperplane. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7eed37c6-2065-42e3-bd1d-205237ccc626/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=8c483ed0360e2df2f6586b87118e5ea4c44470ec637d405a83dd088f3cb64b84&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7eed37c6-2065-42e3-bd1d-205237ccc626/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=1a104b7e621ed4210e4df89b18d29801efd4488adb9cecfdb1a945723aacde75&X-Amz-SignedHeaders=host&x-id=GetObject) ### Advantages and Disadvantages of SVM #### Advantages - **Effective in High-Dimensional Spaces:** SVM performs well in datasets with a large number of features. @@ -324,22 +324,22 @@ These probabilities can be represented as a vector, e.g., [0.97, 0.02, 0.01]. To $$ \hat{y} = argmax_i ([0.97, 0.02, 0.01]) = 0 $$ #### Geometric Interpretation Each $ θ_iTx $ is the equation of a hyperplane, we plot the intersection of the three hyperplanes with 0 in **Fig.1** as colored lines, in addition, we can overlay several training samples. We also shade the regions where the value of $ θ_iTx $ is largest, this also corresponds to the largest probability. This color corresponds to where a sample $ x $ would be classified. For example if the input is in the blue region, the sample would be classified $ \hat{y}=0 $, If the input is in the red region it would be classified as $ \hat{y}=1 $, and in the yellow region $ \hat{y}=2 $. We will use this convention going forward. -![f1.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/69e7fdf6-7b85-4cce-b16d-9c3a55cd0a45/f1.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=96b7a2f765e53382690e4be2a06a88beb4196778118b0a078bf5623623f5c967&X-Amz-SignedHeaders=host&x-id=GetObject) +![f1.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/69e7fdf6-7b85-4cce-b16d-9c3a55cd0a45/f1.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=4d9dd8308f74c991f77dcf1083efcdaff7dc428e4cc3b882f4aaf8e425edba76&X-Amz-SignedHeaders=host&x-id=GetObject) **Fig. 1. Equation of a hyperplane. We plot the intersection of the three hyperplanes with 0, in addition we can overlay several samples. We also shade the regions where the value of *****i***** is largest.** One problem with SoftMax regression with cross-entropy is it cannot be used for SVM and other types of two-class classifiers. ### One vs. All (One-vs-Rest) For one-vs-All classification, if we have $ K $ classes, we use $ K $ two-class classifier models, the number of class labels present in the dataset is equal to the number of generated classifiers. First, we create an artificial class we will call this "dummy" class. For each classifier, we split the data into two classes. We take the class samples we would like to classify; the rest of the samples will be labelled as a dummy class. We repeat the process for each class. To make a  classification, we can use majority vote or use the classifier with the highest probability, disregarding the probabilities generated for the dummy class. Although classifiers such as logistic regression and SVM class values are $ \{0,1\} $ and $ \{−1,1\} $ respectively we will use arbitrary class values. Consider the following samples colored according to class $ y=0 $ for blue, $ y=1 $ for red, and $ y=2 $ for yellow: -![f2.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e9ce04e2-05b9-49ad-8b2a-2d4db3a931a1/f2.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=e84087a21b4b3927ea2c8cf4f64c821a6b37ba5d8ce16c15650bc8a3ed85756d&X-Amz-SignedHeaders=host&x-id=GetObject) +![f2.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e9ce04e2-05b9-49ad-8b2a-2d4db3a931a1/f2.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=5e2f9aadbcff94fa720e4096a55d5389fa6b3bdb09a869d9b9dfeecd0b18b9f1&X-Amz-SignedHeaders=host&x-id=GetObject) **Fig. 2. Samples colored according to class.** For each class we take the class samples we would like to classify, and the rest will be labeled as a “dummy” class. For example, to build a classifier for the blue class we simply assign all other labels that are not in the blue class to the Dummy class, we then train the classifier accordingly. The result is shown in **Fig. 3** where the classifier predicts blue $ \hat{y}=0 $ and in the purple region where we have our “dummy class” $ \hat{y}=dummy $. -![f3.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/695da917-f2bb-4303-a1cb-03516f67aded/f3.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=a898d66be130973ad0dab2a21b1c4363cb05a75fe7ed158ae7fbcef0d4fbca99&X-Amz-SignedHeaders=host&x-id=GetObject) +![f3.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/695da917-f2bb-4303-a1cb-03516f67aded/f3.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=bda5fff5ef618e0660857f11e9ae6c658e05c14499def644a2a7127e218fb348&X-Amz-SignedHeaders=host&x-id=GetObject) **Fig. 3. The classifier predicts blue **$ \hat{y}=0 $** in blue region and dummy class **$ \hat{y}=dummy $** in purple region.** We repeat the process for each class as shown in **Fig. 4**, the actual class is shown with the same color and the corresponding dummy class is shown in purple. The color of the space is the actual classifier predictions shown in the same manner as above. -![f4.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e1e9a232-a9d2-45b8-9180-93e3b6762798/f4.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=42107bd64fbbafbf5265c63a4ec82d5e4e742b483ecc47c7195bfabe94d95616&X-Amz-SignedHeaders=host&x-id=GetObject) +![f4.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e1e9a232-a9d2-45b8-9180-93e3b6762798/f4.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=491c8ad34acc862a27765f637842e21b6bcc9e256cfe947b835ede454485347a&X-Amz-SignedHeaders=host&x-id=GetObject) **Fig. 4. The classifier predicts **$ \hat{y}=0,1,2 $** in blue, red, and yellow region and dummy class ** $ \hat{y}=dummy $** in purple region.** @@ -358,23 +358,23 @@ For a sample in the blue region, the output for each classifier is evaluated: As a result, the selected output is $ \hat{y}_0 = 0 $, where the subscript indicates the classifier number. One issue with one vs all is the ambiguous regions as shown in **Fig. 5** in purple. In these regions you may get multiple classes for example $ \hat{y}_0=0 $ and $ \hat{y}_1=1 $ or all the outputs will equal ”dummy.” -![f5.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/76ebb089-707a-4903-8c87-71c4297fe5ee/f5.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=47a193b6c74d8aabe6e67edd32b91a7e6bfe3e9a34503607f6c7343163c2e495&X-Amz-SignedHeaders=host&x-id=GetObject) +![f5.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/76ebb089-707a-4903-8c87-71c4297fe5ee/f5.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=bf49617a3fcb01175edb3f27f1d0196ff8715e42e2dedbacdab44f8c62a73c4c&X-Amz-SignedHeaders=host&x-id=GetObject) **Fig. 5. The classifier predicts all outputs **$ \hat{y}_0,\hat{y}_1,\hat{y}_2 $** will equal "dummy."** There are several ways to reduce this ambiguous region, you can use the output based on the output of the linear function this is called the fusion rule. We can also use the probability of a sample belonging to the actual class as shown in **Fig. 6**, where we select the class with the largest probability in this case $ \hat{y}_0 $; we disregard the dummy values. These probabilities are scores, as the probabilities are between the dummy class and the actual class not between classes. Just a note packages like Scikit-learn can output probabilities for SVM. -![f6.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/edd3acc1-17c4-4027-9878-7866cb4f689b/f6.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=828bed71806bb7c829536d1a9e849eddfa699e26af4ba1b1598fb6a2751b6b66&X-Amz-SignedHeaders=host&x-id=GetObject) +![f6.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/edd3acc1-17c4-4027-9878-7866cb4f689b/f6.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=6e05ff5226b432c0c5a8bb6fc6f1f61d4b2141ce92a52e02c84de6d4a0bd58f9&X-Amz-SignedHeaders=host&x-id=GetObject) **Fig. 6. Probability of a sample belonging to the actual class compared to dummy variable, selects the class with the highest probability.** ### One-vs-One classification In One-vs-One classification, we split up the data into each class; we then train a two-class classifier on each pair of classes. For example, if we have class 0,1, and 2, we would train one classifier on the samples that are class 0 and class 1, a second classifier on samples that are of class 0 and class 2, and a final classifier on samples of class 1 and class 2. **Fig. 7 **is an example of class 0 vs class 1, where we drop training samples  of class 2. Using the same convention as above where the color of the training samples are based on their class. The separating plane of the classifier is in black.  The color represents the output of the classifier for that particular point in space. -![f7.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b83bec6c-a8bb-461f-a317-d5026af7e744/f7.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=566b2b3bdfdd4b080012b432bf13f62c123a188074811c0bab49f81b3207c6bc&X-Amz-SignedHeaders=host&x-id=GetObject) +![f7.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b83bec6c-a8bb-461f-a317-d5026af7e744/f7.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=cd874d86ede943c477576706cf8a92e75d31d22e410363cc002f49774c6a475d&X-Amz-SignedHeaders=host&x-id=GetObject) **Fig. 7. Probability of a sample belonging to the actual class compared to dummy variable , select the class with the highest probability.   ** We repeat the process for each pair of classes, in Fig 8. For $ K $ classes, we have to train $ K(K−1)/2 $ classifiers. So if $ K=3 $, we have $ (3×2)/2=3 $ classes. -![f8.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c0b45902-990a-463c-b94f-a0b9cc679bc7/f8.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=254ebacf6c666a2e84ed3b408e5489d96a372fb451d2ad3f085a207f4b670f5a&X-Amz-SignedHeaders=host&x-id=GetObject) +![f8.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c0b45902-990a-463c-b94f-a0b9cc679bc7/f8.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=967a6a410e51eabc1aa337e8514168ea48d5c90aa9a441a09e73f4266ae5bced&X-Amz-SignedHeaders=host&x-id=GetObject) **Fig. 8. Probability of a sample belonging to the actual class compared to dummy variable, select the class with the highest probability.** To perform Classification on a sample, we perform a majority vote where we select the class with the most predictions. This is shown in **Fig. 9** where the black point represents a new sample and the output of each classifier is shown in the table. In this case, the final output is one as selected by two of the three classifiers. There is also an ambiguous region but it’s smaller, we can also use similar schemes as in One vs all like the fusion rule or using the probability. -![f9.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/542d9569-324a-4a2d-83b0-814d28179694/f9.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=5c5191a427c62965921153f11ea2238fdc7d357f5f599fdc8b9ac76d71721c8a&X-Amz-SignedHeaders=host&x-id=GetObject) +![f9.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/542d9569-324a-4a2d-83b0-814d28179694/f9.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=34078460801271c3cc7e7a71fcba2f3034cacf5dcc12bedbbbd8fbcf7fb6697b&X-Amz-SignedHeaders=host&x-id=GetObject) ___ ## GridSearchCV: Hyperparameter Tuning in Machine Learning ### Introduction to GridSearchCV diff --git a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 5 - Clustering/Module 5 - Clustering.md b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 5 - Clustering/Module 5 - Clustering.md index efd5af936..391c76ebe 100644 --- a/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 5 - Clustering/Module 5 - Clustering.md +++ b/data/Specialization/IBM AI Engineering Professional Certificate/Machine Learning with Python/Modules/Module 5 - Clustering/Module 5 - Clustering.md @@ -4,8 +4,8 @@ ## Clustering: An Introduction ### Overview of Clustering Clustering is an unsupervised learning technique used to group similar data points into clusters based on their characteristics. This method is commonly applied in various domains to segment data, identify patterns, and make predictions. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9cb01ce9-5e0d-49ef-8f43-c9db38fbc0e0/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=4ca86ed1db47030bf4284706bd5103e63360347f26cd7e134c4a97d4c93c613c&X-Amz-SignedHeaders=host&x-id=GetObject) -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ede0dba7-3f63-4051-85fd-51f2f38eeeb5/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=f0de22419284686ece0e3281f1b41c51989e4e8af2d33a87b582d928b03e0616&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9cb01ce9-5e0d-49ef-8f43-c9db38fbc0e0/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=f058094a2fa29c299751095527340ea7c95c38b11de206ea3789ef017a0ccabf&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ede0dba7-3f63-4051-85fd-51f2f38eeeb5/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=d32e8867dfbad9728c459908338bc99baff2cad104c515b55349fdabb3210333&X-Amz-SignedHeaders=host&x-id=GetObject) ### Applications of Clustering 1. **Customer Segmentation**: - Clustering is widely used for customer segmentation in marketing. It helps businesses to group customers based on demographic or behavioral similarities, allowing for targeted marketing strategies. @@ -37,7 +37,7 @@ Clustering is an unsupervised learning technique used to group similar data poin 9. **Density-based Clustering**: - Creates arbitrary-shaped clusters with algorithms such as **DBSCAN (Density-Based Spatial Clustering of Applications with Noise)**. - Useful for spatial data or noisy datasets. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/23d540d1-3363-46c0-b145-c20928ff781b/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=d6245c4e1334f3d55731ffaff64513fdc34d10265de8b1dada91b4a5c3b00706&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/23d540d1-3363-46c0-b145-c20928ff781b/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=72e8ab82966341fd4dad30d445c4fccab115dbe22b3cd7d3a2b9c7f7ffa2461e&X-Amz-SignedHeaders=host&x-id=GetObject) ### Differences Between Clustering and Classification - **Clustering**: - Unsupervised learning. @@ -60,7 +60,7 @@ K-Means Clustering is an unsupervised learning algorithm used for partitioning a ### Key Concepts - **Customer Segmentation**: Dividing a customer base into groups with similar characteristics. - **Partitioning Clustering**: K-Means is a type of partitioning clustering that divides data into K non-overlapping clusters. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8af3f76b-b350-4668-99db-ffde6afd7a48/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=cd3c16a8c09add5cb5c6eb39759b66d377ae7ee2647269d019112316ecff5881&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8af3f76b-b350-4668-99db-ffde6afd7a48/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=e77e24e4c3ec646a2804c06fef31bd6d1d26eba3ed5fe019c2b0ff42c333350c&X-Amz-SignedHeaders=host&x-id=GetObject) ### Steps in K-Means Clustering 15. **Initialization** - Randomly select K initial centroids from the dataset or create K random points as centroids. @@ -71,7 +71,7 @@ K-Means Clustering is an unsupervised learning algorithm used for partitioning a - Recalculate the centroids by taking the mean of all data points assigned to each centroid. 18. **Iteration** - Repeat the assignment and update steps until the centroids no longer move or the changes are minimal. -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/16d20e8e-68c0-4ad6-83fa-24ee550846a6/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=8f0d59be4e63a2416a4e28cbb003ec0cde8701d9dd0a9f6fb8c0dacd933286f3&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/16d20e8e-68c0-4ad6-83fa-24ee550846a6/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=6a33af01ee104b7bef1617fe8e60f0922cfed5eaafb614650b572b3ccf775456&X-Amz-SignedHeaders=host&x-id=GetObject) ### Distance Metrics - **Euclidean Distance**: Commonly used to measure the distance between data points. - Other metrics: Cosine similarity, Manhattan distance, Minkowski distance, etc., depending on the data type and domain. @@ -116,7 +116,7 @@ plt.title('K-Means Clustering') plt.show() ``` **Output:** -![Figure_1.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/73a2c105-2ca5-46a7-974c-ec918cf62c91/Figure_1.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=95aaf481800a8371afeb4c5b6058281a5e8081d41bcac1bced6d10534f211ad9&X-Amz-SignedHeaders=host&x-id=GetObject) +![Figure_1.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/73a2c105-2ca5-46a7-974c-ec918cf62c91/Figure_1.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=c50e79f18179b04aa9a6854d4f6850704fa1f3eeea5423b84220b2d09f75e14e&X-Amz-SignedHeaders=host&x-id=GetObject) ### Explanation 19. **Import Libraries**: Necessary libraries are imported. 20. **Sample Data**: A sample dataset with 'Age' and 'Income' is created. @@ -142,7 +142,7 @@ K-Means clustering is a partition-based clustering algorithm used to partition a Evaluating K-Means clustering is challenging, especially since it is an unsupervised learning algorithm. Common methods to assess clustering quality include: - **Within-Cluster Sum of Squares (WCSS)**: Measures the average distance between data points and their cluster centroids. Lower values indicate better clustering. - **Elbow Method**: Helps determine the optimal number of clusters (K). Plot WCSS against the number of clusters and look for the "elbow" point where the rate of decrease **sharply shifts***.* -![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7d3cdfd2-3a59-4bf7-8d34-4b4314e49abd/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=0508b63e4b008ad6eacfdb22b38d447e8062297f88885b55497f7e1f48be2f06&X-Amz-SignedHeaders=host&x-id=GetObject) +![image.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7d3cdfd2-3a59-4bf7-8d34-4b4314e49abd/image.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b926d077a20b89e2cfb8e96a6a15443a1dc50b973f67c81c022bd1e7331625b8&X-Amz-SignedHeaders=host&x-id=GetObject) ### Example Code Below is a code example demonstrating K-Means clustering and the elbow method to find the optimal number of clusters: ```python @@ -186,8 +186,8 @@ plt.ylabel('Feature 2') plt.show() ``` **Outputs:** -![Figure_1.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/74024f1a-9e67-4a06-856e-ff0920d20ba0/Figure_1.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=d47c293900f0574dba3a0b66b786bc0bf92c9d765d1df60e9e0ab86916eb82ba&X-Amz-SignedHeaders=host&x-id=GetObject) -![Figure2.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/14af08ae-a84c-4391-95ac-9cee37c62973/Figure2.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=670648f4c44c29cf52c6af8ddecb539550826abe0c52f97d7f176f72f3c9fab3&X-Amz-SignedHeaders=host&x-id=GetObject) +![Figure_1.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/74024f1a-9e67-4a06-856e-ff0920d20ba0/Figure_1.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=4997416026a30628ce4c3b68f1af6512ff63be84c542873994e116e066237300&X-Amz-SignedHeaders=host&x-id=GetObject) +![Figure2.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/14af08ae-a84c-4391-95ac-9cee37c62973/Figure2.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=a3d5f8bcc56665de35dca919b3633d4df606773e843be6f7b081d97557f63fb3&X-Amz-SignedHeaders=host&x-id=GetObject) ### Key Characteristics of K-Means - **Partition-Based**: Divides data into K clusters based on similarity. - **Efficiency**: Relatively efficient on medium and large-sized datasets. diff --git a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Helpers/Achievements/Achievements.md b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Helpers/Achievements/Achievements.md index 1cd1e371a..0260102b6 100644 --- a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Helpers/Achievements/Achievements.md +++ b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Helpers/Achievements/Achievements.md @@ -2,6 +2,6 @@ # Achievements ## Certificate -[Data_Analysis_with_Python_Certificate.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1aa3a050-2338-4a85-85d5-899bad17a31c/Data_Analysis_with_Python_Certificate.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=bfe6357340f44bc0479a0be18cb713a0277dbf4327a518b2701b0bc4d8592740&X-Amz-SignedHeaders=host&x-id=GetObject) +[Data_Analysis_with_Python_Certificate.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1aa3a050-2338-4a85-85d5-899bad17a31c/Data_Analysis_with_Python_Certificate.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=27e8fc84a27f65d2786b379d2a3658bf1d6e49c0882fc709184703228a37867d&X-Amz-SignedHeaders=host&x-id=GetObject) ## Badge -[Data_Analysis_with_Python_Badge.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4fa9bcf8-b584-40dd-8775-c0bfadf6a6f0/Data_Analysis_with_Python_Badge.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=082a3ce9bb84ebfd3803f2b320437a4f224b266ebba59f29f4de413bc6e4c7ee&X-Amz-SignedHeaders=host&x-id=GetObject) +[Data_Analysis_with_Python_Badge.pdf](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4fa9bcf8-b584-40dd-8775-c0bfadf6a6f0/Data_Analysis_with_Python_Badge.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=bdecdabf0b6b6a9e8accfb8191d7fc8f6c03eefdfb8f92a0f30f4f04642e51da&X-Amz-SignedHeaders=host&x-id=GetObject) diff --git a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 1 - Importing Data Sets/Module 1 - Importing Data Sets.md b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 1 - Importing Data Sets/Module 1 - Importing Data Sets.md index b0e46d486..da0ecadc0 100644 --- a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 1 - Importing Data Sets/Module 1 - Importing Data Sets.md +++ b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 1 - Importing Data Sets/Module 1 - Importing Data Sets.md @@ -21,7 +21,7 @@ ___ - **Description:** Includes functions for advanced math problems and data visualization. - **Features:** Solves complex mathematical problems. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/997ac361-58a8-4f04-bb0f-79fea4baa761/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=72327bb228debabd7b5fb661c46a7474e76cdb055843650004876722ac50ec42&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/997ac361-58a8-4f04-bb0f-79fea4baa761/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=9bda4593bf08aa6aa85a5b29c175840de479f0f0e6b51ddde76ae1594187262f&X-Amz-SignedHeaders=host&x-id=GetObject) ___ ### Data Visualization Libraries #### 1. **Matplotlib** @@ -31,7 +31,7 @@ ___ - **Description:** A high-level visualization library based on Matplotlib. - **Features:** Easy to generate various plots like heat maps, time series, and violin plots. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/733d1e42-5a53-4fd8-90c1-3d85254369a6/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=08921bbcceed802d34335dd760ab819616215b44755d901079312f005946f782&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/733d1e42-5a53-4fd8-90c1-3d85254369a6/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=94f74a45ef713622f9efe4c281331d2749be0d0d61a5f5cb93bcb5f2d8071f28&X-Amz-SignedHeaders=host&x-id=GetObject) ___ ### Algorithmic Libraries #### 1. **Scikit-learn** @@ -40,7 +40,7 @@ ___ #### 2. **Statsmodels** - **Description:** A module for exploring data, estimating statistical models, and performing statistical tests. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c62885f5-417d-4179-834f-d68f8f2bdf39/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=2d8abb500020d86f2f111f03605e3ef221a27f37496ed4e8771f4aa0177f06e5&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c62885f5-417d-4179-834f-d68f8f2bdf39/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b436246f396417096eef06111fa95cbb42d67fb62584885729fb39008f10bdcd&X-Amz-SignedHeaders=host&x-id=GetObject) ___ ## Reading Data with Pandas Data acquisition is the process of loading and reading data into a notebook from various sources. Using Python’s Pandas package, we can efficiently read and manipulate data. diff --git a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 2 - Data Wrangling/Module 2 - Data Wrangling.md b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 2 - Data Wrangling/Module 2 - Data Wrangling.md index 452b7678c..3cdf6d885 100644 --- a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 2 - Data Wrangling/Module 2 - Data Wrangling.md +++ b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 2 - Data Wrangling/Module 2 - Data Wrangling.md @@ -36,7 +36,7 @@ Missing values are a common issue in datasets and occur when no data value is st #### Identification of Missing Values - **Common Representations**: NaN, ?, N/A, 0, or blank cells. - **Example**: The `normalized losses` feature has missing values represented as **NaN**. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/52ba3383-bb5a-48e0-8404-2b9dadcf9392/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=6004e20c03a96dda74aeba4a49d9b532696fe43a6721f1ab59f198651b672c51&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/52ba3383-bb5a-48e0-8404-2b9dadcf9392/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171424Z&X-Amz-Expires=3600&X-Amz-Signature=5caed80a02e5121162ecb04152da014960b53a969f0755db01a4e898622d2906&X-Amz-SignedHeaders=host&x-id=GetObject) #### Strategies to Handle Missing Values 1. **Recollection**: - Check if the original data collectors can provide the missing values. @@ -44,7 +44,7 @@ Missing values are a common issue in datasets and occur when no data value is st - **Dropping Entries**: Remove the entire row or column with missing values. - Suitable when only a few observations have missing values. - Example: If the `price` column has missing values and it's the target variable, drop the rows with missing prices. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/08d6fa26-a234-4a16-b8d4-c6d7102d2a2f/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=3354aef4b9b52fb866900a0277e23ba566212fa2e1be31859bcab8159b9b7a43&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/08d6fa26-a234-4a16-b8d4-c6d7102d2a2f/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=487baa583f2199e3a8787c24c87932318e1cae9a4b8a6003f7ecdc14d7b35351&X-Amz-SignedHeaders=host&x-id=GetObject) - **Pandas Method**: ```python df.dropna(axis=0, inplace=True) # Drop rows with missing values @@ -54,7 +54,7 @@ df.dropna(axis=1, inplace=True) # Drop columns with missing values - **Mean/Median/Mode**: - Replace missing values with the mean (for numerical data), median, or mode (for categorical data). - Example: Replace missing `normalized losses` with the mean of the column. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f4791630-48b4-4a44-ba8b-95b0c1d6759b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=d84f1f1e87582a9d65b0e074fcbb14e8ec691626a6ec53a94bb1447c32df9f35&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f4791630-48b4-4a44-ba8b-95b0c1d6759b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=38d6d1a4e27a54a55fa41d9b528c83555652194a9192454a2aaad19c4a6d0ef1&X-Amz-SignedHeaders=host&x-id=GetObject) - **Pandas Method**: ```python mean_value = df['normalized_losses'].mean() @@ -87,7 +87,7 @@ Data collected from various sources often comes in different formats, units, and - **Consistency**: Ensures that data is standardized for analysis. - **Clarity**: Makes data easily understandable. - **Examples**: Representing "New York City" consistently as "NY" or converting measurement units for uniformity. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b1af152b-1030-49c0-b8ce-858e515dacbc/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=fae7235d38e74bc21432db98c5baa68c0273d3c997b7ceca9b55d1d5ee80f25f&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/b1af152b-1030-49c0-b8ce-858e515dacbc/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=901f8e2fc84622dfa8a4a6890262aad2c888860bbf6fd6796aee164adfd8b140&X-Amz-SignedHeaders=host&x-id=GetObject) #### Common Issues and Solutions 7. **Inconsistent Naming Conventions**: - **Example**: Different representations of "New York City" such as "N.Y.", "Ny", "NY", "New York". @@ -148,7 +148,7 @@ Data normalization is an essential preprocessing technique used to standardize t - Normalization ensures each feature has an equal influence on the model. 15. **Computational Efficiency**: - Prevents features with larger ranges from dominating the model (e.g., in linear regression, larger value ranges might bias the model). -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/da5c198c-c176-40b5-98f6-10f801ec4bb9/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=e088a974e5273aa8dcb9fcce9565fd1b6f83650ded98b498aaf8c726f4988f93&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/da5c198c-c176-40b5-98f6-10f801ec4bb9/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=8ca13c29e346f8dd1c822520a9f47b566e7a2f2c664e4981f0fa73171e665e20&X-Amz-SignedHeaders=host&x-id=GetObject) #### Methods of Normalization 16. **Simple Feature Scaling**: - **Formula**: @@ -158,7 +158,7 @@ $$ x_{new} = \frac{x_{old}}{x_{max}} $$ ```python df['length'] = df['length'] / df['length'].max() ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/011e19cf-0bb6-4853-bf97-527c877b7913/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=02ce77e8b1e575c7379fa428b33cabd2f9d42fe66830bb8acabe734feaeac4a1&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/011e19cf-0bb6-4853-bf97-527c877b7913/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=e4da03505615b784c9fc75949194225ef6bac129ce2970f2c632fc7016edd4f2&X-Amz-SignedHeaders=host&x-id=GetObject) 17. **Min-Max Scaling**: - **Formula**: $$ x_{new} = \frac{x_{old} - x_{min}}{x_{max} - x_{min}} $$ @@ -168,7 +168,7 @@ $$ x_{new} = \frac{x_{old} - x_{min}}{x_{max} - x_{min}} $$ df['length'] = (df['length'] - df['length'].min()) / (df['length'].max() - df['length'].min()) ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9a3e8d8f-fde2-45ad-ba84-11dffd074993/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=3dbfb584575611419eb68bceb80c6d5f641571b90d5fffddcf3b01a6542ecb35&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9a3e8d8f-fde2-45ad-ba84-11dffd074993/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=213d40a9f23d37a0ec1a3a1b26acf0f341d52e8f1da89da485f96d7931ce737b&X-Amz-SignedHeaders=host&x-id=GetObject) 18. **Z-Score (Standard Score) Normalization**: - **Formula**: $$ x_{new} = \frac{x_{old} - \mu}{\sigma} $$ @@ -177,7 +177,7 @@ $$ x_{new} = \frac{x_{old} - \mu}{\sigma} $$ ```python df['length'] = (df['length'] - df['length'].mean()) / df['length'].std() ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/18688735-45f9-4dbf-b6f3-d034c2402668/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=7c0045d2f1047b905ac9b1fdb33d12c09732c5f5b8e6c9c8a3cbc5e97ff1a0af&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/18688735-45f9-4dbf-b6f3-d034c2402668/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=934ec09d85d50e2c8c2f9a937779677d3d81ab28923d7d7c6cf29b07c79c464a&X-Amz-SignedHeaders=host&x-id=GetObject) #### Example Implementation in Python Given a dataset containing a feature `length`: 19. **Simple Feature Scaling**: @@ -208,7 +208,7 @@ Binning is a data preprocessing technique where numerical values are grouped int **Application on Car Price Data**: - **Range**: The price ranges from $5,188 to $45,400 with 201 unique values. - **Binning**: We categorize prices into three bins: low price, medium price, and high price. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/dbae2f85-b73c-4c1b-b3dc-26d62ce4ecfa/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=472826810d7ca46b49f8825650492f5d3c406dda54b209cabfc0a4e0672db941&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/dbae2f85-b73c-4c1b-b3dc-26d62ce4ecfa/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=24f94ba5966a967c064d648a5ccb2b7f78cead9ab4fa839d4edc64db8ea24947&X-Amz-SignedHeaders=host&x-id=GetObject) #### **Steps to Implement Binning in Python**: 24. **Determine Bin Dividers**: - Use NumPy's `linspace` function to create equally spaced bin dividers. @@ -257,7 +257,7 @@ plt.ylabel('Number of Cars') plt.title('Histogram of Binned Car Prices') plt.show() ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7b15f63c-194d-4b16-adb0-2e54f99ccf11/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=24e95e1b5065ce6013c1102ca796b5051072e16e716a7070564ce70f447dd07d&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7b15f63c-194d-4b16-adb0-2e54f99ccf11/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=1966791ac4386382124690bcd7d84fc2529476e5f6f8f87f72225949a6a32ae0&X-Amz-SignedHeaders=host&x-id=GetObject) #### Conclusion Binning is a powerful technique for simplifying data analysis and improving model performance. By categorizing continuous variables into discrete bins, we can gain clearer insights and more effectively leverage statistical methods. ___ @@ -310,7 +310,7 @@ print(df) 2 gas 0 1 ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ed895fe2-732d-4632-96db-0746e1225a52/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=0b6d21b8c6c0cf9e93e1df4bedfa6b39be39a20b9424cfb9d9f6128190f8897d&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ed895fe2-732d-4632-96db-0746e1225a52/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=13ada1f63802cf08a39dbbe031436e15e213cc6c1d37415729ed01e962bc8371&X-Amz-SignedHeaders=host&x-id=GetObject) #### Indicator Variable **What is an indicator variable?** An indicator variable (or dummy variable) is a numerical variable used to label categories. They are called 'dummies' because the numbers themselves don't have inherent meaning. diff --git a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 3 - Exploratory Data Analysis/Module 3 - Exploratory Data Analysis.md b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 3 - Exploratory Data Analysis/Module 3 - Exploratory Data Analysis.md index 1931a76b4..981525343 100644 --- a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 3 - Exploratory Data Analysis/Module 3 - Exploratory Data Analysis.md +++ b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 3 - Exploratory Data Analysis/Module 3 - Exploratory Data Analysis.md @@ -72,7 +72,7 @@ Box plots help compare distributions between groups. import seaborn as sns sns.boxplot(x='drive-wheels', y='price', data=df) ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7e6d594d-952e-44b6-97ea-31225882aea6/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=394f633f5d5422b11e9a37f9a5f37cdc2fc4a253a10f8e67666ab79b6f298dd7&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7e6d594d-952e-44b6-97ea-31225882aea6/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=2e185e11a954966b284a06cf0a4d28eda8d83058b28d9ff5ae5f80506dfb1e62&X-Amz-SignedHeaders=host&x-id=GetObject) ### Scatter Plots Scatter plots visualize the relationship between two continuous variables. They help identify how changes in one variable are associated with changes in another. - **Predictor Variable:** The variable used to predict an outcome (e.g., engine size). @@ -90,7 +90,7 @@ plt.title('Scatterplot of Engine Size vs Price') plt.show() ``` ![insert_image_url_here](insert_image_url_here) -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cbfaed9e-b398-4902-8936-dea058b21def/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=bd6f65f12cd9909dcc70eb89f6391086d72a386bbfd51cb7f77c12e3ed1f3d25&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cbfaed9e-b398-4902-8936-dea058b21def/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=8d1bc9b6d6f010986dd0e8c9f86b7ac548cec997c97396bcdcadea575fcc142a&X-Amz-SignedHeaders=host&x-id=GetObject) From the scatter plot, you can observe that as engine size increases, the price of the car also increases, indicating a positive linear relationship. ![insert_image_url_here](insert_image_url_here) ___ @@ -152,7 +152,7 @@ plt.title('Title') plt.show() ``` #### **Example Output** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/91181646-b1e0-4433-9711-6259a96a9247/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=c4bc7822db89993b735315794080077fae27bf654ccbea0216e05bc180d0bd28&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/91181646-b1e0-4433-9711-6259a96a9247/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=af14b4f91dd55a2b24acbd42261ab93013e8d97a2ebc7b2e1ef573a350860ee4&X-Amz-SignedHeaders=host&x-id=GetObject) ![placeholder_for_image](placeholder_for_image) Using the `groupby` method, pivot tables, and heatmaps provides valuable insights into the relationships between different variables in the dataset. @@ -187,7 +187,7 @@ The simplest and most fundamental plot is a standard line plot. The function exp plt.plot(x, y) ``` **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/09aba1c0-0d55-41dd-852a-a04c5b8a3fac/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162020Z&X-Amz-Expires=3600&X-Amz-Signature=7447e16bd1dcf06c822af6ede4084b1a9f53ca88022f8e571071498e08260eb5&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/09aba1c0-0d55-41dd-852a-a04c5b8a3fac/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=32dab56b3b2dec69948bd9f6c767cbfe054f830621a8c3fc2bf5795a8a7a6d46&X-Amz-SignedHeaders=host&x-id=GetObject) ![](#) ___ #### 2. Scatter Plot @@ -197,7 +197,7 @@ Scatter plots present the relationship between two variables in a dataset. It re plt.scatter(x, y) ``` **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/23708af9-659f-4f23-b626-1a4292d7842c/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162019Z&X-Amz-Expires=3600&X-Amz-Signature=efe014fab3e9a81b770a3c644605ad1ccab0d96b010ad687bff4e34a319346fc&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/23708af9-659f-4f23-b626-1a4292d7842c/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=a30edd661dd2f5ca17bfca1e580c51c9f23a6bc5027ad672d7e5bb956525a350&X-Amz-SignedHeaders=host&x-id=GetObject) ![](#) ___ #### 3. Histogram @@ -207,7 +207,7 @@ A histogram is an important visual representation of data in categorical form. T plt.hist(x, bins) ``` **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/24e4424a-df87-40a1-b63b-195cbdc2e0ab/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162019Z&X-Amz-Expires=3600&X-Amz-Signature=a59d9a4e9b1a8ed75e1945fae41f276c37b375f7bac29d8c8c3962e0034f24af&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/24e4424a-df87-40a1-b63b-195cbdc2e0ab/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=9b639b196d797ca2157b3664b927e551785f89be4673b3c23acd23b3f13b3dca&X-Amz-SignedHeaders=host&x-id=GetObject) ![](#) Use an additional argument, `edgecolor`, for better clarity of plot. ___ @@ -218,7 +218,7 @@ A bar plot is used for visualizing categorical data. The y-axis represents the n plt.bar(x, height) ``` **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ab5a6dfe-51f5-43ee-bcb3-33dae4a1c7ad/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162019Z&X-Amz-Expires=3600&X-Amz-Signature=55f28ac07a5087e58ef3fffaf0bde649f0805b0a50bd792b8c1a764b661fbf8b&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/ab5a6dfe-51f5-43ee-bcb3-33dae4a1c7ad/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=81a0127e6404167e56be88a265b9ed2c75d4ea346324314f601ea7dc0ef8c534&X-Amz-SignedHeaders=host&x-id=GetObject) Here, `x` is the categorical variable, and `height` is the number of values belonging to the category. You can adjust the width of each bin using an additional `width` argument in the function. ![](#) ___ @@ -230,7 +230,7 @@ plt.pcolor(C) ``` You can define an additional `cmap` argument to specify the color scheme of the plot. **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8f1b1d60-cf1b-42b3-9faa-f634c89c3f84/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162020Z&X-Amz-Expires=3600&X-Amz-Signature=5c18d21faa887deb340fb6eb20c4e3514724a3f892e9baef2ff084a339cc8f79&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8f1b1d60-cf1b-42b3-9faa-f634c89c3f84/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=0d34603ee6d43d41d841378190124e9d29e8cda8dbc7272de12532abfcebbfa3&X-Amz-SignedHeaders=host&x-id=GetObject) ![](#) ___ ### Seaborn Functions @@ -241,7 +241,7 @@ A regression plot draws a scatter plot of two variables, `x` and `y`, and then f sns.regplot(x='header_1', y='header_2', data=df) ``` **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/13ad0497-05fe-4eaa-984e-707b33e14761/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162020Z&X-Amz-Expires=3600&X-Amz-Signature=11056b206ee9bb70065c32db3bcf114f43921fba18bab78e5a054f46cf9607fe&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/13ad0497-05fe-4eaa-984e-707b33e14761/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=fe9b3dbe21190f2bd9858d11a13c7dcd62d5e136902a560ee1edf497a1a3b911&X-Amz-SignedHeaders=host&x-id=GetObject) ![](#) ___ #### 2. Box and Whisker Plot @@ -253,9 +253,9 @@ sns.boxplot(x='header_1', y='header_2', data=df) **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d207ae92-0a7c-4e2f-aa65-0ee5a2c33bf7/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162022Z&X-Amz-Expires=3600&X-Amz-Signature=d02e34bb5b14263a9ce7c19e0cf62e6c80735b430da763e1911d66a2e0a587e0&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d207ae92-0a7c-4e2f-aa65-0ee5a2c33bf7/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171423Z&X-Amz-Expires=3600&X-Amz-Signature=ae5752717faf3346f6132acd9953e41217d3c37600214f7710cda587168a2b9d&X-Amz-SignedHeaders=host&x-id=GetObject) -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0e516edc-7551-4792-ab18-0494db3c4c0c/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162022Z&X-Amz-Expires=3600&X-Amz-Signature=7ec270b21e0d92846c29f316ddd68c58340902c9b5c9ba3e4c4f98985b403752&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0e516edc-7551-4792-ab18-0494db3c4c0c/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171423Z&X-Amz-Expires=3600&X-Amz-Signature=abefc5f3bb7d74a37a9df9731e22ec825c55823607d1401946e08d975aeb96df&X-Amz-SignedHeaders=host&x-id=GetObject) ![](#) ___ #### 3. Residual Plot @@ -269,7 +269,7 @@ Alternatively: sns.residplot(x=df['header_1'], y=df['header_2']) ``` **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/23a79b9d-2356-49a9-8fd9-65c6b0ab2cc5/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162020Z&X-Amz-Expires=3600&X-Amz-Signature=8b03475ef7f9df712c81453470dd48377305dc9e3b38a46a80adccd8c2bc91c0&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/23a79b9d-2356-49a9-8fd9-65c6b0ab2cc5/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=6cf3cec3d2b88599123e5aa917b4acd99660eaaf44789341aa0c29bbe64449ea&X-Amz-SignedHeaders=host&x-id=GetObject) ![](#) ___ #### 4. KDE Plot @@ -279,7 +279,7 @@ A Kernel Density Estimate (KDE) plot is a graph that creates a probability distr sns.kdeplot(X) || sns.kdeplot(df['age']) ``` **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0d571213-2a2f-4921-a50b-880847aa05ee/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162020Z&X-Amz-Expires=3600&X-Amz-Signature=642743bb3df288ec028f3d446e4523bca8bdf894d3aa86f9e5e293ecc8dd713b&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0d571213-2a2f-4921-a50b-880847aa05ee/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=ee17cb13011aa5b24f3296fe9bacf2564816e6c5275018d9c8e38607a2ba9e2c&X-Amz-SignedHeaders=host&x-id=GetObject) ![](#) ___ #### 5. Distribution Plot @@ -290,7 +290,7 @@ sns.distplot(X, hist=False) ``` Keeping the argument `hist` as `True` would plot the histogram along with the distribution plot. **Example Output:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/53752550-ef82-4ca9-a01a-09921f0282d0/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162020Z&X-Amz-Expires=3600&X-Amz-Signature=e30b0ccb92474a5e0dd887ef49aa9eb365ef0227840452f20205301d614dab1e&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/53752550-ef82-4ca9-a01a-09921f0282d0/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=60a3fd13725710f67d1845e398e615f7b32cfeb270cb972db9f976d7241afadc&X-Amz-SignedHeaders=host&x-id=GetObject) ![](#) ___ ## 4. Correlation Between Variables @@ -300,7 +300,7 @@ Positive correlation indicates that as one variable increases, the other variabl **Example: Engine Size and Price** - **Positive Correlation:** Engine size increases, price also increases. - **Visualization:** Scatter plot with a steep positive slope. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c7ea9b0-3ef3-4357-a9c3-554fc71b6b15/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162021Z&X-Amz-Expires=3600&X-Amz-Signature=29fb62520023bc91808b6c9af57527445a012d19ed4c133797cd911b94549dbd&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c7ea9b0-3ef3-4357-a9c3-554fc71b6b15/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171423Z&X-Amz-Expires=3600&X-Amz-Signature=816e9f0ea05fb562adc703c3de13ff3ef58e052aadcfaf725690c9814c58aa6c&X-Amz-SignedHeaders=host&x-id=GetObject) **Explanation:** When engine size increases, there is a corresponding increase in the price of the vehicle. This positive correlation suggests that larger engines tend to be associated with higher prices in the market. ___ ### Negative Correlation @@ -308,7 +308,7 @@ Negative correlation indicates that as one variable increases, the other variabl **Example: Highway Miles per Gallon and Price** - **Negative Correlation:** As highway miles per gallon increases, price decreases. - **Visualization:** Scatter plot with a steep negative slope. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/10f1f798-9cc4-4df2-a9c1-5a339f554a0b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162021Z&X-Amz-Expires=3600&X-Amz-Signature=13ca87c134d99ad7547af704ba47fb0cdc1ddc3f41d75c0a2553254b1f9ef418&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/10f1f798-9cc4-4df2-a9c1-5a339f554a0b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171423Z&X-Amz-Expires=3600&X-Amz-Signature=5bdb19429b18f9bd8e95e5510d6b5bbfc98acdd6c2bc59972a050c1270205c88&X-Amz-SignedHeaders=host&x-id=GetObject) **Explanation:** When highway miles per gallon increases, the price of the vehicle tends to decrease. This negative correlation suggests that cars with higher fuel efficiency (more miles per gallon) are generally priced lower in the market. ___ ### Weak Correlation @@ -316,7 +316,7 @@ Weak correlation indicates a lack of strong relationship between the variables. **Example: RPM and Price** - **Weak Correlation:** Low and high RPM values show varied prices, indicating no strong predictive relationship. - **Visualization:** Scatter plot with no clear trend or slope. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9f914514-8914-4bf4-ac84-d9e3077f6eb1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162022Z&X-Amz-Expires=3600&X-Amz-Signature=bd37909567ccf20da9b91b0f11ec442c9d34b22053e1429569c31f3db893f2c0&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9f914514-8914-4bf4-ac84-d9e3077f6eb1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171423Z&X-Amz-Expires=3600&X-Amz-Signature=fbd3d3863237615a6d33267016b8fab16b3063a672d5f96f9c625385cf3d3935&X-Amz-SignedHeaders=host&x-id=GetObject) **Explanation:** RPM (engine revolutions per minute) does not strongly predict the price of the vehicle. Both low and high RPM values can be associated with a wide range of prices, indicating that RPM alone is not a reliable indicator of vehicle price. ### **Important Note** Correlation does not imply causation. It signifies a relationship but does not determine cause and effect. @@ -340,12 +340,12 @@ Pearson Correlation provides: - > 0.1: No certainty. #### Example: Horsepower and Car Price Example examines correlation between horsepower and car price using Pearson Correlation. Correlation coefficient is approximately 0.8, indicating strong positive correlation. p-value is much < 0.001, confirming strong certainty. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f18086e5-5b04-4fbf-8309-8944ab20d213/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162021Z&X-Amz-Expires=3600&X-Amz-Signature=9410f76a45815704d2b7342bc395c3189acdac26c390c6602292d0c900f58a28&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f18086e5-5b04-4fbf-8309-8944ab20d213/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171423Z&X-Amz-Expires=3600&X-Amz-Signature=8fd1c8506d849a1c45b92eb60fccebd24f2c79929f0c84433aa197dd1a17c570&X-Amz-SignedHeaders=host&x-id=GetObject) ___ ### Correlation Plot Heatmap visualizes correlations among variables. Color scheme indicates Pearson correlation coefficients. Dark red diagonal line shows perfect correlation (value of 1) between variables and themselves. This heatmap offers overview of variable relationships and their link with price. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cd3b341e-cc1a-45f7-8aec-cdc00436d270/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162021Z&X-Amz-Expires=3600&X-Amz-Signature=176b6c58f8472194da4e5528fa344c4983f6444da406171224602362133ff973&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/cd3b341e-cc1a-45f7-8aec-cdc00436d270/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171423Z&X-Amz-Expires=3600&X-Amz-Signature=51d51203ab4f1f2d5810f24a4da5847ff6961cddb104bf5d50ccf93e13edb02c&X-Amz-SignedHeaders=host&x-id=GetObject) **Note:** To calculate the Pearson Correlation Coefficient and P-value, use statistical functions available in Python libraries like `scipy.stats.pearsonr`. ```python diff --git a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 4 - Model Development/Module 4 - Model Development.md b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 4 - Model Development/Module 4 - Model Development.md index 0883a9ecf..1de2321e4 100644 --- a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 4 - Model Development/Module 4 - Model Development.md +++ b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 4 - Model Development/Module 4 - Model Development.md @@ -17,7 +17,7 @@ This module delves into the process of model development, focusing on predictive ### Importance of Data A model, or estimator, is essentially a mathematical equation that predicts a value based on one or more other values. It relates one or more independent variables (features) to dependent variables (outcomes). The accuracy of the model often improves with the relevance and quantity of data. Including multiple independent variables can lead to more precise predictions. For instance, consider a scenario where predicting an outcome is based on several features. If the model's independent variables do not include a crucial feature, predictions may be inaccurate. Therefore, gathering more relevant data and exploring different types of models is cru1cial for robust model development. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0fa3b083-9d5c-4760-a35a-e329e27bc8a1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=3647934a374fbe136c9daef57414b19bbf00c1a884b111ca3afd83be18d86422&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0fa3b083-9d5c-4760-a35a-e329e27bc8a1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=08d5b48774ea7993db107d152e119bddb3917fba1ad48235a3027b881b0c49f6&X-Amz-SignedHeaders=host&x-id=GetObject) ___ ## **1. Simple and Multiple Linear Regression** @@ -31,7 +31,7 @@ The relationship is defined as: $ y = b_0 + b_1 x $ - $ b_0 $: Intercept - $ b_1  $: Slope -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/dcc48d7a-ddef-4556-8880-b765ffea5656/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=b129ef9f284b3bfef5c27063780d51830ba3be5457dc891f7757a62deaf8c6c0&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/dcc48d7a-ddef-4556-8880-b765ffea5656/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=852afc6fb1e6d7eb02755d3536b457b94c1a5b099a7ebae82a24178abae9ced3&X-Amz-SignedHeaders=host&x-id=GetObject) #### Prediction Step If highway miles per gallon is 20, a linear model might predict the car price as $22,000, assuming a linear relationship. #### Training the Model @@ -59,12 +59,12 @@ predicted_values = lm.predict(x) intercept = lm.intercept_ slope = lm.coef_ ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7c5736c8-35a4-49b8-9fb9-74d756a8b7b1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=77f55723ab56223283fb82c3e72079b2d79ba3c934d8ca291da4de01b991b138&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/7c5736c8-35a4-49b8-9fb9-74d756a8b7b1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=6e681d6b8b8bc83b22882170712bb655dd613f2a19da06a35058864c970d4811&X-Amz-SignedHeaders=host&x-id=GetObject) ### 1.2 Multiple Linear Regression (MLR) Multiple linear regression (MLR) extends SLR to include multiple predictor variables ($ x1,x2, \ldots,xn $) to predict a continuous target variable ($ y $): $$ y=b_0+b_1x_1+b_2x_2+...+bn_xn_y $$ -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/74364aba-71e9-4c9f-bbb9-b7e62620571b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=c4839f5f063a91d2519c60372577aba2193f89a7445dd5dda9c9a74c89b1155a&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/74364aba-71e9-4c9f-bbb9-b7e62620571b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=be861293f45b63d2863d000cb9dd3ff31dd97bc2fb37b4a33817325a8d4ce958&X-Amz-SignedHeaders=host&x-id=GetObject) #### Visualization and Training With two predictor variables ($ x_1 $ and ), data points are mapped on a 2D plane, and () values are mapped vertically. #### Python Implementation @@ -88,10 +88,10 @@ predicted_values = lm.predict(z) intercept = lm.intercept_ coefficients = lm.coef_ ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/2469ceef-2ef8-43f5-8ce1-bd5b5d12a495/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=54a1fd34562f043745c4b412501995dbeb6e0484320aea65aacadeaa6e5c8b5a&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/2469ceef-2ef8-43f5-8ce1-bd5b5d12a495/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=e1200dd85d8c658da1d49162e14f00a452c5903667e5e3de50c1b1e51dfe599e&X-Amz-SignedHeaders=host&x-id=GetObject) In summary, SLR and MLR provide methods to model relationships between variables, helping predict outcomes based on data observations. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9dfa2a06-f57b-44f8-8e17-9cb0123300c1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=c1c0d57a9289e1f7c292ad6bda2758d02095fb0d231577a80008293341f7e48c&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9dfa2a06-f57b-44f8-8e17-9cb0123300c1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=8bec36e91e069225abb9334bc48f432113e5775b607ee29a24bf1b01b114bb73&X-Amz-SignedHeaders=host&x-id=GetObject) ___ ## 2. Model Evaluation Using Visualization ### 1. Regression Plots @@ -113,7 +113,7 @@ import seaborn as sns ```python sns.regplot(x='feature', y='target', data=df) ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/efc9c4a9-2fea-4b28-87e0-d9eb9e2462e0/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=b672fe97bfa36f0f473dd78452d9c77d66e826bd9f4d9475b11e8d5c93365955&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/efc9c4a9-2fea-4b28-87e0-d9eb9e2462e0/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=4906e78c2b675e89e6296f1728a327044194f3ee0d93cb605553282336ab720f&X-Amz-SignedHeaders=host&x-id=GetObject) ### 2. Residual Plots Residual plots represent the error between actual and predicted values. - **Process**: @@ -134,8 +134,8 @@ import seaborn as sns ```python sns.residplot(x='feature', y='target', data=df) ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8865a7c4-6c3a-4eb0-9992-911cb30106fb/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=3c08268014245219a5ed44290b5575e45e277b4cf3133122b450411920ee9364&X-Amz-SignedHeaders=host&x-id=GetObject) -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1238ba33-ad66-4d1d-9992-f51741c0b69b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=605a147ebb0d087acf769ce9a9022ea272c7a8f8345555a8443586acaac14c79&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/8865a7c4-6c3a-4eb0-9992-911cb30106fb/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=88dab5220b0aa1e02ad92797865b543aee4c810088045452447fa7945ec91d76&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1238ba33-ad66-4d1d-9992-f51741c0b69b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=7783d4aaac4fa1c9d829b0ece760074262f42290b71cf0c5e9806ea3cde2be6d&X-Amz-SignedHeaders=host&x-id=GetObject) ### 3. Distribution Plots Distribution plots visualize predicted versus actual values. - **Use**: Helpful for models with multiple independent variables. @@ -157,7 +157,7 @@ import seaborn as sns sns.kdeplot(predicted_values, color='blue', label='Predicted') sns.kdeplot(actual_values, color='red', label='Actual') ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d5eed59c-92aa-4f87-88cf-1e131752a312/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=e44507edf72244a7a39582d13e50cab306db975ce2ede33551247eba5149594f&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d5eed59c-92aa-4f87-88cf-1e131752a312/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=af89a1d49da04e8bedfd8e7399e5a9aaf7b9c8a955864cbbf256a399082e103f&X-Amz-SignedHeaders=host&x-id=GetObject) **Observation**: Prices in range from 40,000 to 50,000 are inaccurate, while 10,000 to 20,000 are closer to target values. ___ ## 3. Polynomial Regression and Pipelines @@ -165,7 +165,7 @@ ___ #### What is Polynomial Regression? - **Purpose**: Used when linear regression isn't suitable. - **Approach**: Transforms data into polynomial form to capture curvilinear relationships. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fefee895-81df-48b5-91f0-788641b6045e/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=b14bb04e4c55704ae36657921da9053543c894320799bfee65480517c61c137d&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fefee895-81df-48b5-91f0-788641b6045e/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=151889dc7e993fd2b582fca90181cb5027763200ab8fccda34489a0f3ed12ab3&X-Amz-SignedHeaders=host&x-id=GetObject) #### Types of Polynomial Models - **Quadratic (2nd Order)**: Includes squared terms. - **Cubic (3rd Order)**: Includes cubed terms. @@ -219,7 +219,7 @@ x_scaled = scaler.fit_transform(x) #### What are Pipelines? - **Purpose**: Efficiently automate data preprocessing and model training. - **Benefit**: Simplifies complex workflows by chaining multiple steps into a single process. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c62869ea-d1f8-44c7-9aec-aa8514f03e4b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=f324bea46739fa6c57596e26fd4c246f26bab528cdaf488e526174bd236e3ba2&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/c62869ea-d1f8-44c7-9aec-aa8514f03e4b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=e7dbb855c56ad92eb34d7f340b13aba8d807bdd71ab4a5287f40bda7e423712f&X-Amz-SignedHeaders=host&x-id=GetObject) #### Benefits - **Efficiency**: Simplifies code by chaining steps. - **Maintainability**: Makes workflow clearer. @@ -321,7 +321,7 @@ predicted = [210, 240, 310] mse = mean_squared_error(actual, predicted) print("MSE:", mse) # Output: MSE: 100.0 ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f5a8ae27-cc45-4723-aa6a-c8dbc6527bdf/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=80bc3f5da0857b2dabd5c22e7506a1708b912f807cb2354cb7d23db3f9ed267f&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f5a8ae27-cc45-4723-aa6a-c8dbc6527bdf/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=34882b96de4dbc03420b39271e0f5bcee040993adf88a5a16ef2dc389c71bdc4&X-Amz-SignedHeaders=host&x-id=GetObject) ### R-squared (Coefficient of Determination) - **Definition**: Indicates how well the data fits the regression line. Values range from 0 to 1, with values closer to 1 indicating a better fit. - **Formula**: $ R^2 = 1 - \frac{\text{MSE of regression}}{\text{MSE of mean}} $ @@ -348,7 +348,7 @@ print("R-squared:", r_squared) # Output: R-squared: 0.9642857142857143 - **Good Fit**: Small MSE for regression, larger for mean → $ R^2 $ near 1. - **Poor Fit**: Similar MSE for regression and mean → $ R^2 $ near 0. - **Negative **$ R^2 $: Possible overfitting. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9a75a205-fac8-4bc5-9a37-0e919c9dae58/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=be2b101a243784b5832d9c6876b7f80d4b770e84105346c520d96c3b4715caf8&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9a75a205-fac8-4bc5-9a37-0e919c9dae58/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=51c47993078ed3c1547c68f0fd1a2e21ac991131926a04e43a859b7cfa369566&X-Amz-SignedHeaders=host&x-id=GetObject) ___ ## 5. Prediction and Decision Making ### Model Evaluation @@ -356,7 +356,7 @@ To ensure a model's validity, use: - **Visualization**: Plot data to check trends and anomalies. - **Numerical Measures**: Metrics like MSE and R-squared. - **Comparison**: Evaluate different models. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1ed3169f-d09f-4aa9-bda2-6b975ae8b131/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=ff23a01f0e154956db5ed9dd3ded05f39daaf5e765b6df89b966f276a34d39a7&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/1ed3169f-d09f-4aa9-bda2-6b975ae8b131/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=3e8c16d41f2a1ade75b440d712de1942b5d377c0fcd7acc73d3f2c48bd5a3e49&X-Amz-SignedHeaders=host&x-id=GetObject) ### Example: Predicting Car Price - **Scenario**: Predict price for a car with 30 highway mpg. - **Result**: Price = $13,771.30 (reasonable value). @@ -400,9 +400,9 @@ print("Predicted Price:", predicted_price[0]) - **Interpretation**: Average squared difference between actual and predicted values. **Example MSEs:** - 495 (good fit) -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f986486a-7f71-47fb-b7a9-99fe89631b3b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=aabbe8dd2754678c715cc00682bfdb68f6f06e3e45adb7f600559f927c6efe2d&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/f986486a-7f71-47fb-b7a9-99fe89631b3b/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=eca064e1f1e19bafee7244a8b6faeca078e1f2444525113f17b5ae634696cb39&X-Amz-SignedHeaders=host&x-id=GetObject) - 12,870 (poor fit) -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4f3ee92f-9d24-4aa2-a4c1-99dd746b3e26/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=7cf4f73a959003ff642f807ca295efb3350ec537a1b1117f735afb447f430ad5&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4f3ee92f-9d24-4aa2-a4c1-99dd746b3e26/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=968f659f14ba8c855967c5e5c42781fd87002112bfd8399657d91e82fa84cabc&X-Amz-SignedHeaders=host&x-id=GetObject) **Code Example:** ```python @@ -430,7 +430,7 @@ print("R-squared:", r_squared) ### Model Comparison - **MLR vs. SLR**: More variables can lower MSE, but not always a better fit. - **Polynomial Regression**: Generally has lower MSE compared to linear regression. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9c93d33a-293b-48ea-a149-5cc33936fd0f/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=0bfba756f4f6b4cd96a5ffcbbc45ab9f4888c0fe7c1f003789d37548191bd8fb&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/9c93d33a-293b-48ea-a149-5cc33936fd0f/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171422Z&X-Amz-Expires=3600&X-Amz-Signature=35950089ae496cbf4d028ab8f48436ebed4bfb1c37e4fae0a1f593560732d36f&X-Amz-SignedHeaders=host&x-id=GetObject) ### Conclusion - Evaluate models using both visualization and numerical metrics. - Consider context and domain for interpreting R² and MSE values. diff --git a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 5 - Model Evaluation and Refinement/Module 5 - Model Evaluation and Refinement.md b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 5 - Model Evaluation and Refinement/Module 5 - Model Evaluation and Refinement.md index 8dc1b279f..947d811eb 100644 --- a/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 5 - Model Evaluation and Refinement/Module 5 - Model Evaluation and Refinement.md +++ b/data/Specialization/IBM Data Science Professional Certificate/Data Analysis with Python/Modules/Module 5 - Model Evaluation and Refinement/Module 5 - Model Evaluation and Refinement.md @@ -5,11 +5,11 @@ ### In-Sample vs. Out-of-Sample Evaluation - **In-Sample Evaluation**: Measures how well the model fits the training data. It does not estimate how well the model will perform on new, unseen data. - **Out-of-Sample Evaluation**: Assesses how the model performs on new data. This is achieved by splitting the data into training and testing sets. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/86faf38a-f355-4667-8e18-d8c7bb5daefb/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=c891e3f26e8778c7a5b4578dbcf4e312b059beb4cd67ae656c51bbd4df7ba1d6&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/86faf38a-f355-4667-8e18-d8c7bb5daefb/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=17655f2866bc40508e71b3c9047317152bd465857526b11bd46bb7f0bf29be40&X-Amz-SignedHeaders=host&x-id=GetObject) #### Data Splitting 1. **Training Data**: Used to build and train the model. Typically, a larger portion of the dataset. 2. **Testing Data**: Used to evaluate the model's performance. Usually, a smaller portion of the dataset, such as 30%. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/674e9221-07aa-4c6d-bf56-fc149ea7fa32/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=5fe886e0014d1f61207abba23df57c84a9d05a596ee482477ee19666b4a072cd&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/674e9221-07aa-4c6d-bf56-fc149ea7fa32/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=ecec36abfa14a2b470500d11452651cab8a5f4d16563e5061d6d9131e21137a5&X-Amz-SignedHeaders=host&x-id=GetObject) **Example Code**: ```python from sklearn.model_selection import train_test_split @@ -28,7 +28,7 @@ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_ - **Generalization Error**: Measures how well the model predicts new data. The error obtained using testing data approximates this error. ### Cross-Validation **Cross-Validation**: A technique to assess the model's performance and estimate generalization error by splitting the data into multiple folds. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/00529d67-52ea-4caa-bddd-32a758009645/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=55b0c8d59779b44af6b879c8865c5c86c1394045d0c4c7272938895ff299fa60&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/00529d67-52ea-4caa-bddd-32a758009645/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=e362aa068c869535ce2946959e662966fa6ac303bdc63a5f5b789fe64bdff34b&X-Amz-SignedHeaders=host&x-id=GetObject) 3. **Splitting Data**: The dataset is divided into *k* equal parts (folds). Each fold is used once as a testing set while the remaining *k − 1* folds are used as the training set. 4. **Using **`**cross_val_score**`: ```python @@ -39,8 +39,8 @@ model = LinearRegression() scores = cross_val_score(model, X, y, cv=3) # 3-fold cross-validation mean_score = np.mean(scores) ``` -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/2736152c-9607-455b-80f3-f9ca34029733/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=e23fca5324bf8f54a1380a3cd4eea5bf3adb02d0e356e80dbde7650130d98f5b&X-Amz-SignedHeaders=host&x-id=GetObject) -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/101e6426-cc5d-43a7-90f1-de74c28d2f66/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=3f526888350f5d5f31ea8e803a56f5c37a205cbeb80ad8055869c815dd59e126&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/2736152c-9607-455b-80f3-f9ca34029733/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b6d117086d363e7c027b217613f0a55903503dc3adeb599a7ce06c69eb80bb53&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/101e6426-cc5d-43a7-90f1-de74c28d2f66/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=62b5f5d620e792426b5948fdf62fe76ee54e8a488aa009b00dffa27d20bf0a68&X-Amz-SignedHeaders=host&x-id=GetObject) ### Cross-Val Predict **cross_val_predict** is used when you want to obtain the predicted values for each test fold during the cross-validation process. It returns the prediction for each data point when it was in the test set. This is useful for: 5. **Visualizing Predictions**: You can plot the predicted values against the actual values to see how well the model performs across the entire dataset. @@ -86,32 +86,32 @@ function $ y(x) $. ### **Underfitting** **Underfitting** occurs when the model is too simple to fit the data: - Example: Fitting a linear function to data generated from a higher-order polynomial plus noise results in many errors. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d0e1153e-6c20-42b7-9a45-3e20b634f29e/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=60c3b7fabe3a0c2356282d02a0539824bbececa447a4de3ea91b01a721e21a98&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d0e1153e-6c20-42b7-9a45-3e20b634f29e/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=4e48ae43dc840724fdf2dee5d8cd83f55710fc3520a81b50ea2880d1843d4b96&X-Amz-SignedHeaders=host&x-id=GetObject) ### **Overfitting** **Overfitting** occurs when the model is too flexible and fits the noise rather than the function: - Example: Using a 16th order polynomial, the model does well on training data but performs poorly at estimating the function, especially where there is little training data. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/2a1d0c40-83ca-453f-9e43-16e3448b7782/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162013Z&X-Amz-Expires=3600&X-Amz-Signature=a44b6df3149d7a98941a3c7dd8d5241a9be8bbd7075d0402025704fa9c4db557&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/2a1d0c40-83ca-453f-9e43-16e3448b7782/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=d1754ec6b84a6887dd6e87074241e4bb5d1ee6d4bae82a439614bbc117dc8d1a&X-Amz-SignedHeaders=host&x-id=GetObject) ### **Optimal Polynomial Order** - To determine the best order, we use the mean square error (MSE) for training and testing sets. - The best order minimizes the test error. - Errors on the left indicate underfitting, while errors on the right indicate overfitting. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fd80c852-c3fe-4216-92e4-f98d900c76b1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=6a00ca7cfc95cef5497721590c7ad8064c7240d615acbbcd7099ba2d4a08115a&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/fd80c852-c3fe-4216-92e4-f98d900c76b1/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=0e429a92270f3778eb58ed6a069545c669104ec648536eac9e8f4f8ec290c7c7&X-Amz-SignedHeaders=host&x-id=GetObject) ### **Irreducible Error** - Noise in the data contributes to the error, which is unpredictable and cannot be reduced. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0d8a9198-e0ee-4810-9b48-3c77c2a9497f/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=b03de9f1aa08ebfd9d7eaae4ee45694394a2754a7a2c49bd9f6b0e6dc3bcf5c7&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0d8a9198-e0ee-4810-9b48-3c77c2a9497f/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=b42efb00e67465045a846872405b1072d41725a22aef3557057ed48c83c3a6d4&X-Amz-SignedHeaders=host&x-id=GetObject) ### **Example with Real Data** - When using horsepower data: - A linear function fits the data better than just using the mean. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/865a8b17-616f-4900-992b-795b570f91a9/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=1e931e9f3a48be8423cec25a669c9f988089c4583372336db234dd862e66bbab&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/865a8b17-616f-4900-992b-795b570f91a9/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=96a805ac3e9ea71612e7b8dbf523471d34cdc8bd9661b3c234870b2805e0dd45&X-Amz-SignedHeaders=host&x-id=GetObject) - A second and third order polynomial improve the fit. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c2d83fc-759c-450f-8281-3eb119ec3a85/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=396914c9c6b5badc13d09510fc2e473db05095fbf8c9016a0825f7aaf51810e7&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c2d83fc-759c-450f-8281-3eb119ec3a85/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=363abc221ff54fe5f7ce176ce7a0b460b8d4eb23fc2f2ff3d832f06e007c88fd&X-Amz-SignedHeaders=host&x-id=GetObject) - A fourth order polynomial shows erroneous behavior. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a041aae4-06b4-4cd0-8ec4-4caa50fd1ca7/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162015Z&X-Amz-Expires=3600&X-Amz-Signature=fd3197ef80168836997c1267f9c03c2d8b105a24cde9e211549729ea3b743c34&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/a041aae4-06b4-4cd0-8ec4-4caa50fd1ca7/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=982cc0bdb48bd0ef743b416797ba5b9be40241e19c39cee360c6c015d730c2b6&X-Amz-SignedHeaders=host&x-id=GetObject) ### **R-squared Analysis** - Plot the R^2 value against the order of polynomial models. - The optimal order has an R^2 close to one. - A drastic decrease in R^2 beyond the optimal order indicates overfitting. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/92ce658f-7383-4bb3-91c3-e26437b3c5e6/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=dafe56737b5ec4cae5e963c3fddc3ee42537e4dea2f55a3a147a32afa9ca40d3&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/92ce658f-7383-4bb3-91c3-e26437b3c5e6/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=1b96c6d9f2c696eb9bca2ba7098736e6747d8e0ee7b0b314e8841e9a1ccbf576&X-Amz-SignedHeaders=host&x-id=GetObject) ### **Calculating R-squared Values** 7. Create an empty list to store R^2 values. 8. Create a list of different polynomial orders. @@ -161,30 +161,30 @@ plt.title('R^2 Value vs. Polynomial Order') plt.show() ``` Output: -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c53c7de-8745-4d43-89cc-fa5f491fbfe5/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=e2ac4d22db6026e83184e90f7bb6cca0bf758c7ba565ab7f897e0a3b279e8b9b&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c53c7de-8745-4d43-89cc-fa5f491fbfe5/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=09016048dae88b7f5f69f5badec38d3fd8eeddf02e9fe7d49dbde69fe3a69245&X-Amz-SignedHeaders=host&x-id=GetObject) This process helps in identifying the best polynomial order that minimizes the generalization error and avoids underfitting or overfitting. ___ ## **Introduction to Ridge Regression** For models with multiple independent features and ones with polynomial feature extrapolation, it is common to have colinear combinations of features. Left unchecked, this multicollinearity of features can lead the model to overfit the training data. To control this, the feature sets are typically regularized using hyperparameters. Ridge regression is the process of regularizing the feature set using the hyperparameter alpha Ridge regression can be utilized to regularize and reduce standard errors and avoid over-fitting while using a regression model. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c39a38d-2d49-4041-bd79-3aca0139bfb3/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=dab914c3c9b83bc35a8679724fb91be0dafe3629f93fe3e2f333f5ad3d0fcba6&X-Amz-SignedHeaders=host&x-id=GetObject) -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d6cfad56-e517-4b28-9645-3de06413a2b5/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=febd34a1bbcd20e9cf8dceef53d67c565e3a8babf20be52481dc3b643e5af3ff&X-Amz-SignedHeaders=host&x-id=GetObject) -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4e4309f5-805f-43a0-8547-9e8781fd1ca4/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=07fd8e217c07e376e07d012887dca524070e8b693e16d00320d0c7d3a7770896&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/0c39a38d-2d49-4041-bd79-3aca0139bfb3/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=9a52264e955876a69407c1cc39868ae363e4d95a63c049ea7b84c1ef8e2a4a3b&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/d6cfad56-e517-4b28-9645-3de06413a2b5/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=bf28cc472dab31c1ca53782ae82c2156f55934649fd2578733a71fce676a7a7f&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4e4309f5-805f-43a0-8547-9e8781fd1ca4/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=14548f0d634dfdcb58034c66b6d5392a341f834faa3bee62a6fa21782fc9ed61&X-Amz-SignedHeaders=host&x-id=GetObject) ### Ridge Regression **Overview**: Ridge regression is a technique used to prevent overfitting in polynomial regression by controlling the magnitude of polynomial coefficients. ### Key Concepts 10. **Overfitting**: - **Problem**: Higher-order polynomials can fit training data very well, but might overfit, especially in the presence of outliers or noisy data. - **Example**: A 10th-order polynomial fitting data with an outlier may produce large coefficients, which can misrepresent the true function. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/3781e151-64db-4738-9f89-94f9f9c0c096/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=c09070317967ee88785668872dbf3329f67d50900f4feab23b6c494c9f765b3c&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/3781e151-64db-4738-9f89-94f9f9c0c096/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=fb8d1dc7340a5c84cab1fc45bc34c03adc59360161d0f27175c9818821ff6440&X-Amz-SignedHeaders=host&x-id=GetObject) 11. **Ridge Regression**: - **Purpose**: Ridge regression addresses overfitting by introducing a parameter, Alpha ($ \alpha $), which penalizes large coefficients. - **Effect**: As Alpha increases, the magnitude of the coefficients decreases, which can prevent overfitting. - **Alpha Selection**: - **Too Small Alpha**: Might still overfit the data. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/af571e3b-ec69-47c8-b4ce-679c07c22950/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=e6afba08a9a2da1a61b5fbadb991724273e4468d1bfb4384d9998d97af25eaa3&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/af571e3b-ec69-47c8-b4ce-679c07c22950/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=2a477de970642c5b16415a3511fa259eaf1f449fdf46045fbef87e6981b52f53&X-Amz-SignedHeaders=host&x-id=GetObject) - **Too Large Alpha**: Can lead to underfitting as the model becomes too simple. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e39a5304-aac2-4d02-a4a2-dc0986a76649/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162016Z&X-Amz-Expires=3600&X-Amz-Signature=a7b9568aad9068381991773b19668186ba60043b98191b60289f79d4dd6e5571&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/e39a5304-aac2-4d02-a4a2-dc0986a76649/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171421Z&X-Amz-Expires=3600&X-Amz-Signature=4b087d4a9b3a98ce41a7974646ff7b1d904f473e195ccc7eb3f48cec8db89e8e&X-Amz-SignedHeaders=host&x-id=GetObject) 12. **Model Training**: - **Procedure**: Use cross-validation to select the optimal Alpha. Split the data into training and validation sets. - **Steps**: @@ -208,7 +208,7 @@ y_pred = ridge.predict(X_test) 14. **Cross-Validation**: - **Purpose**: Used to determine the best Alpha by comparing performance metrics (e.g., R^2) across different Alpha values. - **Process**: Train with various Alpha values, evaluate with validation data, and select the best-performing Alpha. -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4d3f8068-85d5-4c62-bc0e-0eaf7b277985/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=a3c3b5e8dc9f5af3b5a343a959c789eb7501ea2619d108bd21fc1cc59c944e71&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/4d3f8068-85d5-4c62-bc0e-0eaf7b277985/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171420Z&X-Amz-Expires=3600&X-Amz-Signature=8a037b5cc3d5e05b1e93e28a00ac6901ec6a43b311a52038b08e35fcca50ac54&X-Amz-SignedHeaders=host&x-id=GetObject) 15. **Example Visualization**: - **Plot**: Shows R^2 values vs. different Alpha values for training and validation data. - **Interpretation**: @@ -261,7 +261,7 @@ print("Best Estimator:", best_estimator) print("CV Results:", cv_results) ``` **Example Result:** -![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/93fb6806-f698-492b-93cc-a2658013d88d/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T162014Z&X-Amz-Expires=3600&X-Amz-Signature=c6c3f780088c091fd53efea36266b517c39192cc52f8bb30a4c1f80eaad68d3e&X-Amz-SignedHeaders=host&x-id=GetObject) +![Untitled.png](https://prod-files-secure.s3.us-west-2.amazonaws.com/03e82b26-cccb-4906-bb56-adabcbdc0655/93fb6806-f698-492b-93cc-a2658013d88d/Untitled.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45GO43JXI4%2F20241119%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241119T171419Z&X-Amz-Expires=3600&X-Amz-Signature=ad9caf20a44afca7279c6571fefbb625d1b7bbc9f17b3565d3a56ac2d7e4bd09&X-Amz-SignedHeaders=host&x-id=GetObject) - **Key Attributes**: - `**best_estimator_**`: Best model found. - `**cv_results_**`: Detailed results for each hyperparameter combination, including scores and parameters.