Python

  • Part 3: Natural Language Processing – Sentiment Analysis and Opinion Mining

    If you remember in part 2 we discussed what Key Word Analysis is and how this can be implemented to gain deeper insight from textual data. But we can go one step deeper and extract feelings and opinions from the same data. We can do this through Sentiment Analysis and Opinion mining! In this blog I will talk you through what they are and how we can implement them using Microsoft’s Cognitive Services. What is Sentiment Analysis? We should…

    » Read more
  • Part 2 : Natural Language Processing- Key Word Analysis

    Here we are with part 2 of this blog series on web scraping and natural language processing (NLP). In the first part I discussed what web scraping was, why it’s done and how it can be done. In this part I will give you details on what NLP is at a high level, and then go into detail of an application of NLP called key word analysis (KWA). What is NLP? NLP is a form of artificial intelligence which deals with the interactions between humans…

    » Read more
  • Part 1: Web Scraping and Natural Language Processing- Web Scraping

    In this multi blog series I will go through what web scraping is, what Natural Language processing is as a general term as well as diving into some constituent techniques we are interested in; key word extraction, sentiment analysis and its derivative opinion mining. The last few parts will then go through a coded example of scraping the popular review site Trust pilot for reviews of the popular supermarket chain ‘Lidl’. We will then…

    » Read more
  • Creating a quadratic solver in Python

    In this blog post, I will be showing you how to create a python function that will solve any quadratic equation. Firstly, what is a quadratic equation? A quadratic is an algebraic equation that can be arranged as ax2 + bx + c = 0 where a, b, c are known and a ≠ 0. If a = 0 then the equation becomes linear as there isn’t a x2 term. Secondly, how to solve this equation? There are different ways to solves quadratic equations including: By…

    » Read more
  • Pandas; Why Use It And How To Do So!

    Introduction Hi and welcome to what will be my first frog blog! I’m Lewis Prince, a new addition to the Purple Frog team who has come on board as a Machine Learning Developer. My skill set resides mainly in Data Science and Statistics, and using Python and R to apply these. Therefore my blogs will be primarily on hints and tips on performing Data Science and Statistics through the medium of Python (and possibly R). I thought I would start…

    » Read more
  • How to create the Fibonacci Sequence in Python

    This blog post will go through how to create the famous Fibonacci sequence in Python. Each number in the Fibonacci sequence is the sum of the previous two terms. The sequence starts: 0, 1, 1, 2, 3, 5, 8, 13, … and carries on infinitely. The Python code I used is: The first two terms are entered into our list, then we specify the number of terms wanted in our sequence. Next, we loop through from 2 to the number of terms we wanted appending…

    » Read more
  • Join 2 Python lists together using nested loops

    In this blog post I will show you how to join two 2D Python lists together. The code is in the screenshot below. Lines 1 – 2 are two lists that are going to be joined, line 3 is an empty list where the output will be appended to. Lines 4 – 5 are two loops (one nested inside the other) which cycle through the records in both lists, line 6 checks whether the first items (index 0) in the two records from each list that are currently i…

    » Read more
  • How to delay a Python loop

    In this blog post, I will run through 3 different ways to execute a delayed Python loop. In these examples, we will aim to run the loop once every minute.To show the delay, we will print out the current datetime using the datetime module. 1 – SleepThe sleep function from Python’s time module pauses the Python execution by the number of seconds inputted. The example below pauses the script for 60 seconds. The above script has a 60 second…

    » Read more
  • Creating a Python function to calculate Pi

    Pi is 3.14159 to 5 decimal places.To work out Pi, we will be using Leibniz’s formula:X = 4 – 4/3 + 4/5 – 4/7 + 4/9 – …This series converges to Pi, the more terms that are added to the series, the closer the value is to Pi.For the proof on why this series converges to Pi – https://proofwiki.org/wiki/Leibniz%27s_Formula_for_PiThere are several points to note about the series: It’s infinite, we need to find a way to continue…

    » Read more