<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ahmed Farid on Medium]]></title>
        <description><![CDATA[Stories by Ahmed Farid on Medium]]></description>
        <link>https://medium.com/@ahmedfry34?source=rss-72c61a3d7a9d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*V4LTXXJrsQ0zDZ83kYkDFQ.jpeg</url>
            <title>Stories by Ahmed Farid on Medium</title>
            <link>https://medium.com/@ahmedfry34?source=rss-72c61a3d7a9d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 10:47:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahmedfry34/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hands-On with FastAPI: Creating a Simple To-Do List Application]]></title>
            <link>https://medium.com/@ahmedfry34/hands-on-with-fastapi-creating-a-simple-to-do-list-application-478159a6959e?source=rss-72c61a3d7a9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/478159a6959e</guid>
            <category><![CDATA[to-do-list-app]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[curd]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ahmed Farid]]></dc:creator>
            <pubDate>Mon, 08 Jul 2024 13:27:03 GMT</pubDate>
            <atom:updated>2024-07-08T13:27:03.202Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>First, let’s begin with a concise introduction to FastAPI.</strong></h3><p>FastAPI is a modern web framework for building APIs with Python. Created by Sebastián Ramírez, it has become popular because it is fast, easy to use, and packed with features.</p><p>FastAPI stands out for several reasons:</p><ul><li><strong>Speed</strong>: It’s one of the fastest Python frameworks available.</li><li><strong>Ease of Use</strong>: Writing code is straightforward and clear, thanks to Python’s type hints.</li><li><strong>Interactive Documentation</strong>: Automatically generates interactive API documentation with tools like Swagger UI and ReDoc.</li></ul><p>FastAPI is built on <strong>Starlette</strong> (<em>Starlette is a lightweight </em><a href="https://asgi.readthedocs.io/en/latest/"><em>ASGI</em></a><em> framework/toolkit, which is ideal for building async web services in Python.</em>) for the web parts and Pydantic for data validation, making it both fast and reliable.</p><p>In this article, we’ll examine why FastAPI is so popular, its key features, and how to start using it to build your own APIs. Whether you’re an experienced developer or new to API development, FastAPI makes it easy to create efficient and scalable web applications.</p><h3>Core Features and Benefits of FastAPI Compared to Flask and Django</h3><p>FastAPI, compared to Flask and Django, stands out with:</p><ul><li><strong>High Performance</strong>: FastAPI rivals Node.js and Go in speed, leveraging Starlette and Pydantic for efficient performance.</li><li><strong>Ease of Use and Development Speed</strong>: FastAPI’s simple syntax and automatic documentation (Swagger UI, ReDoc) accelerate development, reducing errors.</li><li><strong>Data Validation and Security</strong>: Integrated Pydantic ensures robust data validation, enhancing API reliability. FastAPI also simplifies security with built-in tools for authentication and authorization.</li><li><strong>Asynchronous Support and Scalability</strong>: First-class support for asynchronous programming enables concurrent request handling, crucial for scalability in high-demand applications.</li></ul><p>FastAPI excels in these areas, making it a compelling choice over Flask and Django for developers needing speed, scalability, and ease of development in Python-based API frameworks.</p><h3>Getting Started with FastAPI</h3><p>Getting started with FastAPI is straightforward and involves a few key steps:</p><ol><li><strong>Installation</strong>:</li></ol><ul><li>Install FastAPI using pip:</li></ul><pre>pip install fastapi</pre><p><strong>2- Run a Development Server</strong>:</p><ul><li>Use Uvicorn, a lightning-fast ASGI server, to run your FastAPI application:</li></ul><pre>uvicorn your_module_name:app --reload</pre><ul><li>Replace your_module_name with the Python file where your FastAPI app is defined.</li><li>The --reload option is used to enable auto-reloading, which means the server will restart automatically whenever changes are detected in your code, making development faster and more convenient.</li></ul><p><strong>3- Create Your First FastAPI Application</strong>:</p><ul><li>Define your FastAPI application in a Python file (e.g., main.py):</li></ul><pre>from fastapi import FastAPI<br><br>app = FastAPI()<br><br>@app.get(&quot;/&quot;)<br>def read_root():<br>    return {&quot;Hello&quot;: &quot;World&quot;}</pre><ul><li>In this example, @app.get(&quot;/&quot;) defines a route that responds to GET requests at the root URL (&quot;/&quot;).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*TReDtky9SVUT-NCfAndLcg.png" /></figure><p><strong>4- Explore Interactive API Documentation</strong>:</p><ul><li>FastAPI automatically generates interactive API documentation. Visit http://localhost:8000/docs in your browser to explore the Swagger UI.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M30v_smw8W34dzU7MqUqdw.png" /><figcaption>Interactive API documentation</figcaption></figure><ul><li>Alternatively, visit http://localhost:8000/redoc for the ReDoc documentation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BHgaQU0lBh2-d0VDTCVmXw.png" /></figure><p><strong>5- Expand Your Application</strong>:</p><ul><li>Build upon your basic application by adding more routes, handling query parameters, path parameters, request bodies, and integrating with databases or other services.</li></ul><h3><strong>Real-World Use Case: Simple To-Do List API</strong></h3><p>Creating a Simple To-Do List API is an excellent way to understand the core features and benefits of FastAPI. This API allows users to manage their tasks by performing basic operations like adding, viewing, updating, and deleting to-do items.</p><p><strong>1- Define Models:</strong></p><p>In FastAPI, defining models using Pydantic helps validate the data structure for API requests and responses. Here’s the code of how to define models for a Simple To-Do List API:</p><pre># Import necessary components from Pydantic and typing modules<br>from pydantic import BaseModel<br>from typing import List<br><br># Define a Pydantic model for a single TodoItem<br>class TodoItem(BaseModel):<br>    id: int  # Integer ID for the TodoItem<br>    title: str  # Title of the TodoItem, expected to be a string<br>    description: str  # Description of the TodoItem, expected to be a string<br>    completed: bool = False  # Boolean flag indicating whether the TodoItem is completed, default is False<br><br># Define another Pydantic model representing a TodoList<br>class TodoList(BaseModel):<br>    todos: List[TodoItem] = []  # List of TodoItem objects, initialized as empty by default</pre><p>Defining these models ensures that the data handled by the API is consistent and validated, which simplifies data management and error handling in your FastAPI application.</p><p><strong>Implement Routes:</strong></p><p>In FastAPI, routes define the endpoints of your API and specify how to handle incoming requests. Implementing routes is a crucial step in building your Simple To-Do List API.</p><pre>from fastapi import FastAPI, HTTPException<br>from typing import Optional<br><br># Create a FastAPI instance<br>app = FastAPI()<br># Temporary storage for To-Do items (in-memory list)<br>todos = []<br># Endpoint to retrieve all To-Do items<br>@app.get(&quot;/todos/&quot;, response_model=TodoList)<br>async def read_todos():<br>    return {&quot;todos&quot;: todos}<br><br># Endpoint to create a new To-Do item<br>@app.post(&quot;/todos/&quot;)<br>async def create_todo(title: str, description: str):<br>    # Generate a unique ID (in a real application, consider using a database or UUID)<br>    todo = {&quot;id&quot;: len(todos) + 1, &quot;title&quot;: title, &quot;description&quot;: description, &quot;completed&quot;: False}<br>    todos.append(todo)<br>    return todo<br><br># Endpoint to update a specific To-Do item<br>@app.put(&quot;/todos/{todo_id}/&quot;, response_model=TodoItem)<br>async def update_todo(todo_id: int, title: Optional[str] = None, description: Optional[str] = None):<br>    for todo in todos:<br>        if todo[&quot;id&quot;] == todo_id:<br>            todo[&quot;title&quot;] = title if title else todo[&quot;title&quot;]<br>            todo[&quot;description&quot;] = description if description else todo[&quot;description&quot;]<br>            return todo<br>    raise HTTPException(status_code=404, detail=&quot;Todo not found&quot;)<br><br># Endpoint to delete a specific To-Do item<br>@app.delete(&quot;/todos/{todo_id}/&quot;)<br>async def delete_todo(todo_id: int):<br>    for idx, todo in enumerate(todos):<br>        if todo[&quot;id&quot;] == todo_id:<br>            del todos[idx]<br>            return {&quot;message&quot;: &quot;Todo deleted&quot;}<br>    raise HTTPException(status_code=404, detail=&quot;Todo not found&quot;)</pre><h3>Explanation:</h3><ul><li><strong>GET Route</strong> (/todos/): Retrieves all to-do items and returns them in a list format.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWwBzZxD4f57caiagvdPFw.png" /><figcaption>Get the list</figcaption></figure><ul><li><strong>POST Route</strong> (/todos/): Creates a new to-do item with a unique ID, title, and description, and adds it to the list.</li></ul><blockquote>Note: To read, create, update, and delete a new to-do item, you can use various methods such as a <strong>Python script</strong>, <strong>Postman</strong>, or t<strong>he interactive API documentation</strong> provided by FastAPI.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eXUBoClJSkEColsaHbgMVg.png" /><figcaption>Use the interactive API documentation to create a new to-do item</figcaption></figure><ul><li><strong>PUT Route</strong> (/todos/{todo_id}/): Updates an existing to-do item identified by its ID. It allows partial updates (only title or description can be updated).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPYjc_Cpgd0UrhP-jkxpuQ.png" /><figcaption>Use the interactive API documentation to update to-do item</figcaption></figure><ul><li><strong>DELETE Route</strong> (/todos/{todo_id}/): Deletes a to-do item identified by its ID from the list.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y-lpiyreabFkM6vycHrmvw.png" /><figcaption>Use the interactive API documentation to delete to-do item</figcaption></figure><p>These routes allow the client to perform all CRUD operations (Create, Read, Update, Delete) on the to-do items, showcasing how FastAPI handles different types of HTTP requests and responses.</p><h3>Conclusion</h3><p>Building a Simple To-Do List API with FastAPI provides a practical introduction to its powerful features and benefits. By following the steps to define models, implement routes, and handle CRUD operations, you gain hands-on experience with FastAPI’s ease of use, performance, and automatic documentation capabilities.</p><p>Whether you’re a beginner or an experienced developer, FastAPI’s intuitive design and robust functionality make it an excellent choice for creating modern, high-performance web APIs. This exercise not only helps you understand the core concepts of FastAPI but also equips you with the skills to build more complex and scalable applications in the future.</p><p>By leveraging FastAPI, you can develop APIs quickly and efficiently, ensuring that your applications are both powerful and easy to maintain. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=478159a6959e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A/B Testing and Null Hypothesis Testing: Unveiling the Secrets of Data-Driven Decision-Making by…]]></title>
            <link>https://medium.com/@ahmedfry34/a-b-testing-and-null-hypothesis-testing-unveiling-the-secrets-of-data-driven-decision-making-by-cc6a89fe2d8a?source=rss-72c61a3d7a9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc6a89fe2d8a</guid>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[a-b-testing]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[marketing-analysis]]></category>
            <dc:creator><![CDATA[Ahmed Farid]]></dc:creator>
            <pubDate>Sun, 13 Aug 2023 06:28:27 GMT</pubDate>
            <atom:updated>2023-08-13T06:28:27.698Z</atom:updated>
            <content:encoded><![CDATA[<h3>A/B Testing and Null Hypothesis Testing: Unveiling the Secrets of Data-Driven Decision-Making by Story</h3><p>Let’s make this article like a story to explain everything!</p><p>Acme Inc. was a company that sold widgets. They had been in business for many years, but their sales had been declining in recent months. The company’s CEO, Mr. Smith was worried that they would go out of business if they didn’t do something to increase their sales.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*Jo-c25qByZ7C7C43wj0K8A.png" /></figure><p>One day, Mr. Smith met with Ahmed, a skilled Data Scientist. Ahmed told Mr. Smith that he could help Acme Inc. increase its sales by conducting A/B testing.</p><blockquote><strong>A/B testing</strong> is a method where you compare two versions (A and B) to see which one performs better, commonly used in web development, marketing, and product testing.</blockquote><p>Ahmed explained to Mr. Smith that he would create two versions of Acme Inc.’s website: version A and version B. Version A would have a red call to action button, and version B would have a blue call to action button.</p><p>Ahmed would then randomly assign half of Acme Inc.’s website visitors to see version A and half to see version B. After two weeks, Ahmed would compare the results of the two versions of the website to see which one had a higher conversion rate.</p><p>Mr. Smith was intrigued by Ahmed’s idea. He agreed to let Ahmed conduct the A/B test.</p><p>Ahmed worked hard to create two versions of Acme Inc.’s website. He made sure that both versions of the website were identical, except for the color of the call to action button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*-jDYqHEh_6KRCKUH4ns-GQ.png" /></figure><p>Ahmed then launched the A/B test. He waited a week and then compared the results of the two versions of the website. He found that version B, with the blue call to action button, had a conversion rate of 10%, while version A, with the red call to action button, had a conversion rate of 8%. This meant that 2% more people who saw version B of the website actually bought a widget.</p><p>Ahmed presented the results of the A/B test to Mr. Smith. Mr. Smith was pleased with the results. He decided to change Acme Inc.’s website to version B with the blue call to action button.</p><p>After making the change, Acme Inc. saw a significant increase in sales. They were so happy with the results that they hired Ahmed to continue conducting A/B tests on their website.</p><p>The moral of the story is that A/B testing can be a powerful tool for businesses that want to improve their conversion rates and increase their sales. By testing different ideas, businesses can learn what works best for their audience and make better marketing decisions.</p><p>In this story, Ahmed used <strong>null hypothesis testing</strong> to interpret the results of the A/B test.</p><blockquote><strong>Null hypothesis testing</strong> helps you assess whether the observed difference in A/B testing results is statistically significant or just due to random chance. The null hypothesis often represents the absence of an effect or no difference between groups.</blockquote><p>In this case, Ahmed’s null hypothesis was that there was no difference in conversion rates between version A and version B of the website. His alternative hypothesis was that version B had a higher conversion rate than version A.</p><p>Ahmed used a statistical test called a <strong>t-test</strong> to compare the conversion rates of the two versions of the website. The t-test showed that the p-value for the difference in conversion rates between version A and version B was 0.02. This means that there was a 2% chance that the difference in conversion rates between version A and version B could have occurred by chance.</p><p>Since the p-value was less than 0.05, Ahmed could reject his null hypothesis and conclude that version B had a higher conversion rate than version A.</p><p>Ahmed’s use of null hypothesis testing helped him to make a confident decision about which version of the website was more effective. This decision helped Acme Inc. to increase their sales and improve their bottom line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QGq00eSxK7aoi1ZCkLb6Lg.png" /><figcaption>In a normal distribution, the significance level corresponds to regions in the tails of the curve. In a one-tailed test, the entire significance level is allocated to one tail of the distribution. For example, if you are using a significance level of 0.05 (5%), you would reject the null hypothesis if your data point falls in the 5% tail on either the right (for a right-tailed test) or the left (for a left-tailed test) end of the distribution. In this example, the observed value is statistically significant (p ≤ 0.05), so the null hypothesis (H0) is rejected, and the alternative hypothesis (Ha) is accepted.</figcaption></figure><p>There are a few different ways to calculate the <strong>t-test</strong>. One way is to use the following formula:</p><pre>t = (mean_A - mean_B) / (standard_error)</pre><p>where:</p><ul><li><em>mean_A is the mean of the first group</em></li><li><em>mean_B is the mean of the second group</em></li><li><em>standard_error is the standard error of the difference in means</em></li></ul><p>The <strong>standard error</strong> of the difference in means can be calculated using the following formula:</p><pre>standard_error = sqrt((standard_deviation_A^2) / n_A + (standard_deviation_B^2) / n_B)</pre><p>where:</p><ul><li><em>standard_deviation_A is the standard deviation of the first group</em></li><li><em>standard_deviation_B is the standard deviation of the second group</em></li><li><em>n_A is the number of observations in the first group</em></li><li><em>n_B is the number of observations in the second group</em></li></ul><p>Once you have calculated the t-value, you can look up the p-value in a t-table. The p-value is the probability of obtaining a t-value at least as extreme as the one you calculated, assuming that the null hypothesis is true.</p><blockquote><strong>In conclusion</strong>, I can say that A/B testing is an experimental design, and hypothesis testing is a statistical technique, the value of them in the data science workflow emphasizes their role in making informed decisions based on evidence rather than intuition.</blockquote><p><strong>Thank you for reading my article! I hope you found it informative.</strong></p><p><em>If you are interested in Data Science, Let’s connect on </em><a href="https://www.linkedin.com/in/ahmedfarid26/">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc6a89fe2d8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>