0% found this document useful (0 votes)
14 views21 pages

Notes 1

Wow

Uploaded by

biprajitroy481
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views21 pages

Notes 1

Wow

Uploaded by

biprajitroy481
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Data Analytics: Before going to describe data analysis, some mathematical tools need to be

known like mean, median, mode, standard deviation, mean deviation, variance, percentile,
correlation, bar chart, histogram plot, pie chart, scatter plot etc. based on which analysis can be
given. The tools are described below.
∑𝑛
𝑖=1 𝑥𝑖
Calculation of Mean: For some numbers 𝑥𝑖 , 𝑖 ∈ [1, 𝑛], 𝑚𝑒𝑎𝑛 = 𝑛

Calculation of Mean with frequencies: For some numbers 𝑥𝑖 , 𝑖 ∈ [1, 𝑛], with frequencies 𝑓𝑖 , 𝑚𝑒𝑎𝑛 =
∑𝑛
𝑖=1 𝑓𝑖 𝑥𝑖
∑𝑛
𝑖=1 𝑓𝑖

Calculation of mean with some approximate mean: For some numbers 𝑥𝑖 , 𝑖 ∈ [1, 𝑛], with frequencies
𝑓𝑖 , if the approximate mean is known (say A), then 𝑥𝑖 = 𝐴 + 𝑑𝑖 where 𝑑𝑖 is the difference of A from 𝑥𝑖 ,
∑𝑛
𝑖=1 𝑓𝑖 𝑥𝑖 ∑𝑛
𝑖=1 𝑓𝑖 (𝐴+𝑑𝑖 ) ∑𝑛 𝑛
𝑖=1 𝑓𝑖 𝐴+∑𝑖=1 𝑓𝑖 𝑑𝑖 ∑𝑛
𝑖=1 𝑓𝑖 𝑑𝑖
then 𝑚𝑒𝑎𝑛 = ∑𝑛
= ∑𝑛
= ∑𝑛
=𝐴+ ∑𝑛
𝑖=1 𝑓𝑖 𝑖=1 𝑓𝑖 𝑖=1 𝑓𝑖 𝑖=1 𝑓𝑖

Calculation of median: For some numbers 𝑥𝑖 , 𝑖 ∈ [1, 𝑛], at first we need to check whether n is even of
𝑥𝑛 +𝑥𝑛
+1
2 2
odd. If n is even then 𝑚𝑒𝑑𝑖𝑎𝑛 = . If n is odd then 𝑚𝑒𝑑𝑖𝑎𝑛 = 𝑥𝑛+1 .
2 2

Calculation of Mode: For some numbers 𝑥𝑖 , 𝑖 ∈ [1, 𝑛], the mode is the number which is repeated
maximum times in the sequence of 𝑥𝑖 .

Simple program for Mean calculation (with frequency 1):

Simple program for Mean calculation (with frequency greater than 1):
Simple program for Mean calculation (Using Numpy library):

Simple program for Median Calculation:

Simple program for Median Calculation (Using Numpy library):


Simple program for Mode Calculation:

Simple program for Mode Calculation (Using Statistics library):

Simple program for Mode Calculation (Using Scipy library):

∑𝑛
𝑖=1 𝑥𝑖
Calculation of Standard Deviation: For some numbers 𝑥𝑖 , 𝑖 ∈ [1, 𝑛], 𝑚𝑒𝑎𝑛 = . Standard
𝑛
∑𝑛
𝑖=1(𝑥𝑖 −𝑚𝑒𝑎𝑛)
2
Deviation, 𝑠𝑡𝑑 = √ .
𝑛

Simple Program for Standard Deviation Calculation:


Simple Program for Standard Deviation Calculation using Numpy library:

∑𝑛
𝑖=1 𝑥𝑖
Calculation of Variance: For some numbers 𝑥𝑖 , 𝑖 ∈ [1, 𝑛], 𝑚𝑒𝑎𝑛 = . variance, 𝑣𝑎𝑟 =
𝑛
∑𝑛
𝑖=1(𝑥𝑖 −𝑚𝑒𝑎𝑛)
2
.
𝑛

Simple Program for Variance Calculation:

Simple Program for Variance Calculation using Numpy library:


Calculation of Percentile: Percentile of an element is the percentage of the number of the elements which
are behind the element based on its rank.

Simple Program for Percentile Calculation:

Simple Program for Percentile Calculation using Numpy library:

Data Distribution: Consider a dataset which has random numbers between 0 and 10. Now we need to
segregate the number of numbers between 0 and 1, 1 and 2, 2 and 3 and so on. Here histogram plot can be
done to do so and this is called data analysis.

