0% found this document useful (0 votes)
41 views33 pages

Session1 - Analytics For Programming II - Siryani - 082224

Uploaded by

berkeal260
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)
41 views33 pages

Session1 - Analytics For Programming II - Siryani - 082224

Uploaded by

berkeal260
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/ 33

Programming for Analytics II

Session 1
Thursday August 22nd, 2024

Joseph Siryani, Ph.D.


Adjunct Professor, Department of Decision Sciences
George Washington University – School of Business
Joseph Siryani, Ph.D.
Adjunct Professor, Department of Decision Sciences
George Washington University – School of Business

Healthcare Data & Analytics Leader

Leading teams focused on Instructor of Data Science Virginia Chapter PhD in Systems Engineering
• Data Science & AI • Python Programming Speaker at HIMSS22 focused on Applied Machine
• Statistical Modeling • Python for Data Science • Evolving Standards for Learning and intelligent
• Analytics • Machine Learning Machine Learning and AI Decision Support Systems
• AI Enablement / Governance • Data Visualization in Tableau
• Data Visualization Governance • AI Strategy
Agenda

Introductions & Expectations 3 Lecture 1 & Hands-On


1
Perform class introductions and discuss main Present Lecture 1 and carry out instructor-led
goals and expectations. Python hands-on work and exercises.

Syllabus Overview Q & A’s


2 Walkthru Syllabus.
4 Questions & Answers!
1 Introductions & Expectations
Gartner’s Executive
Welcome!
How to be successful in this course?
❖ Start right away
❖ Review the syllabus carefully. Pay particular attention to:
❑ Course end date and all due dates
❑ Grading policies
❑ Plagiarism policy
❖ Expect to spend 8-12 hours per week on average completing this course
❖ Plan to spend time on the course each day
❖ Engage meaningfully and regularly in course activities -> Earn extra points every week!
❖ Know where to get help
❑ Contact me for any questions about the content of the courses, assignments, due dates, and the like

I look forward to working with you during this class and wish you the very best with this learning experience!
Course Objectives

Are you ready to power up your career and learn the best programming language for data science?

Students who successfully complete the course requirements will be able to:

❖ Write scripts and complete programs in Python

❖ Read in data (including unstructured text) and learn how to process for analysis

❖ Design, develop, and deliver reproducible data products in Python

❖ Use Python packages for prescriptive and predictive analytics

❖ Participate in and get evaluated in competitive analytics platforms like Kaggle


Getting the Python environment ready (Action to do prior to class start)

✔ Download, install, and configure Anaconda, which is the recommended version of Python to use during this
course. If you do not already have it on your machine, the installation link is https://www.anaconda.com/

✔ Familiarize yourself with Anaconda environment and Jupyter Notebooks IDE


What Does It Take to Succeed In This Course?
❖ Expect to spend 8-12 hours per week on average completing this course. The content is designed to prepare you to transfer
these skills to real world applications. Being an effective programmer requires a strong problem-solving mindset. Therefore,
we expect students to apply troubleshooting techniques when they first encounter a challenging exercise

❖ I encourage you to interact with each other, not just with me. You all bring diverse backgrounds to the course, and we all
benefit from your contributions. Learning and discovery takes place during the class and on the various discussion boards all
the way through the last day of class. Please review the boards frequently, post early, and post often (even after you meet the
mandatory requirements)

❖ When responding to your classmates’ postings, you can engage in several different ways. Here are just a few examples:
✔ Supplement the post made by your classmates by citing additional data or material from the reading assignments or other reading
materials. Please cite your references when you do this
✔ Apply the course material to your professional or personal experience from the past or present
✔ Share divergent perspectives and/or experiences from what your classmate expressed
✔ Please assume the best intentions from your peers in class. Maintaining a safe environment for learning is essential
Different Types of Analytics

Source: www.gartner.com
Gartner’s analytics ascendancy model

Source: www.gartner.com
2 Syllabus Overview
Review Syllabus on Blackboard !
3 Lecture 1 & Hands-On
Introduction to Python

❖ Understanding Operators, Variables and Data Types

❖ Conditional statements, Looping constructs

❖ Functions and Data structures

❖ List and Dictionaries


Python Data Types

Type Definition Example

int Integers: positive or negative whole numbers with no decimal point 11

float Floating-point numbers: represent real numbers and are written with a decimal 5.67
point dividing the integer and fractional parts

string A sequence of characters. Strings start and end with single or double quotes “Hello World”

boolean Represents the truth values False and True (or in a numeric context, 0 and 1) True
Python Variable Types

Global variable
A global variable is a variable that is defined outside of a function or class definition. Typically, both function
names and module names are global variables.

Local variable
A local variable is a variable that is created within the body of a function or method.
Python Conditional Statements
A conditional statement is a statement of the form

if <bool>:
<statements>
Python executes this statement as follows: If the boolean expression is True, if executes the statements underneath.
Otherwise, it skips over them.
An alternate form of a conditional is as follows:

if <bool>:

<statements>
else:
<statements>

This form is executed as follows: If the boolean expression is True, it executes the statements underneath the if. Otherwise, it
executes the statements underneath the else. There are additional forms of conditional statements that use the keyword elif.
Python Conditional Expression

A conditional expression is an expression with the following form:


<expr1> if <bool> else <expr2>

To evaluate this expression, Python first evaluates the boolean expression <bool>. If the boolean is True, Python
uses the value of <expr1> as the value of the conditional expression. Otherwise, Python uses the value of
<expr2> as the value of the conditional expression.
Python Container Data Types

