Page 469 - AI Ver 3.0 class 10_Flipbook
P. 469
Installing SciPy
The command that installs SciPy is:
pip install scipy
Assuming that Python and pip are already installed in the computer.
Statistical Learning with Python
Now we all have understood that Data Sciences deals with data analysis and data manipulation. But this numeric
& alpha-numeric data analysis and manipulation is not possible without the intervention of Mathematical
Statistics.
Python with supported libraries like NumPy, Matplotlib etc have a lot of pre-defined functions that implement
Mathematical statistics without getting into the hassle of doing the calculations and creating the formulas or
equations to find out the results. All we need to do is write that function and pass on the data to it. It’s that simple!
Let us take a look at some basic statistical tools used in Python:
Mean
It is the average of numeric data in a given dataset. So, sum of all the values divided by the number of values in
the given set.
It is calculated as:
Mean =
To calculate mean in Python:
[1]: import statistics
marks=[45,34,41,46,47,39,38,48,45,34,41,39,39]
m=statistics.mean(marks)
print("the average marks of the class :",round(m,2))
the average marks of the class : 41.23
Median
When the data is arranged in an ascending/descending order then median is the middle number in a given
dataset. If there are two middle numbers, the mean of these two numbers will give the median.
For odd number of dataset: N + 1 th term
2
N th N th
For even number of dataset: 2 term + 2 + 1 term
2
To calculate median in Python with odd number of values:
[1]: import statistics
marks=[45,34,41,46,47,39,38,48,45,34,41,39,39]
m=statistics.median(marks)
print("the middle value of the sorted marks in class :",m)
the middle value of the sorted marks in class : 41
Advance Python (Practical) 467