Simple Program for data distribution and plotting using Numpy and Matplotlib libraries: Here 10000
numbers have been generated between 0 to 10 and 50 plots have been shown.
Simple Program for normal or Gaussian distribution and plotting using Numpy and Matplotlib
libraries: Here 10000 numbers have been generated 10 with a scale of 1 and 50 plots have been shown.
Pie Chart for Data Analysis: Consider a banking feedback system where 4 comments are there:
“Excellent”,”Good”,”Fair”,”Bad”. Suppose total 120 people have given the feedback whose data is given
below.

Comment Excellent Good Fair Bad


No. of People 30 40 45 5

Scatter Plot for Data Analysis: Consider the equipments of an industry whose efficiency in terms of speed
changes with the ages.

Ages 1 2 3 4 5 6 7 8
Efficiency (in 96 93 90 85 80 75 71 65
terms of
RPM)

Now using these two parameters scatter plot can be designed for analysis.
Linear Regression using Scipy and Matplotlib Library: Consider car speed with respect to the ages.

Ages 5 7 8 7 2 17 2 9 4 11 12 9 6
Car Speed 99 86 87 88 111 86 103 87 94 78 77 85 86

From this data we need to predict the other car speed whose age is given but speed is unknown.
Here “r” is the correlation value. Now the year of an unknown car is given in the “line_graph()” function
then the predicted speed can be calculated.

Polynomial Regression:

Correlation: If x and y are two variables then the correlation between them can be given by the formula
shown below.

𝑛(∑𝑛𝑖=1 𝑥𝑖 𝑦𝑖 ) − ∑𝑛𝑖=1 𝑥𝑖 ∑𝑛𝑖=1 𝑦𝑖


𝜌=
[𝑛(∑𝑛𝑖=1 𝑥𝑖2 ) − (∑𝑛𝑖=1 𝑥𝑖 )2 ][𝑛(∑𝑛𝑖=1 𝑦𝑖2 ) − (∑𝑛𝑖=1 𝑦𝑖 )2 ]
Python Code using Numpy:

Python Code using Pandas:

Reading CSV files using Python: Here there is a database of many cars whose model, weight, volume and
CO2 consumption are present. From these data, some prediction analysis will be done.

CSV File:
Reading CSV file:
Now if a car has some weight and volume then some analysis should be done regarding its consumption to
CO2. Therefore the following code is written to get the data about the cars’ weight and volume.
Multiple Linear Regression: The following piece of codes using the independent parameters “Weight”
and “Volume” and dependent parameter “CO2” will create a prediction model.

Now if a car has weight 1700 unit and volume 2500 unit, then its CO2 consumption can be predicted from
the model.
Description of Sensors and Actuators
IR Sensor (Infrared Proximity Sensor):
TinkerCAD circuit for IR sensor internal circuit (Video Link: video link)

IR Sensor Interfacing with Arduino:

IR sensor interfacing with arduino (Video Link: IR Arduino Interfacing)

PIR Sensor (Passive/ Pyro Infrared Sensor):


PIR sensor interfacing with arduino (Video Link: PIR Arduino Interfacing)

Temperature Sensor: Temperature sensor is based on thermistor or thermocouple. Thermistor is


of two types: 1) Positive Temperature Coefficient (PTC) and 2) Negative Temperature Coefficient
(NTC).

TMP-36 interfacing with arduino (Video Link: TMP36 Arduino interfacing)

DHT Sensor Interfacing with Arduino:


DHT Sensor interfacing with Arduino (Video Link: DHT Sensor Interfacing with Arduino)

Ultrasonic Sensor:
Calculation of distance: From Trigger pin ultrasound is produced and it returns to Echo pin after
being reflected from the object. First of all, the overall time of traverse is calculated (using pulseIn
𝑣𝑠 ×𝑡
function). Thus the distance 𝑑 = where 𝑣𝑠 =velocity of sound (343 m/sec), 𝑡=total time
2
traversed and since the sound traverse the distance twice therefore divide by 2 operation is
performed.

Ultrasonic Sensor interfacing with Arduino:

Ultrasonic Sensor interfacing with arduino (Video Link: Ultrasonic Sensor Arduino interfacing)

Smoke/ Gas Sensor Interfacing with Arduino:


Gas Sensor Module (Arduino Board is only for 5V Power Supply) (Video Link: Gas Sensor
Module)
Gas Sensor Module interfacing with Arduino (Video Link: Gas Sensor Interfacing Arduino)

You might also like