Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

Lecture Slide 2

wdddscdsf dwf,ds f,mds fmds, f

Uploaded by

ayk0227
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Lecture Slide 2

wdddscdsf dwf,ds f,mds fmds, f

Uploaded by

ayk0227
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Lecture 5

Smart Data and Discovery


Matplotlib
Overview
• OS library
• Recursive Function
• Matplotlib
OS (Library)
• Provides the facility to establish the interaction between user and the operating system.
• Portable way of using operating system dependent functionality.
• Let us work with files and directories of OS.
OS Library (Keywords)
Function Description

os.getcwd() Returns the current working directory

os.chdir(path) Changes the current working directory to path

os.listdir(path) Returns a list of files and directories in path

os.mkdir(path) Creates a new directory with the name path

os.makedirs(path) Creates a new directory with the name path and any necessary parent directories

os.remove(path) Deletes the file at path

os.rmdir(path) Deletes the directory at path (the directory must be empty)

os.removedirs(path) Deletes the directory at path and any empty parent directories

os.rename(old_name, new_name) Renames the file or directory at old name to newname

Joins the given paths together using the appropriate separator for the current operating
os.path.join(path1, path2, ...)
system
OS library Examples
Recursive Function
• A function that call itself.
• Useful for solving problems that can be broken down into smaller, similar problems.
• To write a recursive function in Python, you use the same basic syntax as other functions, but with a base case that
ends the recursion.
• Recursive functions can be used to solve a wide range of problems, from calculating factorials and Fibonacci
numbers.
• Recursive functions can sometimes be slower and use more memory than iterative (non-recursive) solutions,
especially for large inputs.
Recursive Function (Example)
Matplotlib
• Introduced by John Hunter in 2002
• Amazing library for visualization of 2D plots in python
• Allows visual access for huge amounts of data in digestible manner.
• Consists of several plots like line, bar, scatter, histogram etc.

Importing Matplotlib
from matplotlib import pyplot as plt or
import matplotlib.pyplot as plt
Basic Plots
• Comes with wide variety plots
• Helps to understand trend, patterns and to make correlations
• Provide information for understanding quantitative information
Line plot
Box Plot
• Shows the five number summary of a set of a data
(minimum score, first quartile, median, third quartile
and maximum score)
• Useful as they show the average score of dataset.
• Useful as they also show the skewness ,
dispersion, outliers of dataset.
Boxplot Example.
Bar Plot
• Also called bar chart
• Represents the category of data with rectangular bars with lengths and heights.
• Allows to compare different sets of data among different groups easily.
• Shows the relationship among two axes
Bar Plot Example
Histogram
• Popular graphing tool.
• Shows the frequency of numerical data using rectangles.
• Height represents frequency of numerical data.
• Used to summarize discrete or continuous data measured on interval scale.
Histogram Example.
Scatter Plots
• Determine whether or not two variables have relationship or correlation.
Scatter Plots Example
Plotting (Y=mx+c)
Plotting (Y=mx+c) where m=2 and c=2
Plotting (Y=mx+c) where m=2 and c=2
Key things to remember
• xlim – set upper and lower limits of x-axis
• ylim – set upper and lower limit of y-axis.
• xlabel – set label for x-axis
• ylabel – set label for y-axis
• legend – add legend to the plot
• title – add title to the plot
• xticks – set custom marker for the x-axis
• yticks – set custom marker for the y-axis
Example
Pie Chart
Any Questions ?

You might also like