BUAN 6333 – FOUNDATION OF PROGRAMMING
Class # 8
Date: 15th October 2024
Tuesday
Table of Contents
Agenda.................................................................................................................................... 3
R Algorithms............................................................................................................................ 3
Factors.................................................................................................................................... 3
Factors and Read Tables..................................................................................................... 4
Logical Rules........................................................................................................................... 5
Logical Conditions................................................................................................................... 6
If and else............................................................................................................................ 7
Ifelse.................................................................................................................................... 7
Loops...................................................................................................................................... 8
For ( ).................................................................................................................................. 8
While Loops......................................................................................................................... 9
Repeat Loops....................................................................................................................... 9
Executing a File Script........................................................................................................... 10
Agenda
Final project details
Python
o Introduction
o Create Environment
Final Project
About the data set provided: which is the record of a grocery shop transactions for about
two and a half months from 05/17/2023 to 07/31/2023.
Each transaction provides the following information:
o ID
o Value in Dollar
o Date
o Day
o Bought Items
Issues with the data:
o Not clean
o Some records are invalid due to human error
o Negative value
o Empty date
o Empty transaction
o Some values might be duplicate
o Data needs to be cleaned already cleaned through group project.
What is the final project?
• It is a live recommendation system; it takes as input:
o Transaction ID,
o Date
o Day
o A list of items bought so far
• The output is a list of 5 items that you recommend to the buyer
• Unified interface function will be provided later to be used for all groups
• You may work on solving the problem as a group but submitted Individually
• Recommendation systems use market basket analysis [a data mining technique
that analyzes customer purchase data to identify which products are often bought
together. It's also known as frequent itemset mining or association analysis].
• Weekly homework assignments will be assigned to guide you through the
project
• At least one question in the final exam will be from these project homework
assignments
Grade Distribution
Project grades will be:
40% Presentation presenting as a group (tentatively)
20% Professor evaluation concerning other groups auto grader: which will test the
transactions kept aside scaling with regards to group performance.
o 3 points if the first recommendation is found in the transaction
o 2 points if the top three recommendations found in the transaction
o 1 point otherwise
40% Peer evaluation
Guidelines:
You all should be working on the project
Each one has to be working on the coding side
You may implement the project using either R or Python
You need to think of your group as a company
You need to think of the problem as a customer problem
You need to design a solution that customers favor/pick your solution over
other companies in the market
Professor comments:
o Curate the best possible code that accurately defines the trend of a consumer
purchasing pattern and determine the top 5 products which may be purchase
together.
Python Script
Vocabulary/Words – Variables and Reserved Words.
Sentence structure – valid syntax patterns.
Story structure – constructing a program for a purpose.
Interactive python is good for experiments and program of 3-4 lines long.
Most programs are much longer, so we type them into a file and tell Python to run
the commands in the file.
In a sense, we are “giving Python a script”.
As a convention, we add “.py” as the suffix on the end of these files to indicate they
contain Python
Interactive versus Script
Interactive: You type directly to Python one line at a time and it responds.
Script: You enter a sequence of statements (lines) into a file using a text editor and
tell Python to execute the statements in the file.
Program Steps or Program Flow
Like a recipe or installation instructions, a program is a sequence of steps to be done in
order.
• Some steps are conditional - they may be skipped.
• Sometimes a step or group of steps is to be repeated.
• Sometimes we store a set of steps to be used over and over as needed several
places throughout the program.
Python – Notes
just run everything, no need to see a line by line. Run the file.
debug, runs the code line by line.