❖ Lists: for storing a sequence of items in a specific order

❖ Dictionaries: for associating unique members of one set of items (keys) with members of another set (values)

❖ Sets: for storing a group of unique items in no specific order

❖ Tuples: like lists, for storing a sequence of items in a specific order, but cannot be modified once created
Python For-loop

A for-loop is a statement of the form


for <variable> in <iterable>:

<statements>

Python executes this statement as follows: It puts the first element of the iterable in the variable, and then
executes the statements indented underneath. It repeats this process if there are still elements left in the iterable.

In a for-loop, the variable after the keyword for is called the loop-variable while the iterable is called the
loop-iterable or loop-sequence.
Python While-loop

A while-loop is a statement with the following form:


while <bool>:
<statements>

Python executes this statement as follows: It first evaluates the boolean expression. If it is True, then it executes
the statements indented underneath. It repeats this process if the boolean expression is True. This boolean
expression is often referred to as the loop condition.

While-loops are difficult to use properly and are often combined with loop invariants.
Python Container Data Types - Lists
Containers are data types that hold other pieces of data but diff er in how those data elements are accessed and what sorts of operations they
support.

Lists
▪ A Python list is a mutable sequence of objects; list elements can be of any type
▪ List elements are indexed by their position in the sequence, with valid indices being integers starting with 0 and ending with n-1, where n
is the number of elements in the list
▪ List elements are accessed using square brackets ([ ]) and can be used for either getting or setting elements at a given position; e.g.,
o my_list[4] returns the element at position 4 in my_list
o my_list[5] = 6 sets the element at position 5 in my_list to the value 6
▪ Lists can also be sliced using square brackets, to get contiguous blocks of elements
o my_list[i:j] returns a list containing elements from my_list starting at position i and ending at position j-1 (so that the number of
elements in the sublist is j-i)
▪ Lists are mutable; elements can be changed, added, or removed
▪ for loops are a useful way of iterating over all the elements of a list; e.g.,

for elem in my_list:


# elem will be set to each successive element in my_list
Python Container Data Types - Lists
▪ Lists can be created in various ways, including list comprehensions:
[expression for element in iterable if condition]

▪ Some useful list methods include:


▪ list.index(obj): return the index of the first occurrence of an object in a list
▪ list.insert(index, obj): insert an object into a list at the specified index
▪ list.append(obj): add an object to the end of a list
▪ list.extend(alist): add the elements of a list to the end of a list
▪ list.count(obj): count the number of times a given object appears in a list
▪ list.sort(): sort the elements of a list (modifying the original list
Python Container Data Types - Dictionaries
▪ A Python dictionary maps a set of keys to an associated set of values
▪ Dictionary elements are accessed by their key; if a specified key does not exist in a dictionary, an error is thrown
▪ Dictionary values are accessed by their key using square brackets ([ ]) and can be used for getting, setting, or adding new elements for a given
key; e.g.,
▪ my_dict[‘c'] returns the value in my_dict associated with the key ‘c’
▪ my_dict[‘e'] = 6 sets the value in my_dict associated with the key ‘e’ to the value 6 or adds it to the dictionary
▪ Dictionaries are mutable; key-value pairs can be changed, added, or removed
▪ for loops are a useful way of iterating over all the key-value pairs (items) in a dictionary; e.g.
for k,v in my_dict.items():
# k will be set to each key in my_dict
# v will be set to the value associated with k
Python Container Data Types - Dictionaries
▪ Dictionaries can be created in various ways, including dictionary comprehensions:
{k:v for element in iterable if condition}
▪ Some useful dictionary methods include:
o dict.keys(): return an iterable view of all keys in a dictionary
o dict.values(): return an iterable view of all values in a dictionary
o dict.items(): return an iterable view of all key-value pairs in a dictionary
o dict.get(key, default): return the value associated with a specified key, return default value if key not in dictionary
Python Container Data Types - Sets
▪ A Python set is a mutable, unordered collection of unique elements
▪ for loops are a useful way of iterating over all the elements of a set; e.g.
for elem in my_set:
# elem will be set to each successive element in my_set
# elements of my_set will be accessed in arbitrary order

Sets can be created in various ways, including set comprehensions:


{expression for element in iterable if condition}
▪ Some useful set methods include:
▪ set.add(object): add object to a set
▪ set.union(set2): return the union between set and set2
▪ set.intersection(set2): return the intersection between set and set2
▪ set - set2: return all elements in set but not in set2 (equivalent to set.difference(s2))
Python Container Data Types - Tuples
A Python tuple is an immutable sequence.
▪ Tuples are indexed and sliced like lists, using square brackets, but only for getting elements (elements cannot be set once a tuple is created)
▪ Tuples are useful for bundling together a group of different data elements, distinguishing each element by its position in the tuple.
▪ Tuples are useful for unpacking multiple objects returned by a function; this requires that the function return as many objects as are assigned
to on the left-hand side; e.g.

x,y,z = my_func()
# requires that my_func() return three objects, or a tuple with three elements
Let The Hands-On begin !
Python Hands-on

Work thru various datasets and 4 exercises and Jupyter notebooks:


❖ Simple data types
❖ Python compound / container data types
❖ Handling text files and list comprehensions
❖ Simple programs in Python
4 Q & A’s
Questions & Answers !
Dr. Joseph Siryani
Department of Decision Sciences
George Washington University – School of Business

Funger Hall
josephsiryani
2201 G St. NW
Washington, D.C. 20052

You might also like