Intro to AI & Intro to Python

Similar documents
Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Python for C programmers

Accelerating Information Technology Innovation

How To Think Like A Computer Scientist, chapter 3; chapter 6, sections

MEIN 50010: Python Introduction

Python 1: Intro! Max Dougherty Andrew Schmitt

Lecture 4. Defining Functions

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

C H A P T E R 1. Introduction to Computers and Programming

Introduction to Python Code Quality

The current topic: Python. Announcements. Python. Python

Python: common syntax

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Part III Appendices 165

Accelerating Information Technology Innovation

Abstract Data Types. CS 234, Fall Types, Data Types Abstraction Abstract Data Types Preconditions, Postconditions ADT Examples

CIS 192: Artificial Intelligence. Search and Constraint Satisfaction Alex Frias Nov. 30 th

CSE : Python Programming

Assignment 7: Due Wednesday May 11 at 6pm UPDATES on Monday May 9

Table of Contents EVALUATION COPY

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Conditional Execution

The Pyth Language. Administrivia

Emerging Trends in Search User Interfaces

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Python Programming Exercises 1

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CSE 111 Bio: Program Design I Lecture 4: Variables, Functions, Strings, Genbank

At full speed with Python

Python. Tutorial Lecture for EE562 Artificial Intelligence for Engineers

Python notes from codecademy. Intro: Python can be used to create web apps, games, even a search engine.

A Little Python Part 1. Introducing Programming with Python

Lecture 3: Functions & Modules

It is been used to calculate the score which denotes the chances that given word is equal to some other word.

Functions and Decomposition

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017

Lecture 4. Defining Functions

Lesson 4: Type Conversion, Mutability, Sequence Indexing. Fundamentals of Text Processing for Linguists Na-Rae Han

Lecture #23: Conversion and Type Inference

Python Class-Lesson1 Instructor: Yao

Java Bytecode (binary file)

Conversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = "Hello";

Python I. Some material adapted from Upenn cmpe391 slides and other sources

Part I. Wei Tianwen. A Brief Introduction to Python. Part I. Wei Tianwen. Basics. Object Oriented Programming

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9

Algorithms and Programming I. Lecture#12 Spring 2015

CS 31: Intro to Systems Binary Arithmetic. Martin Gagné Swarthmore College January 24, 2016

If Statements, For Loops, Functions

Eclipse Environment Setup

Introduction to: Computers & Programming: Review prior to 1 st Midterm

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

DSC 201: Data Analysis & Visualization

Variables, Functions and String Formatting

Introduction to Python Part 2

Lecture 3: Functions & Modules (Sections ) CS 1110 Introduction to Computing Using Python

CS 177 Recitation. Week 1 Intro to Java

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

PROBLEM SOLVING 11. July 24, 2012

Introduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas

Spring 2018 Discussion 7: March 21, Introduction. 2 Primitives

Future Trends in Search User Interfaces

Lecture Numbers. Richard E Sarkis CSC 161: The Art of Programming

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

Some material adapted from Upenn cmpe391 slides and other sources

CS283: Robotics Fall 2016: Software

Jython. secondary. memory

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

Beyond Blocks: Python Session #1

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:

Not-So-Mini-Lecture 6. Modules & Scripts

How to create dialog system

Introduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas

1 Lecture 3: Python Variables and Syntax

S206E Lecture 19, 5/24/2016, Python an overview

Getting Started Values, Expressions, and Statements CS GMU

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

Lecture 1. Course Overview Types & Expressions

Math Day 2 Programming: How to make computers do math for you

Exceptions and File I/O

A computer program is a set of instructions that causes a computer to perform some kind of action. It isn t the physical parts of a computer like the

Case-Based Reasoning. CS 188: Artificial Intelligence Fall Nearest-Neighbor Classification. Parametric / Non-parametric.

CS 188: Artificial Intelligence Fall 2008

Chapter 2 Programming in Python

1 Getting used to Python

Python for Non-programmers

Lecture 1. Course Overview, Python Basics

Python is available at: Why Python is awesome:

Mobile Robots Summery. Autonomous Mobile Robots

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015

CSE 341, Autumn 2015, Ruby Introduction Summary

CS1 Lecture 9 Feb. 5, 2018

Professor Hugh C. Lauer CS-1004 Introduction to Programming for Non-Majors

Unit E Step-by-Step: Programming with Python

Master Your Mac. simple ways to tweak, customize, and secure os x

Pace University. Fundamental Concepts of CS121 1

Lecture 1. Course Overview, Python Basics

Shadows in the graphics pipeline

Import Statements, Instance Members, and the Default Constructor

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

Transcription:

CS311: Artificial Intelligence Intro to AI & Intro to Python CS311 David Kauchak Spring 2013 http://www.bbspot.com/comics/pc-weenies/2008/02/3248.php Adapted from notes from: Sara Owsley Sood Who are you and why are you here? Name/nickname Major and year What is AI? (or what do you think AI is? J ) Course goals Be able to answer the question What is AI? Learn and apply basic AI techniques to solve real-world (current) problems, and in the process appreciate how HARD AI really is (and why) Why are you taking this course? What topics would you like to see covered? 1

2/12/13 AI is a huge field How do we measure success? So, what is AI Building programs that enable computers to do what humans can do. One definition: there are many interpretations of this goal human Building programs that enable computers to do what humans can do. thinking For example: read, walk around, drive, play games, solve problems, learn, have conversations How is AI viewed in popular media? vs. rational Think like a human Think rationally Cognitive Modeling Logic-based Systems Act like a human Act rationally Turing Test Rational Agents vs. acting What challenges are there? 2

