<?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 Farhan Rahman on Medium]]></title>
        <description><![CDATA[Stories by Farhan Rahman on Medium]]></description>
        <link>https://medium.com/@farhanrahman02?source=rss-5b9f97bd2f58------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3bi5gWERPY909T1aiQ_S_Q.jpeg</url>
            <title>Stories by Farhan Rahman on Medium</title>
            <link>https://medium.com/@farhanrahman02?source=rss-5b9f97bd2f58------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:27:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@farhanrahman02/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[AI Agents That Edit Your Blogs and Ping Your Team: LangGraph + Slack in Action]]></title>
            <link>https://medium.com/swlh/ai-agents-that-edit-your-blogs-and-ping-your-team-langgraph-slack-in-action-930725910dba?source=rss-5b9f97bd2f58------2</link>
            <guid isPermaLink="false">https://medium.com/p/930725910dba</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[langgraph]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[slack]]></category>
            <dc:creator><![CDATA[Farhan Rahman]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 10:33:21 GMT</pubDate>
            <atom:updated>2025-06-28T10:33:21.965Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a step by step guide on how to create an agent (without MCP) to build a LLM powered content refining workflow using LangGraph, Ollama and Slack. Before we dive into the implementation of this automated workflow, it is important to understand the choice of the tools and stack used. LangGraph is a framework used for builing agents and orchestrating agents. Thanks to Ollama for serving open source LLMs. Having said that, this is a very simple application of agentic workflow suitable for anyone who wants to learn how to use langgraph for automating certain workflows.</p><h3>📌 Overview</h3><p>In this post, I’ll walk you through how I built a <strong>LangGraph-based AI agent</strong> that:</p><ul><li>📝 Retrieves an existing Medium article</li><li>🤖 Uses a Large Language Model (LLM) to rewrite and improve the blog</li><li>🔁 Iteratively reflects and refines the content</li><li>📤 Automatically sends the final version to a Slack channel</li></ul><p>This is a practical application of <strong>agentic AI workflows</strong>, showcasing how tools like <strong>LangChain</strong>, <strong>LangGraph</strong>, and <strong>Slack integration</strong> can work together to automate content workflows.</p><h3>🏗️ Tech Stack</h3><ul><li><strong>LangGraph</strong>: for graph-based agent orchestration</li><li><strong>LangChain</strong>: for prompt chaining and LLM abstraction</li><li><strong>Ollama + Mistral</strong>: as the local LLM provider</li><li><strong>Slack API</strong>: to send final blog content to a channel</li><li><strong>Python + dotenv + BeautifulSoup</strong>: for scripting and parsing Medium content</li></ul><h3>🚀 What the Agent Does</h3><p>Here’s the lifecycle of the agent:</p><ol><li><strong>Scrape</strong> a published Medium article using requests + BeautifulSoup</li><li><strong>Seed the graph</strong> with the original blog as a HumanMessage</li><li><strong>Generate</strong> an improved version using a structured blog prompt</li><li><strong>Reflect</strong> on that improvement and provide human-like feedback</li><li><strong>Loop</strong> until the content is polished</li><li><strong>Send</strong> the refined version to a Slack channel for publishing or review</li></ol><h3>✍️ Prompts that Power the Agent</h3><h3>🛠 Generate Prompt</h3><pre>You are a professional blog writer. Rewrite the blog post to follow this structure:<br><br>- Title<br>- Introduction<br>- Main Content<br>- Conclusion<br>- Optional Call-to-Action<br><br>Improve clarity, flow, grammar, and engagement.<br><br>BLOG DRAFT:<br>{messages}</pre><h3>🔍 Reflect Prompt</h3><pre>Review the improved blog post and suggest a refinement or better phrasing if needed.<br><br>BLOG POST:<br>{messages}</pre><h3>🧪 Sample Output</h3><p>Here’s a real example of what the agent produces:</p><blockquote><strong><em>Title</em></strong><em>: Streamlining API Integration with LLMs: A Guide to Generating OpenAPI Specifications</em></blockquote><blockquote><strong><em>Main Content</em></strong><em>: Uses a Jinja template to prompt GPT-4 to output swagger files, turning any undocumented API into a usable dev reference.</em></blockquote><blockquote><strong><em>Call-to-Action</em></strong><em>: Encourages developers to follow the blog for more LLM + MLOps workflows.</em></blockquote><h3>📤 Slack Integration</h3><p>Once the final content is ready, it’s posted to a Slack channel via:</p><pre>from langchain_community.tools.slack.send_message import SlackSendMessage<br><br>slack_tool = SlackSendMessage(slack_token=os.getenv(&quot;SLACK_BOT_TOKEN&quot;))<br>slack_tool.invoke({<br>    &quot;message&quot;: final_message,<br>    &quot;channel&quot;: &quot;#ai-notifications-medium&quot;<br>})</pre><p>This turns the agent into a hands-free <strong>content assistant</strong> for teams.</p><p>Now let’s take a look into the step-by-step implementation of the repository here: <a href="https://github.com/frh02/ai-agent-repo">https://github.com/frh02/ai-agent-repo</a></p><h3>Repo Steps:</h3><h4>📦 Installation &amp; Setup</h4><h4>1. Clone the Repository</h4><pre>git clone https://github.com/frh02/ai-agent-repo.git<br>git checkout slack-message-bot<br>cd slack-agent</pre><h4>2. Install Dependencies with Poetry</h4><p>Ensure Poetry is installed:</p><pre>curl -sSL https://install.python-poetry.org | python3</pre><p>Install packages:</p><pre>poetry install</pre><p>Activate the environment</p><pre>poetry shell</pre><h4>3. Run Ollama Locally</h4><p>Install Ollama from <a href="https://ollama.com/">https://ollama.com</a></p><p>Pull a model (e.g. Mistral):</p><pre>ollama pull mistral</pre><p>Start the Ollama server (required for the agent to talk to the LLM):</p><pre>ollama serve</pre><h4>4. Create Your .env File</h4><pre># .env<br>SLACK_BOT_TOKEN=xoxb-your</pre><blockquote><em>⚠️ Never commit this file — it’s listed in </em><em>.gitignore.</em></blockquote><h4>5. Run the Agent</h4><pre>python main.py</pre><p>You should see:</p><ul><li>The scraped Medium article printed</li><li>The refined version generated by the LLM</li><li>A confirmation that the message was sent to your Slack channel</li></ul><h4>💡 How It Works</h4><h4>Agent Flow</h4><ol><li><strong>read_story_node</strong>: Scrapes an existing Medium blog post</li><li><strong>generate_node</strong>: Uses an LLM to rewrite the post in Medium style</li><li><strong>reflect_node</strong>: Reviews and improves the post again</li><li><strong>slack_node</strong>: Sends the final version to a Slack channel</li><li><strong>should_continue</strong>: Controls how many loops happen before Slack posting</li></ol><h3>💬 Slack Integration</h3><p>To connect Slack (for more information, head over to appendix):</p><ol><li>Go to Slack App Management</li><li>Create a new app with:</li></ol><ul><li>chat:write scope</li><li>A bot token (xoxb-...)</li></ul><p>3. Add the bot to the target channel (e.g., #ai-notifications-medium)</p><p>4. Paste your token into .env as shown above</p><h3>🧠 Lessons Learned</h3><ul><li>LangGraph makes it easy to express <strong>iterative AI workflows</strong> with clear conditional logic.</li><li>LLMs can be used not just for generation, but also <strong>reflection and self-improvement</strong>.</li><li>Slack bots are a great endpoint for broadcasting AI outputs.</li></ul><h3>🛠️ What’s Next?</h3><ul><li>✅ Add support for multiple blog sources</li><li>🧾 Let the agent create a blog outline before writing</li><li>🔗 Auto-publish to Medium (when their API returns 😅)</li><li>🔁 Add human-in-the-loop approval via Slack buttons</li></ul><h3>📎 Final Thoughts</h3><p>This agent is a small but powerful example of how GenAI can <strong>augment human workflows</strong> — not replace them. From writing to reviewing to publishing, LLMs can take the repetitive friction out of your creative process.</p><p>If you’re building with LangGraph or GenAI tools — I’d love to connect!</p><h4>📎 Appendix: Slack Bot Integration Guide</h4><p>This appendix provides everything you need to know to build, configure, and securely run a Slack bot for your LangGraph agent.</p><h4>🤖 What Is a Slack Bot?</h4><p>A <strong>Slack bot </strong>is a program that connects to Slack via the [Slack API](<a href="https://api.slack.com/">https://api.slack.com/</a>) and can:</p><p>- Send and receive messages<br>- Automate workflows<br>- Post notifications to channels<br>- Interact with users in real time</p><h4>🛠 How to Create a Slack Bot</h4><p><strong>1. Create the App</strong></p><p>- Visit: <a href="https://api.slack.com/apps">https://api.slack.com/apps</a><br>- Click <strong>Create New App → From Scratch</strong><br>- Give your app a name (e.g., <strong>medium-agent-bot</strong>)<br>- Select your Slack workspace</p><p><strong>2. Add Bot Token Scopes</strong></p><p>In the <strong>OAuth &amp; Permissions </strong>section:</p><p>Add this scope:<br>- `chat:write` — to send messages to channels</p><p>Optional scopes:<br>- `channels:read`, `groups:read`, `im:write`, `users:read`</p><p><strong>3. Install the App to Your Workspace</strong></p><ul><li>Go to the <strong>Install App </strong>tab<br>- Click <strong>Install to Workspace</strong><br>- After installation, Slack will provide a <strong>Bot User OAuth Token l</strong>ike:</li></ul><pre>xoxb-1234567890-1234567890123-abc123…</pre><p><strong>4. 🔐 Store the Token Securely</strong></p><p>Create a `.env` file in your project:env</p><pre>SLACK_BOT_TOKEN=xoxb-your-token-here</pre><p><strong>5. </strong>📥 <strong>Invite Bot to Your Slack Channel</strong></p><p>In Slack, run:</p><pre>/invite @your-bot-name</pre><p>Then post to a channel like #ai-notifications-medium.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=930725910dba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/ai-agents-that-edit-your-blogs-and-ping-your-team-langgraph-slack-in-action-930725910dba">AI Agents That Edit Your Blogs and Ping Your Team: LangGraph + Slack in Action</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developers documentation to OpenAPI specification]]></title>
            <link>https://medium.com/swlh/developers-documentation-to-openapi-specification-d73a0c19e86c?source=rss-5b9f97bd2f58------2</link>
            <guid isPermaLink="false">https://medium.com/p/d73a0c19e86c</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[open-api]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[gpt-4]]></category>
            <dc:creator><![CDATA[Farhan Rahman]]></dc:creator>
            <pubDate>Thu, 08 Feb 2024 07:55:19 GMT</pubDate>
            <atom:updated>2024-02-08T07:55:19.294Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xXkgbhe_4_ZL74Sy" /><figcaption>Photo by <a href="https://unsplash.com/@davfts?utm_source=medium&amp;utm_medium=referral">David Pupăză</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Having trouble integrating APIs into your own platform ? Well, now we have LLMs to our rescue. Working with developers documentation can become tiresome but now you can generate OpenAPI specifications for any platform. For those who don’t know what an OpenAPI specification is, imagine it being a roadmap to an API developer documentation. These spec file (sometimes called swagger file) makes a developers job a lot easier. There is always this downside of these swagger files not being available as open source. If that’s the case you have a road block but not anymore. With the help of LLMs and some smart software development we can now generate these specification files for any SaaS platform.</p><h3>Choosing the right prompt</h3><p>Leveraging the true power of LLMs we need to use efficient prompt engineering. Working with these large language, I have observed that giving the prompt as a template generally tends to work wonderfully.</p><p>Below is a Jinja template I used for prompting:</p><pre>Goal: You are an OpenAPI specification generator. You will be given contents of a developers documentation.<br>We are writing the swagger file only for a particular resource {{ resource_name }}.<br><br>Extract only the relevant information needed from this document content here <br>```json<br>{{ document }} <br>```<br>to generate the OpenAPI specification whose format is here<br>```ts<br>{% include &#39;openapi_spec.ts&#39; %}<br>```<br>Return the output in json format. </pre><h3>Using format for OpenAPI spec file</h3><p>Swagger files are all about correct format and using a typescript for getting the desired output proved to be really helpful.</p><pre>type KeyValue = {<br>    key: string;<br>    value: string;<br>  };<br>  <br>  type JsonPathString = string;<br>  <br>  interface OpenAPIInfo {<br>    description: string;<br>    title: string;<br>    version: string;<br>  }<br>  <br>  interface OpenAPIServer {<br>    url: string;<br>  }<br>  <br>  interface OpenAPIParameter {<br>    description: string;<br>    in: string;<br>    name: string;<br>    required: boolean;<br>    schema: {<br>      type: string;<br>    };<br>  }<br>  <br>  interface OpenAPIResponse {<br>    description: string;<br>  }<br>  <br>  interface OpenAPIOperation {<br>    tags: string[];<br>    summary: string;<br>    description: string;<br>    operationId: string;<br>    parameters: OpenAPIParameter[];<br>    responses: {<br>      [key: string]: OpenAPIResponse;<br>    };<br>  }<br>  <br>  interface OpenAPIPath {<br>    [key: string]: {<br>      [key: string]: OpenAPIOperation;<br>    };<br>  }<br>  <br>  interface OpenAPISpecification {<br>    openapi: string;<br>    info: OpenAPIInfo;<br>    servers: OpenAPIServer[];<br>    paths: OpenAPIPath;<br>  }</pre><h3>Selecting the Model</h3><p>Generally, GPT-4 works surprisingly well with both code generation and documents of different format. Here is an example of a code for calling OpenAI’s GPT-4. You would have to include some parts for pre-processing and using the jinja template as a prompt.</p><pre>def get_completion_with_template(<br>    template_name: str,<br>    context: dict,<br>    dry_run: bool = False,<br>    progress=None,<br>    json_mode=False,<br>    model=None,<br>) -&gt; Tuple[str, Optional[str]]:<br>    prompt = render_prompt(template_name, context)<br><br>    if dry_run:<br>        return prompt, None<br><br>    completion = get_simple_completion(<br>        prompt,<br>        progress=progress,<br>        json_mode=json_mode,<br>        model=model,<br>        template_name=template_name,<br>    )<br><br>    return prompt, completion</pre><p>Well if all dots are connected properly you will see this output from the LLM.</p><pre>{<br>    &quot;openapi&quot;: &quot;3.0.1&quot;,<br>    &quot;info&quot;: {<br>      &quot;description&quot;: &quot;Miro API&quot;,<br>      &quot;title&quot;: &quot;Miro API&quot;,<br>      &quot;version&quot;: &quot;0.1&quot;<br>    },<br>    &quot;servers&quot;: [<br>      {<br>        &quot;url&quot;: &quot;https://api.miro.com/&quot;<br>      }<br>    ],<br>    &quot;paths&quot;: {<br>      &quot;/v1/oauth/revoke&quot;: {<br>        &quot;post&quot;: {<br>          &quot;tags&quot;: [&quot;tokens&quot;],<br>          &quot;summary&quot;: &quot;Revoke token&quot;,<br>          &quot;description&quot;: &quot;Revoke the current access token. Revoking an access token means that the access token will no longer work. When an access token is revoked, the refresh token is also revoked and no longer valid. This does not uninstall the application for the user.&quot;,<br>          &quot;operationId&quot;: &quot;revoke-token&quot;,<br>          &quot;parameters&quot;: [<br>            {<br>              &quot;description&quot;: &quot;Access token that you want to revoke&quot;,<br>              &quot;in&quot;: &quot;query&quot;,<br>              &quot;name&quot;: &quot;access_token&quot;,<br>              &quot;required&quot;: true,<br>              &quot;schema&quot;: {<br>                &quot;type&quot;: &quot;string&quot;<br>              }<br>            }<br>          ],<br>          &quot;responses&quot;: {<br>            &quot;204&quot;: {<br>              &quot;description&quot;: &quot;Token revoked&quot;<br>            },<br>            &quot;400&quot;: {<br>              &quot;description&quot;: &quot;Failed to revoke token&quot;<br>            }<br>          }<br>        }<br>      }<br>    }<br>  }<br>}</pre><p><strong><em>References:</em></strong></p><ul><li><a href="https://swagger.io/specification/">https://swagger.io/specification/</a></li><li><a href="https://openai.com/gpt-4">https://openai.com/gpt-4</a></li><li><a href="https://www.typescriptlang.org/">https://www.typescriptlang.org</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d73a0c19e86c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/developers-documentation-to-openapi-specification-d73a0c19e86c">Developers documentation to OpenAPI specification</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring your CUDA drivers for custom object detection(Linux)]]></title>
            <link>https://medium.com/data-science-collective/configuring-your-cuda-drivers-for-custom-object-detection-linux-5746efdb9cb0?source=rss-5b9f97bd2f58------2</link>
            <guid isPermaLink="false">https://medium.com/p/5746efdb9cb0</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Farhan Rahman]]></dc:creator>
            <pubDate>Wed, 07 Feb 2024 04:00:23 GMT</pubDate>
            <atom:updated>2026-06-09T18:48:33.995Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IFD3upF07RkuKTCf" /><figcaption>Photo by <a href="https://unsplash.com/@vitalysacred?utm_source=medium&amp;utm_medium=referral">Vitaly Sacred</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>With the introduction of Convolutional Neural Network, the field of computer vision has seen some great progress. Object detection is now considered a central task in machine vision. The application of object detection in today’s world is unprecedented, from self driving vehicles to person identification in our smart phones use object detection at it’s core. Having said that there has been a substantial progress. Methods like few-shot object, single shot object detection have made this task fairly simple to implement with straight forward priciples for detection. We can further say that object detection is a combination of object classification and object localisation. There are pretrained models which detect objects in our day to day lives but what if you want a model to do predictions on our own collection of dataset ? This article will you to build your model for detecting your toys you had as a kid. Let’s dive in!!</p><h3>Overview:</h3><p>We use the <a href="https://github.com/tensorflow/models/tree/master/research/object_detection">tensorflow object detection</a> API for implementing our object detection on custom data. Although the instruction given in the official tutorial on tensorflow is quite adequate but it might be tricky at times. This article gives you an overview on how I implemented the API for my own dataset. It is very important to set up your environment for implementation. It is advised to using conda to create the virtual environment but using pip also meets the purpose. Use the following command to setup the envrionment.</p><pre>conda create -n myenv pip python=3.9</pre><p>Activate the virtual environment using the following command:</p><pre>conda activate myenv</pre><p>Before installing tensorflow, please make sure that you have compatible version with python, cuDNN and CUDA. It is essential to have the correct versions installed so that tensorflow can do computations on your GPU. If you do not have a GPU, then you can proceed without considering the cuDNN and CUDA version. Personally, I found the following configuration highlighted in red working best. You can find the compatibility table <a href="https://www.tensorflow.org/install/source#gpu">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkSlwbFd7IT184_8VtPSqw.png" /></figure><p><strong>Installing cuDNN and CUDA:</strong></p><p>Please follow this step very carefully to get GPU acceleration while implementing the object detection pipeline. First make sure you have the proper NVIDIA driver installed by using this in a terminal.</p><pre>sudo ubuntu-drivers devices</pre><p>This will show a list of suitable drivers, I used nvidia-driver-515 but you can install any version using the following command:</p><pre>sudo apt install nvidia-driver-[version number]</pre><p>To verify your installation, use this command:</p><blockquote>nvidia-smi</blockquote><p>This will bring show that you have the version of driver installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qlwhc0pzJFKCsQTcaQpbqQ.png" /></figure><h4>Go to <a href="https://developer.nvidia.com/cuda-downloads">https://developer.nvidia.com/cuda-downloads</a> to download latest CUDA Toolkit.</h4><p>But for our purpose we need the older version of the CUDA Toolkit from <a href="https://developer.nvidia.com/cuda-toolkit-archive">Archived Releases.</a> Install the following version highlighted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1JjhJ7G3S7EItKAHJcQm4w.png" /></figure><p>Use the following configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3H_tg5tKalLrCR9zUXXUpw.png" /></figure><p>And follow the steps as given.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nb7J7frgZEm2QnwFFXXCww.png" /></figure><p>Please note that in the last step , use the following command:</p><p>$ sudo apt-get -y install cuda-11.2</p><p>For the next step open the bash file using:</p><pre>nano ~/.bashrc</pre><p>Once you open your bashrc use the following command to configure your drivers. Use these:</p><pre># NVIDIA CUDA TOOLKIT<br>export PATH=/usr/local/cuda-11.0/bin${PATH:+:${PATH}}<br>export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}</pre><p>Update your current shell environment using:</p><pre>source ~/.bashrc</pre><h4>Go to <a href="https://developer.nvidia.com/cudnn">https://developer.nvidia.com/cudnn</a> and download CUDNN.</h4><p>Remember since I have CUDA-11.2 so I will use cudnn-8.0.5 but you can also follow these steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjk_ekhT6nhnvyiAwZxCRQ.png" /></figure><p><strong>Note:</strong></p><pre>sudo apt-get install cudnn-cuda-11.2</pre><p>But <strong><em>just incase</em></strong> you don’t follow the steps and download the tar file instead then use this command to unzip it.</p><pre>tar -zxf cudnn-11.0-linux-x64-v8.0.5.39.tgz</pre><p><strong>Note: Copy the unzipped file into the actual cuda folder</strong></p><p>Next up, we need the contents of the cuda-lib64and include to be inside the lib64 . Use these commands:</p><pre>cd cuda<br>sudo cp -P lib64/* /usr/local/cuda/lib64/<br>sudo cp -P include/* /usr/local/cuda/include/</pre><p>Voila! You are all set now 🎖️.</p><p><strong>References:</strong></p><p><a href="https://developer.nvidia.com/cudnn">https://developer.nvidia.com/cudnn</a></p><p><a href="https://github.com/tensorflow/models/tree/master/research/object_detection">models/research/object_detection at master · tensorflow/models</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5746efdb9cb0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-collective/configuring-your-cuda-drivers-for-custom-object-detection-linux-5746efdb9cb0">Configuring your CUDA drivers for custom object detection(Linux)</a> was originally published in <a href="https://medium.com/data-science-collective">Data Science Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Beyond Perception]]></title>
            <link>https://medium.com/analytics-vidhya/data-beyond-perception-c1ceef95b231?source=rss-5b9f97bd2f58------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1ceef95b231</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Farhan Rahman]]></dc:creator>
            <pubDate>Fri, 26 Jun 2020 14:18:41 GMT</pubDate>
            <atom:updated>2020-06-30T14:02:55.066Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_QSmUlvyWaPNNaw50jIeWQ.jpeg" /><figcaption>Image by statistics authority of UK</figcaption></figure><p>The quote “Data is everywhere” can’t be more true.We tend to see only what is presented to us, but we often overlook what information might be hidden inside each data.This article provides information about how we can find links and correlation between various features of a given data. Sometimes very important information which is vital for our analysis is hidden as a combination of individual features. Let’s jump in to the task at hand and find out the power of statistics and python.</p><h3>Explore the Data</h3><p>To illustrate my point, I have used the advertising data from the textbook “An Introduction to Statistical Learning with Applications in R” (Gareth James, Daniela Witten, Trevor Hastie, Robert Tibshirani). The data can be found using the author’s website or the link: <a href="http://faculty.marshall.usc.edu/gareth-james/ISL/data.html">http://faculty.marshall.usc.edu/gareth-james/ISL/data.html</a></p><pre>url = &#39;http://faculty.marshall.usc.edu/gareth-james/ISL/Advertising.csv&#39;<br>ds = pd.read_csv(url,index_col=0)</pre><p>Now to visualize the relation between the different features of our data set we can use pair plot() which gives us the scatter plot between two features and the histogram.</p><pre>sns.pairplot(ds);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*DL2_jkj0PuN3vRFDT-Ao9g.png" /><figcaption>Pair wise plot for different features</figcaption></figure><p>Isn’t python amazing? Seaborn is an amazing data visualization library and you can use its various functions to utilize it to its full content.</p><h3>Understand the data:</h3><p>The pair wise plot above can be overwhelming if you are new to this but it is just a plot of two features taken one at time, hence the name pair plot. In our data the plot towards the bottom right is a scatter plot of sales against the budget of advertising for television. Now to quickly get a glimpse of how our data is related,you can use the following commands:</p><pre>g = sns.pairplot(ds, kind=&quot;reg&quot;)</pre><p>This will plot a linear regression line fitting all the pair wise plots.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*WtCcNkN7kSoQcjU94ZXunQ.png" /><figcaption>Linear Regression fit to data</figcaption></figure><p>Another great function of seaborn library is that it tells us about the correlation of different data with each other, using just a line:</p><pre>corr = ds.corr()<br>sns.heatmap(corr)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*WAt-ISBkwqK6q9P506m8Xw.png" /><figcaption>Heat map showing correlation</figcaption></figure><p>The heat map gives us the extent to which these features are correlated with each other and especially focusing on the last row which is the relation between the sales and the advertising budget.It is quite clear that the sales of TV is positively correlated to the budget of advertising while the correlation between radio and sales is decreasing and it decreases even further for the the sales of newspaper and the budget of advertising.</p><h3>Fitting the Linear Regression Model:</h3><p>Now to get into the Machine Learning part we have to fit regression model.We have to split the model into 70:30 train test data points. Then use different linear regression models to fit the data for different features.</p><pre>train, test = train_test_split(ds, test_size=0.3)<br>reg_tv = LinearRegression().fit(train[[&#39;TV&#39;]], train[&#39;sales&#39;])<br>reg_radio = LinearRegression().fit(train[[&#39;radio&#39;]], train[&#39;sales&#39;])<br>reg_news = LinearRegression().fit(train[[&#39;newspaper&#39;]], train[&#39;sales&#39;])<br>y_pred_tv = reg_tv.predict(test[[&#39;TV&#39;]])<br>y_pred_radio = reg_radio.predict(test[[&#39;radio&#39;]])<br>y_pred_news = reg_news.predict(test[[&#39;newspaper&#39;]])</pre><p>We can observe how the linear regression model fits our training and test set using the following plots. The red blue points are the scatter plot for the training set while the green colored points are for the test data set .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*ANU4bz70IFpP0Xi3bbFPSA.png" /><figcaption>Linear model for different features</figcaption></figure><p>By observing the above plots,anyone can say that the linear models are not good enough. We can definitely use other models belonging to different class to see how it fits our data but we often root to higher level models without exploring what the data has to offer. Even from this linear model we can roughly say that it fits the Sales against TV budget best. This can mean that on increasing the budget for advertising in TV entertainment we can increase the sales of that feature.</p><h3>The Hidden Pieces:</h3><p>There can be various combination of features which might give us a huge amount of information about how they are interconnected.For this purpose I have used combination like multiplying the budget of TV and radio , radio and newspaper , newspaper and TV and the combination of all three.You can do this using :</p><pre>ds[&#39;news_radio&#39;] = ds[&#39;newspaper&#39;]*ds[&#39;radio&#39;]<br>ds[&#39;tv_radio&#39;] = ds[&#39;TV&#39;]*ds[&#39;radio&#39;]<br>ds[&#39;news_tv&#39;] = ds[&#39;newspaper&#39;]*ds[&#39;TV&#39;]<br>ds[&#39;news_radio_tv&#39;] = ds[&#39;newspaper&#39;]*ds[&#39;radio&#39;]*ds[&#39;TV&#39;]<br>ds</pre><p>The above code will create new columns in your already existing data frame.All you have to now is to fit the linear model for the new set of features.</p><pre>train, test = train_test_split(ds, test_size=0.3)<br>reg_news_radio = LinearRegression().fit(train[[&#39;news_radio&#39;]], train[&#39;sales&#39;])<br>reg_tv_radio = LinearRegression().fit(train[[&#39;tv_radio&#39;]], train[&#39;sales&#39;])<br>reg_news_tv = LinearRegression().fit(train[[&#39;news_tv&#39;]], train[&#39;sales&#39;])<br>reg_news_radio_tv = LinearRegression().fit(train[[&#39;news_radio_tv&#39;]], train[&#39;sales&#39;])<br>y_pred_news_radio = reg_news_radio.predict(test[[&#39;news_radio&#39;]])<br>y_pred_tv_radio = reg_tv_radio.predict(test[[&#39;tv_radio&#39;]])<br>y_pred_news_tv = reg_news_tv.predict(test[[&#39;news_tv&#39;]])<br>y_pred_news_radio_tv = reg_news_radio_tv.predict(test[[&#39;news_radio_tv&#39;]])</pre><h3>Visualize the data:</h3><p>I used subplot function to generate different plots and for the sake of comparing between the individual features like the budget of TV, Radio and newspaper and the synthesized features I included the individual plots as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*PbzmSSjRyLCj4rbfCqJLAw.png" /><figcaption>Linear model on training data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*eINPWVdk0kdJgj1hwUopXg.png" /><figcaption>Linear regression fit on test data</figcaption></figure><p>It is quite evident that the combination of feature like TV and radio together and the combination of news, radio and TV follows a linear trend. Which means the the company might increase the sales if they spend more on advertising of TV and radio rather than increasing the budget for newspaper.</p><p>So it is not always necessary that the data available to you will best describe a model ,sometimes the information is hidden and we can make amends to our data to find a correlation between various parameters of a data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1ceef95b231" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/data-beyond-perception-c1ceef95b231">Data Beyond Perception</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Ontario’s mobility is shaping up since reopening]]></title>
            <link>https://medium.com/swlh/how-ontarios-mobility-is-shaping-up-since-reopening-3b9625b55a13?source=rss-5b9f97bd2f58------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b9625b55a13</guid>
            <category><![CDATA[ontario]]></category>
            <category><![CDATA[google-colab]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[google-communi]]></category>
            <category><![CDATA[covid-19-crisis]]></category>
            <dc:creator><![CDATA[Farhan Rahman]]></dc:creator>
            <pubDate>Fri, 19 Jun 2020 16:24:57 GMT</pubDate>
            <atom:updated>2020-06-30T11:26:08.700Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KfYKBdcuYdK33RwYRxhf9A.png" /><figcaption>screenshot from dlpng.com</figcaption></figure><p>As we all are taken aback by this pandemic, global communities have come together and there has been emphasis on public health strategies, like social distancing measures, to slow the rate of transmission.One such initiative was taken by Google where they use aggregated, anonymized data which shows how busy certain types of places are — helping identify when a local business tends to be the most crowded.</p><p>This article highlights the trend in the influx and out flux of people in certain places. The local government of Ontario announced a phase based reopening system, and the data collected is specific to the activities since phase 1 reopening of public places in Ontario.The findings below helps us to get a general view about the community mobility in relation to the COVID-19 crisis.</p><h3><strong>How to get access to the data:</strong></h3><p>Google has made the data open to public and can be accessed using the link below:</p><p><a href="https://www.google.com/covid19/mobility/">COVID-19 Community Mobility Report</a></p><p>The data is made available on a global scale and can be downloaded in csv format. General report of mobility has been provided country and region wise which shows the pattern of community mobility in selected areas namely — parks, grocery ,pharmacy, residential ,transit stations and workplaces. The data maintains the integrity of the user and in no way reveals the identity of the user.The data might show some void in data points which might be because of the insufficient parameters available to maintain the user’s anonymity.</p><h3>Extract the data :</h3><p>Specific instructions will depend on your browser and operating system, but on Windows OS, I can get the URL by right-clicking on the button that says “Download global CSV” and choosing “Copy Link Address”.(Feel free to use any platform — in my case I used Google Colab)</p><p>Then, in the following cells, use that URL to read the data into a pandas Data Frame called df.</p><pre><strong>import</strong> <strong>pandas</strong> <strong>as</strong> <strong>pd</strong><br><strong>import</strong> <strong>matplotlib.pyplot</strong> <strong>as</strong> <strong>plt<br></strong>url = &quot;#INSERT THE URL HERE&quot;<br>df = pd.read_csv(url)</pre><p>To get some general overview you can use the info() and head() functions to show some basic information about the data and to look at the first few samples.</p><pre>df.info()<br>df.head()</pre><h3>Basic data manipulations:</h3><p>The data includes a date field, but it may have been read in as a string, rather than as a datetime. If that’s the case, use to_datetime() to convert the field into a date time format.</p><pre>df[&#39;date&#39;] = pd.to_datetime(df[&#39;date&#39;])<br>df.info()</pre><p>Next to extract the subset of data for the location of your choice. You can choose any location. The data is reported for different regions, with different levels of granularity available. This is best explained by example:</p><p>Suppose I want the overall trend from the entire Canada. I would use the subset of data where country_region is equal to “Canada” and sub_region_1 is null:</p><pre>df_subset = df[(df[&#39;country_region&#39;].eq(&quot;Canada&quot;)) &amp; (df[&#39;sub_region_1&#39;].isnull())]</pre><p>Suppose I want the overall trend from the entire province of Ontario: I would use the subset of data where country_region is equal to “Canada”, sub_region_1 is equal to “Ontario”, and sub_region_2 is null:</p><pre>df_subset = df[(df[&#39;country_region&#39;].eq(&quot;Canada&quot;)) &amp; (df[&#39;sub_region_1&#39;].eq(&quot;Ontario&quot;)) &amp; (df[&#39;sub_region_2&#39;].isnull())]</pre><p>Is the data complete, or is some data not available for the location you have chosen? To check for missing data in the ...percent_change_from_baseline fields you can use :</p><pre><strong>for</strong> i <strong>in</strong> range(7,13):<br>  print(df_subset.iloc[:,i].isnull().values.any()) <em># looping through the column with the ...percent_change_from_baseline </em><br>  <em>#and looking for missing data points</em></pre><p>In my subset of data frame i.e <strong>Ontario</strong>, it is evident that data points are not missing from the fields like … percent_change_from_baseline. But while you look at states like Indiana and New York as a whole there are data points which show gap in the data, so as to maintain the differential privacy of the user’s identity. As the data collected by a particular user did not meet the threshold of maintaining a user’s anonymity. These missing data points are relevant if we consider analysis for a day to day basis or only for a particular day, but since the data is collected over a period of 5 week,missing few data points won’t pose a great loss to the data accuracy for that particular week.</p><p>For this data, the date field is important, but we don’t necessarily care about the absolute date. Instead, we care about how many days have elapsed since the first confirmed case of COVID-19 in this location, how many days have elapsed since a “stay at home” order or similar rule was established in this location (if there was one) and how many days have elapsed since it was lifted (if applicable).</p><p>For example, in Canada,Ontario, I used the days since reopening. For reference use:</p><pre><a href="# Ontario reopen phase1 , May 19 2020 https://www.ontario.ca/page/reopening-ontario-whats-each-stage#section-1"><strong><em>https://www.ontario.ca/page/reopening-ontario-whats-each-stage#section-1</em></strong></a></pre><pre><em># days_since...</em><br>days_since_reopen = (df_subset[&#39;date&#39;] - pd.to_datetime(&#39;2020-05-19 00:00:00&#39;)).dt.days.values<br>print(days_since_reopen)</pre><pre><em># Ontario reopen phase1 , May 19 2020<br># for further reference , facilities that open include retail, construction , indoor sports etc.</em></pre><h3>Visualize data:</h3><p>Finally, we are going to visualize the changes in human mobility over this time, for the location you have chosen.Here we are focusing on the trends in community mobility for different sectors of public commute.</p><pre>%matplotlib inline<br>fig, axs = plt.subplots(6)<br>axs[0].plot(days_since_reopen,df_subset.retail_and_recreation_percent_change_from_baseline)<br>axs[1].plot(days_since_reopen,df_subset.grocery_and_pharmacy_percent_change_from_baseline)<br>axs[2].plot(days_since_reopen,df_subset.parks_percent_change_from_baseline)<br>axs[3].plot(days_since_reopen,df_subset.transit_stations_percent_change_from_baseline)<br>axs[4].plot(days_since_reopen,df_subset.workplaces_percent_change_from_baseline)<br>axs[5].plot(days_since_reopen,df_subset.residential_percent_change_from_baseline)<br>plt.xlabel(&#39;Days since reopening&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*Lbx_KH2C8OEUGR0SJrLFdQ.png" /></figure><h3>Observation:</h3><p>The results here seems to be satisfy common sense,as it is quite reasonable to say that there will be upsurge of people visiting the parks, <em>workplaces ,transit stations, retail and grocery stores</em> after reopening and this claim is supported by the results in the graph above and a downward trend is observed for the <em>residential </em>changes.The peaks in the graph resemble a holiday for places like the <em>parks and other activities</em> other than the <em>workplace </em>change which observes a sharp decrease.</p><p>The data for mobility changes due to COVID-19 is helpful to measure the change in the mobility for certain fields. When it comes to defining the mobility of the people respective to their jobs like student the data seems to be lacking in some aspects and also when we compare the data of the visits to National parks and recreational center there is no clear parameter that helps us to differentiate whether the number of visits to the National Park is more or the public gardens. Also not a very vivid differentiation can be made for people who work in hospitals and grocery stores as they probably have the same amount of time they spend in the residential area. So for better analysis ,clearer and categorized data might help our cause to measure the true Mobility changes caused in different sectors due to COVID-19.</p><h3>Reference:</h3><p>Use the following links to understand the data better:</p><ul><li><a href="https://www.google.com/covid19/mobility/data_documentation.html?hl=en#about-this-data">Attribution</a></li><li><a href="https://support.google.com/covid19-mobility/answer/9825414?hl=en&amp;ref_topic=9822927">Understand the data</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b9625b55a13" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-ontarios-mobility-is-shaping-up-since-reopening-3b9625b55a13">How Ontario’s mobility is shaping up since reopening</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>