<?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 Mina Jambajantsan on Medium]]></title>
        <description><![CDATA[Stories by Mina Jambajantsan on Medium]]></description>
        <link>https://medium.com/@mina_77131?source=rss-27b96db2e3ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*XjVCNtqRUQX5s6S6kEzekA.jpeg</url>
            <title>Stories by Mina Jambajantsan on Medium</title>
            <link>https://medium.com/@mina_77131?source=rss-27b96db2e3ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 08:59:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mina_77131/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[ERROR 001523: JPEG compression is only supported for 8 bit unsigned or 16 bit unsigned data with…]]></title>
            <link>https://medium.com/@mina_77131/error-001523-jpeg-compression-is-only-supported-for-8-bit-unsigned-or-16-bit-unsigned-data-with-c2abad43426c?source=rss-27b96db2e3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2abad43426c</guid>
            <category><![CDATA[gis-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[satellite-imagery]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Mina Jambajantsan]]></dc:creator>
            <pubDate>Thu, 16 May 2024 11:54:50 GMT</pubDate>
            <atom:updated>2024-05-16T11:54:50.337Z</atom:updated>
            <content:encoded><![CDATA[<h3>ERROR 001523: JPEG compression is only supported for 8 bit unsigned or 16 bit unsigned data with one or three bands, and without a colormap.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*63A83iWOHBeCJwWyvqweWA.png" /></figure><p>How many of us encountered this problem while creating a training dataset for a Machine Learning model? Or I guess there are might be million other reasons to receive this messge.</p><p>To simply put in my case this error message means that I have 4 BANDS instead of 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9pRQvQcat65512zf9vqwiw.png" /></figure><p>I believe there are multiple solutions to this problem, but here is an easy one:</p><pre>import rasterio<br>from rasterio.enums import Resampling<br>import numpy as np<br> <br># Open the original TIFF file<br>with rasterio.open(&#39;input.tif&#39;) as src:<br>    # Read all bands except the fourth one<br>    bands = [src.read(i) for i in range(1, src.count + 1) if i != 4]<br>   <br>    # Stack the bands into a 3D array<br>    data = np.stack(bands)<br> <br>    # Get the profile of the source file<br>    profile = src.profile<br>    profile.update(count=len(bands))  # Update the profile with the new number of bands<br> <br># Write the new TIFF file without the fourth band<br>with rasterio.open(&#39;output.tif&#39;, &#39;w&#39;, **profile) as dst:<br>    dst.write(data)</pre><p>In case you don’t have rasterio, please install it first:</p><pre>pip install rasterio</pre><p>I hope it helps! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2abad43426c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An example of Archaeological Drone Surveying]]></title>
            <link>https://medium.com/@mina_77131/an-example-of-archaeological-drone-surveying-b7e2a13f657?source=rss-27b96db2e3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7e2a13f657</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[aerial-photography]]></category>
            <category><![CDATA[uav]]></category>
            <category><![CDATA[drones]]></category>
            <category><![CDATA[archaeology]]></category>
            <dc:creator><![CDATA[Mina Jambajantsan]]></dc:creator>
            <pubDate>Thu, 16 Apr 2020 09:58:03 GMT</pubDate>
            <atom:updated>2020-05-04T16:03:37.532Z</atom:updated>
            <content:encoded><![CDATA[<h3>An example of Archaeological Drone Surveying or how did I get my data?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ou4MF_MhxWpe3L4f_yM_Sg.jpeg" /><figcaption>An elevation map of Ulaan Kherem, a 10th century Khitan settlement</figcaption></figure><p>I have been a team member of Hungarian-Mongolian Archaeological project aiming to study historic sites of Liao Empire on territory of Mongolia. The Empire ruled present-day Mongolia, Northern China, Russian Far East and North Korea from 916 to 1125. Our project started in 2016 and the last season was in 2018.<br>I started the drone flying with no previous experience, but had a seminar of Aerial Archaeology during my PhD studies in Budapest at ELTE University. I have tried and learned many new things during this project, and I hope this post will give a short resume of my experience.</p><p>2016 October — November<br>Our first trip to Mongolia took place in October 2016 from Budapest, and our goal was to visit as many sites as possible to choose the right one for further research.<br>I had a DJI Phantom 3 Standard with 2 batteries (1 main and 1 spare), a charger, and a set of extra propellers. Also, I had a full documentation of the drone and the batteries in a file in my laptop and the batteries were in a fireproof safety bags (LiPo Guard). I didn’t plan to fly much because of the cold weather in Mongolia. For your attention, if you fly anywhere from Budapest Liszt Ferenc International Airport, no matter what airline you flying, you need to put your drone in the luggage, and you are not allowed to carry onboard it in any way. They were really strict about it, and it was a hard lesson for me, because I wasn’t prepared for this plot, it didn’t really feel safe (spoiler alert, it arrived safe and sound in UlaanBaatar).<br>While we had transit in Moscow, I asked the Russian airport about their drone on board policy, and they said it doesn’t matter for them.</p><p>In Mongolia we visited several archaeological sites, and despite the extreme conditions (-30 degrees Celsius or -22 Fahrenheit cold and the strong wind) I managed to take a few shots from about 100 meters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DA86U5YTu42OpKltc7tfMQ.jpeg" /><figcaption>Fragment of a wall and corner</figcaption></figure><p>It wasn’t a good idea, please don’t do it after me. I was lucky, my drone returned unharmed, but it could’ve gone either way:<br>- Weather is unpredictable, it might start to snow<br>- Extreme temperatures can impact flight performance because the Lithium Polymer (LiPo) batteries drain faster in cold temperature<br>- Drones are NOT recommended to fly under 0 Celsius<br>- There was an eagle lurking around, who was curious enough to fly close to the drone to observe it, and smart enough to decide it was inedible</p><p>A few tips if you decide to give it a try anyway:<br>- Check wheather conditions, never ever try to fly if it will snow or rain<br>- Avoid contact with snow (I used a small rug from the car for landing)<br>- Keep the batteries warm (I kept them under my coat)<br>- Always check the temperature of the batteries (no matter if it’s winter or summer)<br>- Use only fully charged batteries<br>- Hover after take-off for 10–20 seconds to ensure it’s ready and will not freeze right away</p><p>For this short flight I used only the official DJI app , and made a few more shots at a second site as well. Conditions were as “usual”: extreme cold, strong wind, hungry eagles.<br>From UlaanBaatar I flew back to London through Moscow with the drone in my hand luggage. None of the airports had issues with it, only thing is that batteries must be about 20% full (just to have 1 light out of 4 to show that it’s an operating thing, but still not enough to fly around, which of course you should never do anywhere near an airport).</p><p>May — June 2017<br>After a discussion with our Mongolian colleagues we decided to conduct further research on KharBukh Balgas, a Khitan settlement which used to be a fort on the far Northern border of Liao Empire. The settlement existed in the 10th-11th centuries and can be found in Mongolia, Bulgan Province. Length of the walls are between 660 metres to 760 metres, the present height is around 2–2.5 meters, and width is around 3–4 meters. The settlement had 4 gates, watch towers on every corner, over the gates and on the walls. KharBukh balgas is a later given name, we are not sure about its name during Liao Empire (Mongolian researchers found 3 potential names in written sources), but what we know is that this fort used to hold back and fight nomad tribes from North to raid the Khitan Empire.<br>Later in the 17th century a Buddhist Monastery was built between the 10th century walls. The Monastery didn’t last long, it was destroyed during war between Mongolian lords.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lV4gjedZPzbhKkn6ElJ2Aw.jpeg" /><figcaption>10th century walls and 17th century building remains (and a tiny museum in the left upper corner)</figcaption></figure><p>This time I was flying from home, while other members of the team were flying from Budapest, and the meeting point was in Moscow. London Heathrow didn’t mind the drone and batteries in hand luggage, neither did Moscow Sheremetyevo.<br>Now I was more prepared technically and even had GPS coordinates to work with. I have upgraded for a DJI 3 Phantom Pro, invested in a professional DJI Drone bag and bought 2 more spare batteries and fireproof bags for them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y_E9LC7bgB2uVKb-f18P6A.jpeg" /><figcaption>A dedicated drone bag, 4 batteries (1 in the drone), extra set of propellers, an iPad, card reader</figcaption></figure><p>If you are travelling, especially this far, the bag is a lifesaver.</p><p>Apps I used:<br>- Official DJI GO app for primary check of the drone<br>- Map Pilot (Maps Made Easy) for grid flights and essentially it was my “work tool”<br>- DroneDeploy to see my projects in one place, also very useful for afterwork on my images (but it has a price)<br>- Litchi for hoovering around an object to capture images that can be used for 3D Models<br>To create an Orthomap of the captured drone photos I used ArcGIS and later QGIS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n3Ni4l-Q-70qq-iECeawvw.jpeg" /><figcaption>An example of a Map Pilot dashboard</figcaption></figure><p>So what do we see here?<br>- The drone will fly on altitude of 100 metres, because it gives a nice resolution, still not using that much power. On 200 metres the resolution would be smaller, and on 50 metres it will require at least 8 batteries which luxury we don’t have in such remote sites. If you have unlimited power source like normally in city and extra days on site, you can go for the better resolution<br>- The resolution of the photos will be 4.3 cm / pixel<br>- The overall area is 66.47 hectares, and the distance is 27.42 km by the grids. By the way, we can adjust the grids, but I prefer an overlap of 80% to 80% due to terrains consistency<br>- The maximum speed is essentially 5.4 metres / second, but can vary due to wind speed and strength<br>- The whole duration of the flight will be 92 minutes 41 seconds and will require 5 batteries. Again, mind the wind. If you are lucky, it might take less time.<br>- We will capture 813 images with 1951 points and it will require 4.05 GB memory space. I had a 64 GB memory card in the drone, should be enough for a while<br>- Officially these batteries can fly 23 minutes, but for safety reasons I will be flying 18.3 minutes. Again, a lot depends on the wind, if it’s too windy up there you don’t want to risk losing your drone somewhere in the wild</p><p>Pros of this big open terrain is that you don’t have to worry that your Wi-Fi signal might be disturbed or you have to be mindful of any high structures.<br>Cons that if you lose the drone for any reason, it’s extremely hard to find it (yes, been there, done that).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G_hq_D-PUtE0wiOVJkvKpw.jpeg" /><figcaption>Our “under thousand stars” accommodation</figcaption></figure><p>As you can see, we were living in these tents, and we had no electricity for the time being. All we had is a big gasoline aggregator every evening strictly for a couple of hours. I needed to charge all my 4 batteries during this time, and I had a battery charging hub for that. It was able to charge all the batteries after each other, meaning they were not charged all in one time. I must admit, I had a rather difficult time with charging, probably it was the hardest part on site. Also, every evening I downloaded the images to my laptop and at least to 2 other members of the team. If anything happens to the drone or my laptop, we will still have 2 other copies.</p><p>I had multiple flying plans for areas surrounding the fort, and my flight depended on battery. In overall during 2017 and 2018 seasons I managed to make photos of nearly every area I wanted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KI_MtH026ONMlaiBHdb8Ng.png" /><figcaption>It reminds me of a bear</figcaption></figure><p>June 2018<br>In this season I managed to finish flying over the areas that were missing from last year, also we participated in an excavation done by our Mongolian colleagues. This excavation was studying the remains of the Buddhist Monastery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJWzDlyTZd-4XLQIdMcriQ.jpeg" /><figcaption>A room in one of the smaller buildings</figcaption></figure><p>In total in Mongolia I have captured images of two more Khitan settlements, a 2000 years old Xiongnu cemetery, two 17th century Buddhist Monastery remains and several bronze age burials. Much later at home I used ArcGIS and QGIS. Both are geographic information system applications to view, edit and analyse geospatial data, the first one maintained by Esri, the second one is open-sourced.</p><p>Often people ask me why was I using a DJI Phantom and not a bigger, stronger, more professional drone which can capture more features? The answer is easy: the DJI Phantom is relatively small, can carry multiple batteries, relatively cheap, very reliable and I can walk with it in my backpack even for many kilometres. When battery life is such a treasure, you need to make the flight plan as optimal as you can. I rather walked from one start point to the next one than lose any precious airborne minutes.</p><p>This year I learned how to make contour maps with QGIS, and upgraded my elevation map skills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k15K5P2z6RTQ8rrQteAl8w.png" /><figcaption>KharBukh elevation map</figcaption></figure><p>I didn’t have any GPS coordinates for any sites except the Khitan settlements, so every time I had to improvise, aka pilot simultaneously. Cellular data is still a rare thing in rural Mongolia, so it wasn’t an option to quickly make a flight plan after arriving to the site. Although there were many other obstacles like weather, time, too much sunshine (you just barely can see your screen), and bugs (lots of bugs), I still enjoyed every moment of it.</p><p>In the future I am considering investing in a serious lightweight portable solar charger and taking 2 drones on the trip, because losing a drone midseason is my recurring nightmare. Not sure if it still would be a DJI Phantom or a Mavick, might go for the second one, because size matters.</p><p>I hope you have enjoyed reading it and found it useful.<br>Please let me know if have any questions regarding the topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*IvOk4UWXSHRRreYxPbryAg.gif" /><figcaption>And let’s fly away</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7e2a13f657" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image preprocessing with Pillow]]></title>
            <link>https://medium.com/analytics-vidhya/image-preprocessing-with-pillow-1e19bdc57934?source=rss-27b96db2e3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e19bdc57934</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[archaeology]]></category>
            <category><![CDATA[pillow]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[drone-photography]]></category>
            <dc:creator><![CDATA[Mina Jambajantsan]]></dc:creator>
            <pubDate>Sun, 19 Jan 2020 19:32:00 GMT</pubDate>
            <atom:updated>2020-01-20T12:26:37.036Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-8y7FL0Nzc_R_7WS6PC3uQ.jpeg" /><figcaption>Mongolian landscape</figcaption></figure><p>Pillow is an open source library originally written by Fredrik Lundh, which allows to import, open, manipulate images and save them in different formats. With Pillow we can do per-pixel manipulations, filtering, rotating, masking, flipping, enhancing, sharpening and even more sophisticated processes. It is also a basis for SciPy, Numpy and Matplotlib libraries. Initialy it was called Python Imaging Library and was released in 1995 (25 years ago).</p><p>Before even starting to split our data to train and test sets we need to learn to load our images and to perform some basic manipulations. Pillow is the perfect tool for that, and if we are working using Anaconda, then it’s usually installed as a part of SciPy installations which we can <strong>check</strong> confirming the <strong>version number</strong> like this:</p><pre>import PIL</pre><pre>print(&#39;Pillow Version:&#39;, PIL.__version__)</pre><p>Or if it’s not found we can <strong>install it</strong>:</p><pre>pip install Pillow</pre><p>Here I’ve <strong>imported all the libraries</strong> I will use later:</p><pre>import PIL<br>from PIL import Image<br>from matplotlib import image<br>from matplotlib import pyplot<br>from numpy import asarray<br>from os import listdir</pre><p>Then we can <strong>load our image</strong>. Here I’m loading a JPG image with name ‘circles’:</p><pre>image = Image.open(&#39;circles.jpg&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eX4XFSk3hpH8sM3Uxebogg.jpeg" /><figcaption>‘circles.jpg’</figcaption></figure><p>Let’s <strong>summarize</strong> some details:</p><pre>print(image.mode)<br>print(image.size)<br># show the image<br>image.show()</pre><pre>out: RGB<br>     (4000, 3000)</pre><p>It shows me the ‘mode’ meaning the pixel channel (RGB or CMYK), and the ‘size’ which shows the dimensions of the image in pixels (4000 x 3000)</p><p>Now we can <strong>load </strong>and <strong>view</strong> our image using <strong>Matplotlib</strong> with Pillow under the hood. The <em>imread()</em> function loads the image as array of pixels and the<em> imshow()</em> function diplays an array of pixels as an image:</p><pre>from matplotlib import image<br>from matplotlib import pyplot<br>data = image.imread(&#39;circles.jpg&#39;)</pre><pre># summarize shape of the pixel array<br>print(data.dtype)<br>print(data.shape)</pre><pre># display the array of pixels as an image<br>pyplot.imshow(data)<br>pyplot.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZdLZ81NtmikgZN8X2v4BwQ.png" /></figure><p>What information does it show?<br>uint8 → Data type of the array: 8-bit unsigned integers<br>3000, 4000 → Shape of the array: 3000 pixels wide by 4000 pixels high<br>3 → Three channels for red, green, and blue</p><p>Now we can access the pixel data constructing a <strong>NumPy</strong> array and pass in the image object. If the image data will be manipulated as a NumPy array, and later we want to save it as a JPEG or PNG file, we can use the <em>Image.fromarray()</em> function:</p><pre># load image as Pillow Image object<br>image = Image.open(&#39;circles.jpg&#39;)</pre><pre># convert image to numpy array<br>data = asarray(image)</pre><pre># summarize shape<br>print(data.shape)</pre><pre># convert it back as Pillow Image<br>image2 = Image.fromarray(data)</pre><p>And the new image2 type will be a PILL.image.image:</p><pre>type(image2)</pre><p>We also can load multiple images from a folder:</p><pre>from matplotlib import image<br>from matplotlib import pyplot</pre><pre># load all images in a directory<br>loaded_images = list()<br>for filename in listdir(&#39;images&#39;):<br>    # load image<br>    img_data = image.imread(&#39;images/&#39; + filename)<br>    # store loaded image<br>    loaded_images.append(img_data)<br>    print(&#39;&gt; loaded %s %s&#39; % (filename, img_data.shape))</pre><p>To save images to a file we can use the the <em>save()</em> function. It’s useful when we want to save the image in a different format (PNG, GIF or PEG):</p><pre>image = Image.open(&#39;circles.jpg&#39;)<br># save as PNG format<br>image.save(&#39;circles.png&#39;, format=&#39;PNG&#39;)<br># load the image again and inspect the format<br>image2 = Image.open(&#39;circles.png&#39;)<br>print(image2.format)</pre><p>Colour gives complexity to images, to the their processing and their coding. For example, RGB images are composed of three independent channels for red, green and blue primary colour components, CMYK images have four channels for cyan, magenta, yellow and black ink plates, etc. When we don’t need colour (as in my case), colour might be considered as noise. So simplifying to grayscale means saving processing time and code complexity. To do this we can call the <em>convert()</em> function provided by Pillow:</p><pre># the mode ‘<em>L</em>‘ will convert an image to grayscale<br>grey_image = image.convert(mode=&#39;L&#39;)<br># save in jpeg format<br>grey_image.save(&#39;circles_grayscale.jpg&#39;)<br># load the image again and show it<br>image2 = Image.open(&#39;circles_grayscale.jpg&#39;)<br># show the image<br>image2.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fbk0kS0i8hzW1kNacCnBjw.jpeg" /><figcaption>‘circles_grayscale.jpg’</figcaption></figure><p>Another useful thing before modeling is to resize the image. When we want to achive the same width and height for thumbnails, the <em>thumbnail()</em> function takes a tuple with the width and height and resizes it to a given parameter:</p><pre># report the size of the image<br>print(image.size)<br># create a thumbnail and preserve aspect ratio<br>image.thumbnail((100,100))<br># report the size of the thumbnail<br>print(image.size)</pre><p>The other very useful function is the <em>resize()</em> function where you can specify the width and height in pixels to fit the image a new shape:</p><pre># report the size of the image<br>print(image.size)<br># resize image and ignore original aspect ratio<br>img_resized = image.resize((200,200))<br># report the size of the thumbnail<br>print(img_resized.size)</pre><p>Not having enough number of images may lead to insufficient data to process by a Machine Learning Algorithm. In order to increase the number of images we might want to use some simple data augmentation. We can crop, flip, zom or rotate our images. So here are some basic manipulations:</p><p>To flip image we can call the <em>flip()</em> function:</p><pre>image = Image.open(&#39;circles.jpg&#39;)<br># horizontal flip<br>hoz_flip = image.transpose(Image.FLIP_LEFT_RIGHT)<br># vertical flip<br>ver_flip = image.transpose(Image.FLIP_TOP_BOTTOM)<br># plot all three images using matplotlib<br>pyplot.subplot(311)<br>pyplot.imshow(image)<br>pyplot.subplot(312)<br>pyplot.imshow(hoz_flip)<br>pyplot.subplot(313)<br>pyplot.imshow(ver_flip)<br>pyplot.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*S57RqSSwB0yi8CSwLegyVA.png" /><figcaption>Flipped images</figcaption></figure><p>The<em> rotate() </em>method takes number of degrees as a parameter and rotates the image in counter clockwise direction to the number of degrees specified:</p><pre># plot original image<br>pyplot.subplot(311)<br>pyplot.imshow(image)<br># rotate 45 degrees<br>pyplot.subplot(312)<br>pyplot.imshow(image.rotate(45))<br># rotate 90 degrees<br>pyplot.subplot(313)<br>pyplot.imshow(image.rotate(90))<br>pyplot.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*mhDACjmHqcfNF_1oVq6INA.png" /><figcaption>Rotated image</figcaption></figure><p>Now that I know how to import an image using Pillow and a few basic manipulations with it, I hope to increase the number of my raw data to be able to use it on a later project.</p><p>If you are still with me and interested in the above picture, please find it here:</p><p>The above picture was taken in summer 2018 in Mongolia. As you can see, it was made in a countryside, it shows a car, a standing alone person and 12 circle like objects (maybe 3 more). These objects are Xiongnu burial mounds around 100 BC to 100 AD. More precise information can be given after an archaeological excavation and further research. The photo was taken by me with a DJI Phantom Pro Drone, and here you can see how this exact territory looks on Google Earth:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-SY1EXV6H3Cjk2MKxPxAA.png" /><figcaption>Hard to spot the burials</figcaption></figure><p>As I wrote in earlier posts, Mongolia is huge, number of archaeologists is relatively small to the territory, and archaeological research is difficult due to landscape and vast land. It’s very hard to find new archaeological sites to protect them from legal and illegal miners or from “treasure hunters”. Usually they just dig up a big hole in hope to find gold or silver burial objects, scatter the things they think valueless (like human and animal bones, ceramics and wooden objects), then leave the hole open. This kind of damage is irreversible, all it’s information about the past is lost, or very difficult to recollect.</p><p>If we could find new archaeological sites by satellite pictures, maybe we could prevent illegal excavations, conduct a professional research or preserve them for future generations. Here you can see a rescue excavation done by Mongolian archaeologists before opening a mining site:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lErP_DKEHXYBQJ754GvcBg.jpeg" /><figcaption>An excavated burial place</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KXqYgM4IJzU2gurS51CxqQ.jpeg" /><figcaption>From 20 meters above</figcaption></figure><p>Thank you for reading and please let me know if you have any further questions.</p><p>References:</p><p><a href="https://pillow.readthedocs.io/en/stable/handbook/index.html">Pillow Handbook</a></p><p><a href="https://machinelearningmastery.com/how-to-load-and-manipulate-images-for-deep-learning-in-python-with-pil-pillow/">Machinelearningmastery.com</a></p><p><a href="https://pythontic.com/image-processing/pillow/rotate">Pythonic</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e19bdc57934" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/image-preprocessing-with-pillow-1e19bdc57934">Image preprocessing with Pillow</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[What is p-value? (The Pufi version)]]></title>
            <link>https://medium.com/@mina_77131/what-is-p-value-the-pufi-version-da2b36e5de22?source=rss-27b96db2e3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/da2b36e5de22</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[p-value]]></category>
            <category><![CDATA[alpha]]></category>
            <category><![CDATA[null-hypotheses]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mina Jambajantsan]]></dc:creator>
            <pubDate>Tue, 10 Dec 2019 13:59:40 GMT</pubDate>
            <atom:updated>2019-12-18T14:10:33.579Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is p-value? (A cat version)</h3><p>Everyone who is studying Data Science most certainly must have come across the P-value.<br>But what does p-value mean? And what is it? How do we know about it? What does it tell you? Is it a number? Or a line? Or an area? Or just a definition of something statisticians love to scare you away? Well, surely not the last one, but we definitely have to come clear with p-value, otherwise we will have difficult time understanding our data.</p><p>Table of content:<br>1. Introduction<br>2. Confidence level, Null Hypothesis and Alternative Hypothesis<br>3. P-value<br>4. Sir Ronald Fisher<br>5. P-hacking<br>Summary</p><ol><li>Introduction</li></ol><p>Wikipedia says that “In <a href="https://en.wikipedia.org/wiki/Statistical_hypothesis_testing">statistical hypothesis testing</a>, the p-value or probability value is the probability of obtaining test results at least as extreme as the <a href="https://en.wikipedia.org/wiki/Realization_(probability)">results actually observed</a> during the test, assuming that the <a href="https://en.wikipedia.org/wiki/Null_hypothesis">Null Hypothesis</a> is correct.” Does this definition help us understand p-value? Maybe, but my English language knowledge (or lack of it) doesn’t help in this case. Sounds very dry, very not “sinking in”-ish. Or when I try to take it “lightly”, it sounds like a mysterious mission given by a wise man in a video game.</p><p>So let me understand it in terms of cats. Cats are my favourite, many people’s favourite, they are fluffy, and loving, and cute. Please let me introduce my Pufi, and let’s assume I’m trying to find out if Pufi is overweight by finding that p-value I’m looking for. Let’s assume the definition of overweight cat is anything more than 8kg:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0rp5tKWh1DmDwlbiUWyv8g.jpeg" /><figcaption>Pufi</figcaption></figure><p>To clarify in the beginning that sometimes p-value is also written as <em>p</em> <em>value</em>, P value or p value, and they all are fine, so for now let’s stick with “p-value”.</p><p>In order to understand p-value, we need a basic understanding of confidence level (Greek letter alpha, 𝛼), Null and Alternative Hypotheses. These definitions are essential in order to understand our mission.</p><p>2. What is confidence level, aka alpha (𝛼)? What about Null Hypothesis and Alternative Hypothesis?</p><p>So alpha, or 𝛼 is our threshold which indicates us if our finding is extreme or not, in other words if our data (weight of Pufi) is rare or not. The common 𝛼 values are 0.05 and 0.01, meaning that for a significance level of 0.05, expect to have sample means in the critical region of 5% when Null Hypothesis is reject able. We can set our 𝛼 to any number we feel needed, but we will use the usual given value of 0.05. We need to set our alpha before doing the hypothesis tests, because if we will shift this number after the test, we will end in a deepest rabbit hole, and the more we will be messing with our test. But let’s talk about it later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*E1QHPDurVTcwDoZnCUKemw.jpeg" /><figcaption>source: <a href="https://xkcd.com/1478/">https://xkcd.com/1478/</a></figcaption></figure><p>In our case the Null Hypothesis (Ho) would state, that Pufi is statistically have the weight less than 10 kg, so she is not overweight and the Alternative Hypothesis (Ha) would state that she doesn’t have that average weight (so she is larger than 10 kg). Out in the normal world the Hypothesis Testing means testing relationship of A and B, or has A effect on B. We always start by the presumption of innocence which is the <a href="https://en.wikipedia.org/wiki/Legal_principle">legal principle</a> that one is considered innocent until proven guilty. So Null Hypothesis is always presuming that A does not have any effect on B, there is <strong>no significant</strong> relationship or difference between them, while the Alternative Hypothesis states the opposite. Only after rejecting the idea of Null Hypothesis we can try proving the Alternative Hypothesis.</p><p>Please note, that we are saying fail to reject the Null Hypothesis, and not accept the Null Hypothesis. The Null Hypothesis testing doesn’t allow us to accept or provide evidence that the Null is true with that data. We only failed to provide evidence that it’s false.</p><p>But how do we reject or accept the idea of Null Hypothesis?</p><p>Well, we need data! We will measure Pufi for a period of time (let’s say, for a week) in the same time with the same weight scale. Our data is: [8.4, 8.7, 7.8, 7.0, 7.7, 8.5, 8.3].</p><p>Here comes the p-value. The p-value is the probability of getting this sample of weights, given the Null Hypothesis is true. As the weights look too high for a cat who actually weights 8kg, we expect that the Null Hypothesis might be wrong. The probability of getting this sample of weights(the p-value) is probably pretty low if this cat actually weights 8 kg! But is the sample high enough to reject the Null Hypothesis? This is where we do the maths, to figure out the actual p-value is! If it’s lower than 0.05, then we can reject the Null Hypothesis at this level.</p><p>The p-value shows us, that if we take a sample test over and over again, and if we have a p-value of less than 0.05 (which is 5%) we can state that we have sufficient evidence to allow us to reject the idea of Null Hypothesis being true. This means that our test is statistically significant, so it is unlikely to happen <strong>just by chance alone</strong>. So, by this the p-value of 0.049 is just good enough as p-value of 0.0049, because both are under the 𝛼 level we set before the test, and both are letting you reject the idea of Null Hypothesis being true. Although the p-value is not giving us straight answer if this or that hypothesis is true, or how much this or that hypothesis is more significant.</p><p>3. So, if p-value is a number, then it is between 0 and 1.</p><p>· A small <em>p</em>-value (typically ≤ 0.05) indicates strong evidence against the Null Hypothesis, so you reject the null hypothesis</p><p>· A large <em>p</em>-value (&gt; 0.05) indicates weak evidence against the Null Hypothesis, so you fail to reject the Null Hypothesis</p><p>· <em>p</em>-values very close to the cut-off (0.05) are considered to be marginal (could go either way)</p><p>But what is our p-value now? As a Data Scientist, we can use Python’s module for conducting <a href="https://www.statsmodels.org/stable/index.html">statistical tests </a>and data exploration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hAGX0doZ03KRau5SXETiyw.png" /></figure><p>And here is the summary we can have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uy7uvRYMXtfv8Rh-kkJG8A.png" /></figure><p>Here we can see lots of outcomes, but for now let’s just focus on the p-value which is basically zero, so we can reject the idea of Null Hypothesis, and our p-value is in the blue zone (see below):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*riw8VHEgtwWMajiVpoOsIA.png" /><figcaption>source: <a href="https://www.simplypsychology.org/p-value.html">https://www.simplypsychology.org/p-value.html</a></figcaption></figure><p>It seems very easy, it’s like saying yes or no (p-value lower than 0.05 or not), but there are still some errors cold occur.</p><p>Let’s talk about error Type I and Type II. Failing to reject the Null Hypothesis doesn’t mean there is no relationship or effect, but rather means we didn’t get enough evidence to say there is definitely one in our case. In our case it means we failed to reject the idea of Pufi being not overweight. On the side note, we are not allowed to generalize given our data on all calico cats. We can’t say that all calico cats are not overweight or overweight based on only a sample cat (Pufi). It’s like saying all men are the same (or women) based only on the sample of our exes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*32oVhTJ8z7pIvDFnqQji6g.jpeg" /><figcaption>Pufi is positive about the Null Hypothesis</figcaption></figure><p>In statistical hypothesis testing we might errors might occur, when we are rejecting the Null Hypothesis while it’s being true or accepting the Null Hypothesis when it’s not true.</p><p>Type I error means the False Positive error, also known as “false alarm”, resulting that a given condition exists. Type II error refers to False Negative error, when there is a condition met, but the test shows there is nothing. In our case it means that Pufi IS overweight while not being so (False Positive) or being NOT overweight while being so (False Negative). It doesn’t seem like a big deal in case of a cat, but think about being pregnant, having cancer or having a fire in the house (and not knowing about it — Type II error), or having tons of vitamins or worrying all the time (believing we are lack of vitamins, or assuming the worst — Type I error). What we want to see is the True Positive or the True Negative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*SM0dM45czfrOuDwqshw8ZQ.png" /><figcaption>source: <a href="https://towardsdatascience.com/machine-learning-an-error-by-any-other-name-a7760a702c4d">https://towardsdatascience.com/machine-learning-an-error-by-any-other-name-a7760a702c4d</a></figcaption></figure><p>And this how they would look like when there are multiple comparisons:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*vtvK-QE6L7425nCv5a333w.jpeg" /><figcaption>source: <a href="https://stats.stackexchange.com/questions/307568/type-i-error-in-research-what-is-the-alpha-of-a-study-especially-when-there-are?rq=1">https://stats.stackexchange.com/questions/307568/type-i-error-in-research-what-is-the-alpha-of-a-study-especially-when-there-are?rq=1</a></figcaption></figure><p>Alright, you might say, but how do we know about this p-value? Where did it come from? Who said it must be 0.05?</p><p>4. Well, it came from Sir Ronald Fisher, a British statistician in the early 1900’s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ad68Ih2T5PQ_XZI7xbmmQ.jpeg" /><figcaption>source: <a href="https://blogs.adelaide.edu.au/special-collections/2017/02/17/ra-fisher/">https://blogs.adelaide.edu.au/special-collections/2017/02/17/ra-fisher/</a></figcaption></figure><p>Ronald Fisher had a randomised experiment called “<a href="https://en.wikipedia.org/wiki/Lady_tasting_tea">lady testing tea</a>”, involving fellow scientist lady, Muriel Bristol and 8 cups of teas with milk. The experiment started with the lady’s declining a cup of tea, because Fisher poured the tea first, and then the milk. She stated that she can identify by test which tea had been poured the tea first and then the milk, or the other way around (which she preferred). So, for the experiment he poured 4–4 cups of tea (milk first, then tea and tea first, then the milk), she guessed all the 8 cups right, meaning there were 70 possible orders. This means the probability that she has guessed right would be 1 in 70! Which equals the p to 1/70 = 0.01428571. Please see the Wikipedia page for details, it is really interesting.</p><p>So, since Fisher’s experiment based on 8 cups of teas we are determining if a result is meaningful or not. The p-value of 0.05 means it is 1 in 20 odds that we can reject the Null Hypothesis. But as Fisher said in his book: “It is usual and convenient for experimenters to take 5 per cent as a standard level of significance, in the sense that they are prepared to ignore all results which fail to reach this standard, and, by this means, to eliminate from further discussion the greater part of the fluctuations which chance causes have introduced into their experimental results.” Later his preference became the golden standard, but let’s not forget, that Sir Fisher decided on the value of p because it’s “usual and convenient”, which pops the question: “What is the difference in significance in result with p-value of 0.049 or another result with p-value of 0.051?” (beyond the obvious 0.02).</p><p>5. And here we come to the issues with p-value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*gCuDivIyTo3LSJrX__o9pQ.jpeg" /><figcaption>source: <a href="http://www.outwardon.com/article/the-science-behind-darth-vader/">http://www.outwardon.com/article/the-science-behind-darth-vader/</a>, although don’t blame the for the poor design of the text. That was me.</figcaption></figure><p>As we said earlier, the p-value must be lower than the alpha we set before the test. And there is debate over the alpha, some state that it should be set depending on the situation, for example set lower for medical tests (which is perfectly makes sense, because people’s life on the stake).</p><p>The other issue with p-value is that it shows how extreme is your data if you assume the Null Hypothesis, but it doesn’t tell you if the Null Hypothesis is correct or probably correct. It’s hard to absorb, because in the beginning of our test we assumed for a moment, the Null Hypothesis is correct.</p><p>Also there is an issue called p-hacking. As you can assume it’s about falsifying the p-value in order to have a statistically significant test result. Why? Because tests are money and time, also academic journals will not publish articles about not significant results saying “actually we don’t have convincing evidence about this, but also we don’t have enough convincing evidence that it’s not”. However, if everything was done right, all the the tests are correct, even “not finding anything significant’ is still a finding in my opinion, because it means you found that something is not there! During an excavation this result is perfectly explainable and rarely, but happens (that’s another topic), when due rescue excavations you have an archaeological site with 7 burials in total, spend weeks working on them, document everything, and end up having partial findings just in one single burial pit. It is still a great job, if we don’t conduct the excavation we would never know what is in there or what is not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XU9urcwwSCHGb_1lEBpWtg.jpeg" /><figcaption>Mongolia</figcaption></figure><p>So, p-hacking means when analyses are being chosen based on what makes the p-value go wild and not on what’s the best analysis plan. Or it means manipulating with your data. Or manipulating the degree of freedom. Or stop collecting data or still trying to collect data which will give the needed result. Sometimes it might be just a mistake, but it can be intentional as well. Anyhow it’s happening, it means false results. As a research saying “By simply manipulating researcher degrees of freedom, even absolutely negative data can produce a p-value under 0.05 an incredible <a href="http://pss.sagepub.com/content/22/11/1359.full">61%</a> of the time.”</p><p>Here we can see why no one wants green jelly beans (but handle this information with care, it’s only 5% probability that it’s true :) )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*IgmbwlLTYwpIdvV5wbg3eA.png" /><figcaption>source: <a href="https://xkcd.com/882/">https://xkcd.com/882/</a></figcaption></figure><p>In my case it might just show that Pufi is not overweight, and I would end up feeding her more, and she would end up on diet at Christmas. But on a big scale out in the world it might mean supporting nasty things like flat Earth “theory” or anti vaccination “studies” (I know, it’s very extreme, but in many cases it may result diminish the public’s belief in science).</p><p>How to prevent p-hacking?</p><p>1. Plan ahead, decide your tests and parameters beforehand, and if you will need to make changes, report them</p><p>2. Declare how many times you are going to run a specific test. And do not stop earlier just because you have reached the desired p-value (or do not continue if you haven’t received it)</p><p>3. Decide when to stop collecting data</p><p>4. Decide what your outliers will be, know which values/features/results are being outliers (outliers in our case would be Pufi weight of 10 kg or 6 kg which could mean that the scales are broken, or she is cheating somehow)</p><p>5. Your results must be replicable and correct for multiple comparisons</p><p>6. If you have found something way more interesting than the original proposal, test the new hypothesis again under new terms/tests/conditions to get a true p-value</p><p>Summary:</p><ul><li>Before the Hypothesis tests we declare our confidence level, the 𝛼,(usually 0.05 or 0.01)</li><li>First we assume that the Null Hypothesis is the true distribution</li><li>Then we calculate how often we see our data</li><li>In probability terms p-value answers the question how rare your data is by telling you the probability getting the data as extreme as you observed if the Null Hypothesis was true</li><li>If it’s a number, it’s between 0 and 1, and it’s better the lower it is</li><li>If it’s under 0.05, you can state that your finding is statistically significant</li><li>The p-value is not giving us the probability we want, it’s only a statistical method used by the <strong>frequentist approach to probability</strong> that will give us the <strong>probability of a hypothesis given our data</strong></li><li>The p-value might tell us to reject the idea of Null Hypothesis but will not say how right is the Alternative Hypothesis</li><li>Do not do p-hacking, just don’t</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NCdp66aObAdsIMz1LIhE4A.jpeg" /></figure><p>Thank you all for reading, please accept a picture of Pufi enjoying an early morning sun</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da2b36e5de22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Folium, Matplotlib, Geopanda Maps]]></title>
            <link>https://medium.com/@mina_77131/folium-matplotlib-geopanda-maps-cf503d27c97a?source=rss-27b96db2e3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf503d27c97a</guid>
            <category><![CDATA[folium]]></category>
            <category><![CDATA[basemap]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[geopandas]]></category>
            <category><![CDATA[matplotlib]]></category>
            <dc:creator><![CDATA[Mina Jambajantsan]]></dc:creator>
            <pubDate>Mon, 28 Oct 2019 20:48:52 GMT</pubDate>
            <atom:updated>2021-02-08T14:46:49.250Z</atom:updated>
            <content:encoded><![CDATA[<p>Maps using Folium, Matplotlib and Geopanda</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JV-liQv_Va530pu6_5Qe4g.jpeg" /><figcaption>Image by Nasa</figcaption></figure><p>Three ways to create great maps with Python libraries</p><p>Probably many aspiring Data Scientists familiar with the King County house sales dataset. This dataset contains records of 21,613 houses sold in King County between May 2014 and May 2015. The dataset also contains 21 different variables such as price, GPS coordinates, zip code, number of bedrooms, area of the living space, area of the lot, number of views, and so on, for each house.</p><p>Data visualising is essential in order to have a better overview of our data. It makes the data more accessible, understandable and usable (<a href="https://en.wikipedia.org/wiki/Data_visualization">https://en.wikipedia.org/wiki/Data_visualization</a>). We have access to many kinds of tools starting with simple bar charts, scatter plots to more complex ones like a 3D graph.</p><p>In this post I will show maps made using Folium, Matplotlib and GeoPanda.</p><p>First, let’s import all our necessary libraries:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3329eef12fcda7e0ad9ba8ecbfbcab96/href">https://medium.com/media/3329eef12fcda7e0ad9ba8ecbfbcab96/href</a></iframe><p>After loading the dataset, cleaning the necessary columns and data, it’s important to check the credibility of given data. We might not be able to check columns like price, number of bathrooms or year of renovation, but for example we can check if the waterfront houses are indeed on the waterfront. First, we will create a waterfront DataFrame, then use the Folium Library to mark those houses.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95c6372e43f45a1288894a17bfa41483/href">https://medium.com/media/95c6372e43f45a1288894a17bfa41483/href</a></iframe><p>We can apply different tiles for Folium: <a href="https://python-graph-gallery.com/288-map-background-with-folium/">https://python-graph-gallery.com/288-map-background-with-folium/</a>, here I have used the OpenStreetMap:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*RZVjelmTCsj2GypBJ1TdUQ.png" /></figure><p>It looks like our data is valid, although if we want to be thorough, we might want to check the waterfront column more carefully (Null values).</p><p>Also if you would like to upgrade your map, so it will show the price and sqft of living space, you could use the popup markers:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6fd4a063dd7170063799fe98c5f411c/href">https://medium.com/media/f6fd4a063dd7170063799fe98c5f411c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9VQVKhkkUBcjVXu7IlATJA.png" /></figure><p>The Folium Library gives us the opportunity of another great maps as cluster maps or heat map. I will use an interactive cluster map to observe the location of the most expensive top 25% of houses sold that year. We could have a closer look at each marker, but this cluster map makes more sense, if we use it as a density map to locate areas with larger number of expensive houses. If we would be looking for an expensive area to move, this map can give us a hint which area to look at. First, we need to determine the top 25%, create a DataFrame for these houses, and plot a new map:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ce7d1124c0627dca24a26c66ff2b11d/href">https://medium.com/media/3ce7d1124c0627dca24a26c66ff2b11d/href</a></iframe><p>Which looks like this (given in series as you zoom in):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UB_64eHON3uo38_VoU-X8Q.png" /></figure><p>On the first image we can see the total number of expensive houses (top 25%).</p><p>The second image shows us 2 large areas with 2096 and 2715 houses, also the blue line indicates the area for the given number of houses. The last two images are zoomed in. A quick note for this kind of interactive cluster map: loading more than 5–6 000 points most likely will slower down your computer, and may take longer time for it to process.</p><p>Let’s move on to Matplotlib. We can have many useful information on Matplotlib starting from documentation to tutorials on their official website: <a href="https://matplotlib.org/">https://matplotlib.org/</a>.</p><p>Since we have date of built of the sold houses, using this library I would like to show how the city of Seattle was expanding over the years.</p><p>The first house according to our dataset was built in 1900, and the last one was built in 2015. Before the World War II we can see a big decline in the industry, and then a steady growth, and then again, a slight decline in 1980s.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/493a9af131c63788c0f113cae68e07fe/href">https://medium.com/media/493a9af131c63788c0f113cae68e07fe/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*Pns92muOvdyIdBxng0g1nQ.png" /></figure><p>Using this frequency map, I have separated 3 big periods:</p><p>1. Houses built from 1900 to 1940</p><p>2. Houses built from 1940 to 1980</p><p>3. Houses built from 1980 to 2015</p><p>Here I have converted the 3 periods into 3 bins:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e22b3e75b8c5ed53e4f9cae8da5bfe31/href">https://medium.com/media/e22b3e75b8c5ed53e4f9cae8da5bfe31/href</a></iframe><p>And created a map using Matplotlib. This code is for the general map where all 3 periods are on one map:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92eb5df0a7149b46795d36c690483af3/href">https://medium.com/media/92eb5df0a7149b46795d36c690483af3/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*E0MwZOQyiPHuXutKcVpQ4w.png" /></figure><p>Please note, that I have given the alpha=0.2 for the last two bins in order to make the a little bit more transparent, so we can see the early period as well. And here the map with the subplots:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/390f6765836d22d9b8d2d9791f047e02/href">https://medium.com/media/390f6765836d22d9b8d2d9791f047e02/href</a></iframe><p>Plotting all 4 maps (1 general map with all periods + 3 separate periods), we can see how the town was spreading through the years:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlVD5wjzde6zqhWJwGOkmw.png" /></figure><p>Using GeoPandas we can make the general map even more detailed. Here is a great tutorial which helped me a lot: <a href="https://towardsdatascience.com/geopandas-101-plot-any-data-with-a-latitude-and-longitude-on-a-map-98e01944b972">https://towardsdatascience.com/geopandas-101-plot-any-data-with-a-latitude-and-longitude-on-a-map-98e01944b972</a>.</p><p>For this map I have reversed the plotting of houses by years, because as we can see from our previous maps, the area of historic houses is much smaller, as the next generation of houses. In order to use a basemap we need to install Descartes and GeoPandas, import them, and use shapefiles, which you will need to download:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1e460c5acf3e2ac444e7bc823ac76f2/href">https://medium.com/media/d1e460c5acf3e2ac444e7bc823ac76f2/href</a></iframe><p>Don’t forget to give the Coordinate Reference System (CRS) as epsg:4326 in order to secure our base map. See more about CRS here: <a href="https://www.nceas.ucsb.edu/~frazier/RSpatialGuides/OverviewCoordinateReferenceSystems.pdf">https://www.nceas.ucsb.edu/~frazier/RSpatialGuides/OverviewCoordinateReferenceSystems.pdf</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2782b2d57ce2d5227e089965af6d5730/href">https://medium.com/media/2782b2d57ce2d5227e089965af6d5730/href</a></iframe><p>And here we can see the added geometry column with individual points for each row:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CN9D4nURKibKG-QDoA4_ZA.png" /></figure><p>Last, but not least, let’s plot the “Houses built by years” map with a basemap:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d42ae7e25b1796e37aaf0e0c65e40cd/href">https://medium.com/media/3d42ae7e25b1796e37aaf0e0c65e40cd/href</a></iframe><p>And we can have our last map where we can the growth of Seattle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bKeNsiRoHQQlXbHs6rZSfw.png" /></figure><p>I hope you found this post useful and it helps you working with these great Python libraries.</p><p>And if you are still with me, as a bonus, may I bring to your attention a professional map building software, the QGIS, a Free And Open Source Geographic Information System: <a href="https://www.qgis.org/en/site/">https://www.qgis.org/en/site/</a></p><p>From the many useful things QGIS can help you to create, I was able to make a contour map from an elevation map of this beautiful 10–11th century Khitan town remains with 17th century Buddhist Monastery buildings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GR91T4C3HNBwtb7PJtOH1A.png" /></figure><p>And the contour map:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*8VQFziabw51Fvq3f3pbQ5g.jpeg" /></figure><p>Sources:</p><p>Data Vizualisation:<br><a href="https://en.wikipedia.org/wiki/Data_visualization">https://en.wikipedia.org/wiki/Data_visualization</a></p><p>Map backgrounds with Folium:<br><a href="https://python-graph-gallery.com/288-map-background-with-folium/">https://python-graph-gallery.com/288-map-background-with-folium/</a></p><p>Matplotlib:<br><a href="https://matplotlib.org/">https://matplotlib.org/</a></p><p>GeoPandas tutorial:<br><a href="https://towardsdatascience.com/geopandas-101-plot-any-data-with-a-latitude-and-longitude-on-a-map-98e01944b972">https://towardsdatascience.com/geopandas-101-plot-any-data-with-a-latitude-and-longitude-on-a-map-98e01944b972</a></p><p>Coordinate System Reference: <a href="https://www.nceas.ucsb.edu/~frazier/RSpatialGuides/OverviewCoordinateReferenceSystems.pdf">https://www.nceas.ucsb.edu/~frazier/RSpatialGuides/OverviewCoordinateReferenceSystems.pdf</a></p><p>QGIS:<br><a href="https://www.qgis.org/en/site/">https://www.qgis.org/en/site/</a></p><p>Khitan town ortophoto:<br>Drone photos were made by me and later “stitched” to an orthomap for the elevation map</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf503d27c97a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Archaeology and Data Science]]></title>
            <link>https://medium.com/@mina_77131/why-i-am-learning-data-science-9076a4123ced?source=rss-27b96db2e3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/9076a4123ced</guid>
            <category><![CDATA[archaeology]]></category>
            <category><![CDATA[inner-asian-studies]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mina Jambajantsan]]></dc:creator>
            <pubDate>Mon, 14 Oct 2019 11:14:51 GMT</pubDate>
            <atom:updated>2021-02-08T14:42:40.014Z</atom:updated>
            <content:encoded><![CDATA[<p>Possibilities of Data Science in Archaeology</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2N8mMPv2MqZaSdiQmiXNqw.jpeg" /><figcaption>Mongolia, Bulgan aimag, Khar Bukh Khitan age town (10th Century) with a 17th Century Buddhist Monastery</figcaption></figure><p>In 2012 Data Science was proclaimed as “The Sexiest Job of the 21st Century” (Davenport, Thomas H., and D.J. Patil, 2012). Since the last 5 years Data Science as a career opportunity became one of the most sought after in this decade. A lot of professionals with background in Math, Business, Computer Science or Statistics are aspire to be Data Scientists, which is absolutely reasonable. Most of them have the required domain and programming knowledge including a fair amount of statistics and mathematics.</p><p>“But what brings me, the Archaeology and Inner Asian Studies PhD student to this shiny new field where everything seems to be so technical and modern?” Data Science is the job of the future, done in glamorous skyscrapers in the middle of the city, predicting big business analyses, developing Machine Learning Algorithms. And here I am, with an affinity for reading in a quiet library with dusty old books, cherishing ancient broken objects, and enjoying working somewhere at the end of the world in the middle of the big nowhere with no Wi-Fi, minimal electricity and no bathrooms. Well, the last part I don’t enjoy so much, but that’s part of the job.</p><p>I believe that Archaeology could gain a lot from modern technology and shouldn’t be stuck in the past similarly to the objects we are studying. A lot of archaeologists from all over the world are using LIDAR technology, geophysics, drones, underwater drones and many more technological inventions and innovations of the modern age. Drone usage is now a common practice at excavations. We are able to take pictures from above without using small planes or helicopters as it was at the dawn of Aerial Archaeology. Planes would require a professional pilot, tons of fuel, great cameras and a very strong stomach (not to fall out of the open plane or not get seasick from the ups and downs). With LIDAR-s we can have a “peek” at what’s under the ground without disturbing the soil, but this technology has a high price. Appearance of drones gave us a whole new perspective to our field of research:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3-yEf3o6i1zUMBtq8vOr4Q.jpeg" /><figcaption>Mongolia, Bulgan aimag, Kheregsur (tomb), Bronze age</figcaption></figure><p>For now I’m planning to use Data Science methods on exploring two main things :</p><p>Firstly, I would like to finish my PhD thesis about Medieval (11th — 13th Century) burials in Mongolia according to written sources and modern archaeological excavations. If you wonder why this period, then this was the time of the Mongolian Empire and Genghis Khan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IY0fP8OmysZDgRZdsb5-hQ.jpeg" /><figcaption>Mongolian Empire</figcaption></figure><p>I could use Data Science to tidy up my data, which sounds like a show off instead of using good old Excel, but with a massive data number (though not as massive as a small business data), loads on Nan data and more than 20 columns, using Python and Pandas will allow me less inaccuracy. Also, the graphic visualisation of the given data will be more clear and efficient. I’m hoping to see new patterns I might have missed, also later make my findings and thesis outcomes more understandable.</p><p>The second reason I’m learning Data Science is to be able to process information on given photos, especially drone photos or maps.</p><p>Here I have a nice Orthophoto of a 5th century BC Xiongnu cemetery where we can observe a car on the top of the picture, a Mongolian family’s yurt on the right bottom corner and lots of lots of circles. Please excuse the shape of the map, the drone photos were taken manually, and not by a usual program I would use (like Maps Made Easy) due lack of internet required for exact GPS coordinates, etc. Pictures were made by a DJI Phantom Pro drone on height of 100 meters, and later “stitched” into an Orthomap on ArcGis program.</p><p>Every stone circle here is a tomb. I believe there are about 200 of them in the span of 100 years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qiqeprJJU8e_5ltRlhcgow.jpeg" /><figcaption>Mongolia, Bulgan aimag, Xiongnu cemetery, 5th century BC</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cXHIa4TYxmTLrsfPR3a35w.png" /><figcaption>Closer look of the tombs</figcaption></figure><p>My goal with this map is to be able to identify as much tombs as I can with Machine Learning. I would like to be able to feed an algorithm of stone circles (tombs) to a Machine and be able to have a more detailed analysis of this map. A few questions, but not all, like how many circles are there; what is the diameter of them; what is the average/minimum/maximum diameter; what is the condition of the tomb (how dark or light is the colour of the circle, or how well expressed the circle is), what is the distance between them?</p><p>The further outcome of this project could help to identify archaeological objects from distance, I even dream about being able to discover objects on satellite images. This would greatly improve life of archaeologists in sparsely populated countries like Mongolia (1.566.000 km2, population of 3.256.176, with density of 1.97/ km2), or inhabitant and difficult to access areas like vast plateaus and Siberia.</p><p>The algorithm could be used on later projects and would help identifying and counting different objects and shapes.</p><p>I strongly believe this can be used not only in Archaeological field, but mining or any field/terrain related tasks.</p><p>References:</p><p>Davenport, Thomas H., and D. J. Patil. <a href="http://hbr.org/2012/10/data-scientist-the-sexiest-job-of-the-21st-century/">“Data Scientist: The Sexiest Job of the 21st Century.”</a> <em>Harvard Business Review</em> 90, no. 10 (October 2012): 70–76.</p><p>Map: <a href="https://www.britannica.com/place/Mongol-empire/The-period-of-relative-unity-1227-60">https://www.britannica.com/place/Mongol-empire/The-period-of-relative-unity-1227-60</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9076a4123ced" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>