What challenges are there? Perception perceive the environment via sensors Computer vision (perception via images/video) process visual information object identification, face recognition, motion tracking Natural language processing and generation speech recognition, language understanding language translation, speech generation, summarization What challenges are there? Knowledge representation encode known information water is wet, the sun is hot, Dave is a person, Learning learn from environment What type of feedback? (supervised vs. unsupervised vs. reinforcement vs ) Reasoning/problem solving achieve goals, solve problems planning How do you make an omelet? I m carrying an umbrella and it s raining will I get wet? Robotics How can computers interact with the physical world? Understand spoken language? speech recognition is really good, if: restricted vocabulary specific speaker with training Gotten quite good in the last few years and shows up in lots of places: Mac has built-in dictation software Siri is pretty good (though there s more than speech recognition going on there) Google allows you to search via voice command What does the spoken language actually mean (language understanding)? much harder problem! many advances in NLP in small things, but still far away from a general solution Speak? Understandable, but you wouldn t confuse it for a person Can do accents, intonations, etc. Better with restricted vocabulary Loquendo http://tts.loquendo.com/ttsdemo/default.asp Dealing with facial expression is challenging Kismet (MIT) 3

Drive a car? Freeway driving is relatively straightforward Off-road a bit harder see DARPA grand challenges (2004, 2005) And urban driving is even trickier See DARPA urban challenge (2007) Google s autonomous vehicle Hint: there s a connection here Identify emotion? This is hard! Some success in text movie reviews blogs twitter dealing with sarcasm is hard Some success with faces strongly biased by training data works best when exaggerated Reasoning? Success on small sub-problems General purpose reasoning is harder Wolfram Alpha OpenCyc Walk? Robots have had a variety of locomotion methods Walking with legs, is challenging Differing terrains, stairs, running, ramps, etc. Recently, a number of successes Honda s Asimo http://www.youtube.com/watch?v=w1czbcnx1ww Sony QRIO http://www.youtube.com/watch?v=9vwz5fqeufg Boston Dynamic s Big Dog http://www.youtube.com/watch?v=w1czbcnx1ww 4

When will I have my robot helper? Vacuum? Clean the floor? Mow the lawn? Fold a pile of towels? UC Berkeley towel folding robot: http://www.youtube.com/watch?v=gy5g33s0gzo Administrivia go/cs311 Office hours, schedule, assigned readings, problem sets Everything will be posted here Read the administrivia page! ~4 programming assignments (in Python) ungraded written assignments quizzes 2 exams (dates are tentative) final project for the last month teams of 2-3 people research-like with write-up and presentation class participation readings Academic honesty and collaboration 5

Python basics >>> x = 5 #no variable types or declarations >>> y = 10.0 #python has implicit typing >>> type(y) # gets the type of an expression <type 'float'> >>> type(x) <type 'int'> >>> x + y #meaning that the type is implied by whatever #you do to the variable 15.0 >>> type(x + y) <type 'float > >>> x = 'hi there' >>> x + y Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: cannot concatenate 'str' and 'int' objects >>> x + str(y) 'hi there10' More python fun >>> x[0] ##treat a string as a list 'h' >>> x[0:4] ##substring of a string is a sublist - slices 'hi t >>> x[-1] e >>> x[-3:] ere >>> myl = [2]*5 ##can do powerful things >>> myl ##what do you think this will do? [2, 2, 2, 2, 2] >>> myl[2] = 0 >>> x = 1 >>> y = hello >>> x, y = y, x >>> x hello >>> y 1 Defining functions look at functions.py def defines a new function : indicates the beginning of a new block of text no curly braces (for better or worse) a block is indicated by it s indentation DON T MIX SPACES AND TABS Whatever editor you use look up how to Auto-expand tabs into spaces! == for equality True and False External files You can edit in your favorite text editor (for example Aquamacs or TextWrangler). You could also use an IDE like IDLE or WingIDE if you d like. When you re ready, you can import the commands in the file using import >>> import functions # don t include the.py >>> L = [1,2,3,4] >>> functions.listsearch(l, 5) False >>> functions.listsearch(l, 1) True 6

External files You can edit in your favorite text editor (for example Aquamacs or TextWrangler). You could also use an IDE like IDLE or WingIDE if you d like. If you don t want to have to type <module>. before the commands: >>> from functions import * # don t include the.py >>> L = [1,2,3,4] >>> listsearch(l, 5) False >>> listsearch(l, 1) True STDOUT and STDIN look at IO.py print prints to the console (you can use it in functional form with () or without) help(raw_input) takes an optional prompt which is printed to the user returns a string we typecast it to an int using int() can get a typecast error if user doesn t enter an int notice that this is a script! Python executes from the top of the file to the bottom Functions must be declared before calling The last line is the method call to the function Defining classes look at polygon class in classes.py class <classname>: again, denotes a new block of code self should be the first argument to any class method It allows you to use the. notation for calling methods It gives you a handle to the data associated with the current object When you call the method, you don t actually specify it init is similar to a constructor p = polygon( ) str is similar to tostring in Java and is called whenever an object is printed we can define optional parameters using = in the parameter list must be the last parameters in the list if not specified, they get the default value can specify using the name if desired Defining classes look at box class in classes.py can define multiple classes in a file (and filename doesn t matter, remember these are just scripts. You could type these into the interpreter if you d like) isinstance function is similar to instanceof in Java 7

dir and help! provide all of the methods and data members available to an object help(listsearch) dir( foo ) help( foo.split) dir(str) help(str.split) dir(42) dir([]) No memorizing! Just use dir & help (and online documentation J ) Comments and docstrings # denotes a comment (use them!) """ denotes a multi-line string. When put at the top of a file or as the first line in a function definition these provide documentation via help (use them!) help(classes) 8