<?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 Hany IMAM on Medium]]></title>
        <description><![CDATA[Stories by Hany IMAM on Medium]]></description>
        <link>https://medium.com/@Hanyk961?source=rss-35435a20a029------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zUx-Xqni5GLZZbAY.png</url>
            <title>Stories by Hany IMAM on Medium</title>
            <link>https://medium.com/@Hanyk961?source=rss-35435a20a029------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 08:14:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Hanyk961/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[Leveraging OpenAI and ChatGPT to Query Local Documents with a Shiny App]]></title>
            <link>https://medium.com/analytics-vidhya/leveraging-openai-and-chatgpt-to-query-local-documents-with-a-shiny-app-9efa419a9018?source=rss-35435a20a029------2</link>
            <guid isPermaLink="false">https://medium.com/p/9efa419a9018</guid>
            <category><![CDATA[shiny-app]]></category>
            <category><![CDATA[gpt-3]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[r]]></category>
            <dc:creator><![CDATA[Hany IMAM]]></dc:creator>
            <pubDate>Tue, 28 Mar 2023 08:49:26 GMT</pubDate>
            <atom:updated>2023-03-28T08:49:26.186Z</atom:updated>
            <content:encoded><![CDATA[<p>The integration of OpenAI’s ChatGPT with Shiny, an R package for creating interactive web applications, offers a powerful way to ask questions and retrieve answers directly from local documents. In this article, we will demonstrate how to a Shiny app can harness the capabilities of ChatGPT, making it easier to search and analyze information stored in local documents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NRS35_ryZgRRysQ50D28lg.png" /><figcaption>An example using “Curie” as an engine</figcaption></figure><p>Several AI engines, each with unique capabilities and applications, are available from OpenAI. Here is a succinct summary of some important engines in plain language:</p><p>Ada: This engine is the tiniest and fastest. It works well for easy chores and rapid solutions. Consider it as a useful assistant for everyday use, but keep in mind that it might not be as precise or comprehensive for difficult topics.</p><p>Babbage: A step up from Ada, Babbage is more capable and has a wider range of jobs it can complete. It’s comparable to having an informed friend who can offer more context and depth, but it might not be ideal for more specialized issues.</p><p>Curie: More advanced than Babbage, Curie is capable of handling complex tasks with greater detail and accuracy. It’s like having an expert by your side who can understand context better and give more insightful answers, but it may still have occasional limitations.</p><p>Davinci: The most sophisticated and potent engine in the lineup, Davinci is made to be exceptionally good at a variety of activities, including as comprehending context, giving thorough responses, and resolving challenging issues. It’s like having a genius at your disposal, but be aware that it still might make a mistake now and then.</p><p>Each of these engines is powered by artificial intelligence, and their performance can vary depending on the task at hand. They are designed to cater to different needs, so choosing the right engine depends on the complexity and requirements of your specific use case.</p><p>For more information on engine: <a href="https://platform.openai.com/docs/api-reference/engines/list">https://platform.openai.com/docs/api-reference/engines/list</a></p><h3><strong>The App (in Shiny framework)</strong></h3><p>To achieve the solution, I have implemented the OpenAI API in my R Shiny application using the httr package to retrieve answers in json format:</p><pre># Replace with the GPT-3 endpoint and your desired model name<br>gpt3_endpoint &lt;- &quot;https://api.openai.com/v1/engines/curie/completions&quot;<br>api_key &lt;- &quot;your_api_key_here&quot;<br>body = jsonlite::toJSON(list(<br>  prompt = paste(prompt, all_text),<br>  max_tokens = 50,<br>  n = 1,<br>  stop = NULL,<br>  temperature = 1<br>), auto_unbox = TRUE)</pre><p>Now, the application would follow the Shiny-app structures with a UI and a Server part:</p><pre># Define UI<br>ui &lt;- fluidPage(<br>  titlePanel(&quot;Ask your documents&quot;),<br>  sidebarLayout(<br>    sidebarPanel(<br>      fileInput(&quot;pdf_file&quot;, &quot;Choose PDF File&quot;, accept = c(&quot;.pdf&quot;)),<br>      textInput(&quot;question&quot;, &quot;Enter your question:&quot;),<br>      actionButton(&quot;submit&quot;, &quot;Submit&quot;)<br>    ),<br>    mainPanel(<br>      textOutput(&quot;answer&quot;)<br>    )<br>  )<br>)</pre><pre>server &lt;- function(input, output) {<br>  observeEvent(input$submit, {<br>    if (!is.null(input$pdf_file)) {<br>      pdf_text &lt;- pdf_text(input$pdf_file$datapath)<br>      all_text &lt;- paste(pdf_text, collapse = &quot;\n&quot;)<br>      <br>#Your prompt part (GPT3 endpoint)<br>           <br># Run the application<br>shinyApp(ui = ui, server = server)</pre><p>It is quite straight forward to build such applications and it is also experimental to test different engines and manipulate the parameters to retrieve the desired outcomes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9efa419a9018" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/leveraging-openai-and-chatgpt-to-query-local-documents-with-a-shiny-app-9efa419a9018">Leveraging OpenAI and ChatGPT to Query Local Documents with a Shiny App</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[The “One Minute Map” — static and interactive maps creation with the R tmap package]]></title>
            <link>https://medium.com/@Hanyk961/the-one-minute-map-static-and-interactive-maps-creation-with-the-r-tmap-package-6f919b57d7f7?source=rss-35435a20a029------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f919b57d7f7</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[meta]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <dc:creator><![CDATA[Hany IMAM]]></dc:creator>
            <pubDate>Tue, 25 Jan 2022 10:23:32 GMT</pubDate>
            <atom:updated>2022-01-26T08:43:38.187Z</atom:updated>
            <content:encoded><![CDATA[<h3>The “One Minute Map” — static maps creation with the R tmap package: The case of MetaWealth Index in Nigeria</h3><p><strong>Yes, you have read it right! </strong>This post is not related to Missy or Luda famous “One Minute Man” song, yet it is a straightforward introduction to a series of data analysis applications in R, particularly how to create and deal with maps in R and Rstudio within a minute!!</p><p>This is the first of a series that I will be sharing in <a href="https://medium.com/u/504c7870fdb6">Medium</a> for data scientists and lovers to put more hands on mapping using R.</p><p>In this session, I will take you through the smooth journey of creating static maps with the “tmap” package in R in less than a minute.</p><h3>About the data</h3><p>As a humanitarian data scientist, I focus on areas where conflictivity, poverty and fragility are the main drivers of my research, hence I am using Nigeria as an example to map the “Weighted Relative Wealth Index” that was produced by <a href="https://medium.com/u/4e7a97edbbf7">Meta</a> Data for Good team with a big dataset containing more than 100K observations (records). The dataset has only 4 variables, longitude, latitude, wri and error. More on the data and the study behind it is well explained by <a href="https://medium.com/u/4e7a97edbbf7">Meta</a> <a href="https://dataforgood.facebook.com/dfg/tools/relative-wealth-index">here</a>.</p><h3>The static map</h3><p>Using the “tmap” package in R, I was able to create the first map of the WRI using the dots technique.</p><p>To create a dot map, you need a dataset with longitude and latitude and some indicators to add more information to your map, or you need a <em>shapefile</em> that has all the information embedded within its relative components.</p><p>In “tmap” package, you convert the dataset to a geographic standard file using the st_as_sf, by setting the coordinates variables and teh CRS projection system:</p><p>wrimap &lt;- st_as_sf(nga_wealth_index, coords = c(“longitude”, “latitude”), crs = 4326)</p><p>I then used tm_shape and tm_dots to inform the console that I am creating a dots map:</p><p>tm_shape(wrimap) + <br> tm_dots(alpha = 0.8, col = “rwi”, palette = “PRGn”,<br> stretch.palette = TRUE, size = 0.01)+</p><p>The layout is an optional item in “tmap” where a user adjusts the visualization parameters:<br> tm_layout (frame = TRUE, bg.color = “transparent”,<br> legend.title.size = 1,<br> legend.text.size = 0.6,<br> legend.position = c(“right”,”bottom”),<br> legend.bg.color = “white”,<br> legend.bg.alpha = 1,<br> main.title = “Weighted Relative Wealth Index in Nigeria”,<br> main.title.size = 1<br>)</p><p>Here is the result map showing the weighted relative wealth index in Nigeria.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5vq4vavKr95U33nrfc0u2g.png" /></figure><h3>Deep dive into the RWI data</h3><p>The map shows a significant difference in wealth between the northern part of the country where it tends to have a very low negative index, and the southern part where it looks wealthier as per the index.</p><p>Again, as a humanitarian data scientist, I am more concerned in areas where conflict might be a driver of a less wealthier context.</p><p>In this regard, I will be mapping the average RWI on the Local Government Areas (LGA) level for the Borno, Adamawa and Yobe (BAY) states.</p><p>The shapefile of the LGAs can be downloaded from the Humanitarian Data Exchange (HDX) <a href="https://data.humdata.org/">website</a>.</p><p>Using the “point.in.poly” function from the “SpatialEco” package, I got the LGAs information added to my points shapefile. I then calculated the mean of WRI in each o the LGAs by using the“dplyr” package.</p><p>“Tigris” package is then requested to join back the new dataframe with the WRI mean to the LGAs shapefile:</p><p>lga_rwi &lt;- geo_join(adm2,<br> wri_mean,<br> “ADM2_EN”,<br> “ADM2_EN”,<br> how = “left”) # Joins the rwi average to the LGA shapefile</p><p>Now it is the time to map our RWI data over the LGAs, using the tm_fill function from the “tmap” package:</p><p>wri.lga.map &lt;-<br> tm_shape(lga_rwi) +<br> tm_fill(col = “wri”,<br> palette = “PRGn”,<br> stretch.palette = FALSE,<br> n = 10) +<br> tm_borders(col = “black”,<br> lwd = 0.5) +<br> tm_text(“ADM2_EN”,<br> size = 0.7) +<br> tm_layout(<br> main.title = “Average Wealth Index in BAY States”,<br> main.title.size = 1,<br> legend.position = c(“left”, “bottom”),<br> legend.text.size = 1,<br> legend.text.color = “black”,<br> legend.title.size = 1,<br> bg.color = “#d0e2ec”,<br> legend.outside = T<br> )<br>The results are shown in the map below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MyrBXLEoT7021ryZWQMoww.png" /></figure><p>As you may see, there is a tendency to less wealth in the LGAs of the three states except for the two main cities Maiduguri and Yola where the WRI is reaching a positive number between 0.8 and 1.2 which is also considered to be relatively low.</p><p>In the next sessions, we will do some spatial correlation analysis with different datasets that might allow us revealing the reason behind a low RWI in such context.</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f919b57d7f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object detection and Deep Learning: Identify Google Streetview image content using YOLO in R]]></title>
            <link>https://medium.com/analytics-vidhya/object-detection-and-deep-learning-identify-google-streetview-image-content-using-yolo-in-r-bca631aa0bf3?source=rss-35435a20a029------2</link>
            <guid isPermaLink="false">https://medium.com/p/bca631aa0bf3</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[geoai]]></category>
            <category><![CDATA[yolo]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Hany IMAM]]></dc:creator>
            <pubDate>Sun, 27 Sep 2020 06:23:14 GMT</pubDate>
            <atom:updated>2020-10-28T10:18:50.435Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Google Street View</strong> is a technology featured in Google Maps and Google Earth that provides interactive panoramas from positions along many streets in the world. It was launched in 2007 in several cities in the United States, and has since expanded to include cities and rural areas worldwide. Streets with Street View imagery available are shown as blue lines on Google Maps.</blockquote><blockquote>Google Street View displays panoramas of stitched images. Most photography is done by car, but some is done by tricycle, boat, snowmobile, and underwater apparatus, as well as on foot.</blockquote><blockquote><a href="https://en.wikipedia.org/wiki/Google_Street_View">https://en.wikipedia.org/wiki/Google_Street_View</a></blockquote><h3><strong>Scraping images</strong></h3><p>Here is how you can scrape images from Google Streetview in Google maps:</p><pre>jpeg(file=&quot;/complete/URL/tofile/Sanaa1.jpeg&quot;)<br>google_streetview(location = c(15.3168264, 44.2289662),<br>                  size = c(400,600),<br>                  panorama_id = NULL,<br>                  output = &quot;plot&quot;,<br>                  heading = 90,<br>                  fov = 90,<br>                  pitch = 0,<br>                  response_check = FALSE,<br>                  key = key)</pre><pre>dev.off()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MKaKam1X-pmizTFUCWXtTg.png" /><figcaption>Google Streetview extract of a street in Sana’a — Yemen</figcaption></figure><p>If you are intending to use multiple images at once, you can run a “for” loop that will scrape multiple images from different locations.</p><h3><strong>Deep Learning: Object Detection — Why YOLO?</strong></h3><blockquote><strong>You only look once</strong> (YOLO) is a state-of-the-art, real-time object detection system. On a Pascal Titan X it processes images at 30 FPS and has a mAP of 57.9% on COCO test-dev: <a href="https://pjreddie.com/darknet/yolo/">https://pjreddie.com/darknet/yolo/</a></blockquote><blockquote>Darknet YOLO model has several advantages over classifier-based systems. It looks at the whole image at test time so its predictions are informed by global context in the image. It also makes predictions with a single network evaluation unlike systems like <a href="https://github.com/rbgirshick/rcnn">R-CNN</a> which require thousands for a single image. This makes it extremely fast, more than 1000x faster than R-CNN and 100x faster than <a href="https://github.com/rbgirshick/fast-rcnn">Fast R-CNN</a>.</blockquote><blockquote><a href="https://pjreddie.com/darknet/yolo/">https://pjreddie.com/darknet/yolo/</a></blockquote><p>Below is the 3 lines script that will be implemented on our extracted image to identify its contents:</p><pre>#Image Detection<br>library(image.darknet)<br>#Import YOLO Tiny Model <br>yolo_tiny_voc &lt;- image_darknet_model(type = &#39;detect&#39;, <br> model = &quot;tiny-yolo-voc.cfg&quot;, <br> weights = system.file(package=&quot;image.darknet&quot;, &quot;models&quot;, &quot;tiny-yolo-voc.weights&quot;), <br> labels = system.file(package=&quot;image.darknet&quot;, &quot;include&quot;, &quot;darknet&quot;, &quot;data&quot;, &quot;voc.names&quot;))<br>Output_image &lt;- image_darknet_detect(file=&quot;/complete/URL/tofile/Sanaa1.jpeg&quot;, <br>                          object = yolo_tiny_voc,<br>                          threshold = 0.12)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5OaJZjScLq8Htp9Zyl-NPg.png" /><figcaption>Labels have been added to our image</figcaption></figure><blockquote><strong>Changing The Detection Threshold</strong></blockquote><blockquote>By default, YOLO only displays objects detected with a confidence of .25 or higher. You can change this by passing the -thresh &lt;val&gt; flag to the yolo command. For example, to display all detection you can set the threshold to 0.</blockquote><blockquote><strong>Training YOLO on VOC</strong></blockquote><blockquote>You can train YOLO from scratch if you want to play with different training regimes, hyper-parameters, or datasets.</blockquote><blockquote><strong>Get The Pascal VOC Data</strong></blockquote><blockquote>To train YOLO you will need all of the VOC data from 2007 to 2012. You can find links to the data <a href="https://pjreddie.com/projects/pascal-voc-dataset-mirror/">here</a>. To get all the data, make a directory to store it all and from that directory run:</blockquote><blockquote>wget https://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar<br>wget https://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar<br>wget https://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar<br>tar xf VOCtrainval_11-May-2012.tar<br>tar xf VOCtrainval_06-Nov-2007.tar<br>tar xf VOCtest_06-Nov-2007.tar</blockquote><blockquote><a href="https://pjreddie.com/darknet/yolo/">https://pjreddie.com/darknet/yolo/</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bca631aa0bf3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/object-detection-and-deep-learning-identify-google-streetview-image-content-using-yolo-in-r-bca631aa0bf3">Object detection and Deep Learning: Identify Google Streetview image content using YOLO in R</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>
    </channel>
</rss>