Monday, 17 December 2018

Learnings

Welcome to the first post on Artificial Intelligence. In this post, we will see the different "learnings" and related terms in vogue today in the area of Artificial Intelligence:

Artificial Intelligence: Per this link, Artificial intelligence or AI is the simulation of human intelligence processes by machines, especially computer systems. These processes include learning (the acquisition of information and rules for using the information), reasoning (using rules to reach approximate or definite conclusions) and self-correction. Particular applications of AI include expert systems, speech recognition and machine vision

Machine Learning: According to this link, Machine Learning is an application of Artificial Intelligence of getting computers to learn and act like humans do, and improve their learning over time in autonomous fashion, by feeding them data and information in the form of observations and real-world interactions.

Supervised Learning: According to this link, Supervised Learning is the machine learning task of learning a function that maps an input to an output based on example input-output pairs. It infers a function from labeled training data consisting of a set of training examples. In supervised learning, each example is a pair consisting of an input object (typically a vector) and a desired output value (also called the supervisory signal). A supervised learning algorithm analyzes the training data and produces an inferred function, which can be used for mapping new examples. An optimal scenario will allow for the algorithm to correctly determine the class labels for unseen instances.

Classification: According to this link, Classification is the problem of identifying to which of a set of categories (sub-populations) a new observation belongs, on the basis of a training set of data containing observations (or instances) whose category membership is known. Classification is considered an instance of Supervised Learning.

Regression Analysis: Regression Analysis is widely used for prediction and forecasting, where its use has substantial overlap with the field of machine learning. Regression Analysis is also used to understand which among the independent variables are related to the dependent variable, and to explore the forms of these relationships. Regression Analysis is also considered an instance of Supervised Learning.

Unsupervised Learning: Per this link, Unsupervised learning is a branch of machine learning that learns from test data that has not been labeled, classified or categorized. Instead of responding to feedback, unsupervised learning identifies commonalities in the data and reacts based on the presence or absence of such commonalities in each new piece of data.

Clustering: According to this link, Clustering is the task of grouping a set of objects in such a way that objects in the same group (called a cluster) are more similar (in some sense) to each other than to those in other groups (clusters). Clustering is considered an instance of Unsupervised Learning.

Semi-supervised Learning: Between Supervised Learning and Unsupervised Learning lies Semi-supervised Learning. According to this link, Semi-supervised learning is a class of machine learning tasks and techniques that also make use of unlabeled data for training – typically a small amount of labeled data with a large amount of unlabeled data.

Deep Learning: Per this link, Deep Learning is part of a broader family of machine learning methods based on learning data representations, as opposed to task-specific algorithms. Learning can be supervised, semi-supervised or unsupervised.  The "deep" in "deep learning" refers to the number of layers through which the data is transformed. More precisely, deep learning systems have a substantial credit assignment path (CAP) depth. The CAP is the chain of transformations from input to output. CAPs describe potentially causal connections between input and output. Most deep learning methods use neural network architectures.

Neural Network: According to this link, Neural Network is a system of hardware and/or software patterned after the operation of neurons in the human brain. Neural networks -- also called artificial neural networks -- are a variety of deep learning technology, which also falls under the umbrella of artificial intelligence, or AI.

Reinforcement Learning: According to this link, Reinforcement Learning (RL) is an area of machine learning concerned with how software agents ought to take actions in an environment so as to maximize some notion of cumulative reward.

Deep Reinforcement Learning: When Reinforcement Learning uses neural networks, it results in Deep Reinforcement Learning.

Feature Learning or Representation Learning: According to this link, Feature Learning or Representation Learning is a set of techniques that allows a system to automatically discover the representations needed for feature detection or classification from raw data. This replaces manual feature engineering and allows a machine to both learn the features and use them to perform a specific task.

Natural Language Processing: According to this link, Natural Language Processing (NLP) is a subfield of computer science, information engineering, and artificial intelligence concerned with the interactions between computers and human (natural) languages, in particular how to program computers to process and analyze large amounts of natural language data. Challenges in Natural Language Processing frequently involve speech recognition, natural language understanding, and natural language generation.

I will try and update if I come across any more points that can be added to this post

Wednesday, 28 November 2018

Raspberry Pi - II

In the second segment on Raspberry Pi, we introduce the camera module. Using the camera, one can click still pictures and also film events. In the first post on Raspberry Pi, we used Raspberry Pi 3 Model B. We will be using the same for all the work in this article as well. Using Python based picamera package, we can communicate with the camera in Raspberry Pi. The code for picamera is here. Documentation to latest picamera release that we will be using is here. It is assumed that a camera that is compatible with this model of Raspberry Pi is already attached. The attached camera is shown below:

























As a first step, we have to enable the camera software on the Raspberry Pi. So, navigate to Raspberry Pi icon --> Preferences --> Raspberry Pi Configuration --> Configure Raspberry Pi system as shown below:




















Then, click on enabled as shown below against Camera:


















Finally, it should look like as shown below:



















Then, click on OK. On the Reboot needed window click Yes:



















Once roboot is complete, login into Raspberry Pi, check version of picamera by running validate.sh that contains below code:

python3 -c "from pkg_resources import require; print(require('picamera')[0].version)"












In the first program in Python, we will see the different properties of the attached camera hardware. The program is shown below:


The output is shown below:

























Note that the default resolution is 720x480, and default value for hflip, and vflip is false. For more details of above properties that can be also set, please refer the documentation. In the next program, we will click a picture. We set a few properties like resolution, hflip, and vflip before clicking the picture and capture it in .jpg format as shown below:












Command to run above program is below:








The captured picture is shown below:




















In the same manner, we can also video record any event and play it in omxplayer in Raspberry Pi. This concludes the post on adding camera module to Raspberry Pi

Friday, 23 November 2018

Arduino - VI

We continue the discussion on Arduino. In the sixth post on Arduino, we add the time element to a temperature sensor reading and see the output in serial monitor. We will use the same environment as in the first post of this series

In the last post, by importing a library called TimeLib.h we added the time element to Arduino. For the temperature reading, we will add LM35 sensor. Details about the sensor is here.

The code is shown below:

#include <TimeLib.h>

int tempPin = 0;     // initialize the number of temperature sensor output data pin
int temp_reading;    // declare variable for temperature reading
float temp_celcius;  // declare variable for temperature reading

void setup() {
  Serial.begin(9600);  // initialize serial port
  setTime(1542982538); //The argument to setTime must be Unix time 
}

void loop() {
  temp_reading = analogRead(tempPin);
  temp_celcius = (temp_reading/1024.0)*500; 
  digitalClockDisplay();
  Serial.print(" : ");
  Serial.println(temp_celcius); //temperature in Celcius
  delay(5000);
}

void digitalClockDisplay(){
  // ref https://github.com/PaulStoffregen/Time
  // digital clock display of the time
  Serial.print(day());
  Serial.print("/");
  Serial.print(month());
  Serial.print("/");
  Serial.print(year()); 
  Serial.print(" ");
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
}

void printDigits(int digits){
  // ref https://github.com/PaulStoffregen/Time
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

The circuit is shown below:




















Upload above program into Arduino. The serial monitor output is shown below:



















This concludes the post on adding time element to a temperature reading in Arduino