Interactive Session on Project 2 & Assorted Topics Copyright, 1996 © Dale Carnegie & Associates, Inc. By Surendra Singhi Spring 2005.

Slides:



Advertisements
Similar presentations
CS 63 LISP Philip Greenspun's Tenth* Rule of Programming:
Advertisements

Florida International University COP 4770 Introduction of Weka.
The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
ANSI Common Lisp 5. Control 16 June Blocks -- progn progn > (progn (format t “a”) (format t “b”) ( )) ab 23 The expressions within its body.
Visual Basic for Applications. What it does Extends the features and built in functions of Excel – Create and run VB procedures – Some may be easy to.
Machine Learning in Practice Lecture 3 Carolyn Penstein Rosé Language Technologies Institute/ Human-Computer Interaction Institute.
Lisp Recitation (cse471/598 Fall 2007 ) Aravind Kalavagattu.
CSE 341, S. Tanimoto Pattern Matching - 1 Pattern Matching in Lisp Lists can be used to represent sentences, relations, tree structures, etc. (this list.
Common Lisp! John Paxton Montana State University Summer 2003.
17-Jun-15 Assorted Ruby Details. The command line irb starts an interactive Ruby interpreter ruby starts Ruby, with input from the command line End with.
First Lecture on Introductory Lisp Yun Peng. Why Lisp? Because it’s the most widely used AI programming language Because AI researchers and theoreticians.
CMSC 471 LISP. Why Lisp? Because it’s the most widely used AI programming language Because it’s good for writing production software (Graham article)
Recursion. Definitions I A recursive definition is a definition in which the thing being defined occurs as part of its own definition Example: A list.
COMP 205 – Week 11 Dr. Chunbo Chu. Intro Lisp stands for “LISt Process” Invented by John McCarthy (1958) Simple data structure (atoms and lists) Heavy.
SVMLight SVMLight is an implementation of Support Vector Machine (SVM) in C. Download source from :
Allegro CL Certification Program Lisp Programming Series Level I Session Top Ten Things to Know.
Functional Programming
Input/Output Chapters 7 & 9. Output n Print produces output > (print 100) n It also returns the value it printed –that’s where the second 100 came.
1 Othello Game Programs (human to human). 2 (defconstant all-directs '( )) ALL-DIRECTS (defconstant empty 0) EMPTY (defconstant.
The Case primitive: matches the evaluated key form against the unevaluated keys by using eql The general format of case is the following: (case (... ).....
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
For Monday Read Chapter 3 Homework: –Lisp handout 2.
1 Lisp Functions –Built-in functions –Defining functions –Function Evaluation and Special Forms defun, if Control statements –Conditional if, cond –Repetition.
Lecture 2-1CS250: Intro to AI/Lisp Intelligent Agents Lecture 3-2 October 14 th, 1999 CS250.
ITEC 380 Organization of programming languages Lecture 3 – Functional Programming.
1 More About Lisp. 2 Functions on Lists (setf x '(a b c)) => (A B C) (setf y '(1 2 3)) => (1 2 3) (rest x) => (B C) ;;all but the first element (nth 1.
CSE 341, S. Tanimoto Lisp Defining Functions with DEFUN Functions are the primary abstraction mechanism available in Lisp. (Others are structures.
Artificial Intelligence IES 503 Asst. Prof. Dr. Senem Kumova Metin.
04 Control. Control-Blocks Common Lisp has 3 basic operators for creating blocks of code progn block tagbody If ordinary function calls are the leaves.
06 INPUT AND OUTPUT Functional Programming. Streams Two kinds of streams  Character streams  Binary streams Character streams are Lisp objects representing.
The Loop Macro Many of the CL “functions” are actually macros (let, progn, if, etc) The most complicated macro in CL is probably the Loop macro –The Loop.
Lecture 6-2CS250: Intro to AI/Lisp Programming in Your Favorite Language Lecture 5-2 February 11 th, 1999 CS250.
Chapter 10: BASH Shell Scripting Fun with fi. In this chapter … Control structures File descriptors Variables.
Function Design in LISP. Program Files n LISP programs are plain text –DOS extensions vary; use.lsp for this course n (load “filename.lsp”) n Can use.
Macros “How can you get anything done in [other languages], I think, without macros?” - Paul Graham, 2003.
Lisp Files, Arrays, and Macros CIS 479/579 Bruce R. Maxim UM-Dearborn.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Building user-defined functions: the progressive envelopment technique The idea: define combinations of LISP primitives through a sequence of experiments.
Introduction to LISP. Lisp Extensible: It lets you define new operators yourself Lisp programs are expressed as lisp data structures –You can write programs.
11 Speed & Debug.  Lisp is really two languages:  A language for writing fast programs  A language for writing programs fast  In the early stage,
UMBC CMSC Common Lisp II. UMBC CMSC Input and Output Print is the most primitive output function > (print (list 'foo 'bar)) (FOO BAR) The.
PRACTICAL COMMON LISP Peter Seibel 1.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
1 Variable Declarations Global and special variables – (defvar …) – (defparameter …) – (defconstant …) – (setq var2 (list 4 5)) – (setf …) Local variables.
CSE 143 Lecture 4 More ArrayIntList : Pre/postconditions; exceptions; testing reading: slides created by Marty Stepp and Hélène Martin
Programming in R Subset, Sort, and format data. In this session, I will introduce the topics: Subsetting the observations in a data frame. Sorting a data.
Basic Introduction to Lisp
Control Structures CSC 358/ Outline Midterm Lab #3 Homework #4 Sequential structures Conditional structures Unconditional branching Iteration.
Macros and general code walkers in Lisp: how useful! or, how useful? Ernst van Waning
PRACTICAL COMMON LISP Peter Seibel 1.
Input Streams “A program designed for inputs from people is usually stressed beyond the breaking point by computer-generated inputs.” Dennis Ritchie, Bell.
Input/Output Chapters 8 & 9. Character Input n Read-char reads a single character n Read-line reads until the next end-of-line –returns a string n Both.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
 If you want to open an already existing file select file->open on the menu and then choose the program you want to modify. If you want to open a new.
1 Outline Review Introduction to LISP Symbols and Numbers Lists Writing LISP Functions LISPWorks.
Section 15.4, 15.6 plus other materials
Modern Programming Languages Lecture 20 Fakhar Lodhi
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Getting Started with Lisp
Detailed File I/O Examples Focus on Input
Figure 1.1 Rules for the contact lens data.
“The fastest I/O is no I/O.” Nils-Peter Nelson, Bell Labs
Modern Programming Languages Lecture 21 Fakhar Lodhi
Modern Programming Languages Lecture 20 Fakhar Lodhi
Defining Functions with DEFUN
Peter Seibel Practical Common Lisp Peter Seibel
Abstraction and Repetition
Common Lisp II.
def-ining a function A function as an execution control structure
The general format of case is the following: (case <key form>
Presentation transcript:

Interactive Session on Project 2 & Assorted Topics Copyright, 1996 © Dale Carnegie & Associates, Inc. By Surendra Singhi Spring 2005

CSE 471/598, CBS 598 by Surendra Singhi2 Agenda Project 2 discussion Various Terms Requirements Some tips Some code Analysis Questions, questions, and questions. Questions on anything and everything you want to know about the course/projects/home works.

CSE 471/598, CBS 598 by Surendra Singhi3 Jargon Dataset – Data along with the meta- information. Instance – Each row in the dataset. Attributes/Features – Columns in the dataset. Real/Numeric attributes - Continuous Nominal attributes – Discrete Classifier – The decision tree built. Classification – The process of making prediction for instances.

CSE 471/598, CBS 598 by Surendra Singhi4 Project Requirements A function named "read-data" which should take an input file and store it in a structure in some format (its up to you) and return the structure (henceforth called dataset). A sample input file is given as (read-data "train.arff")

CSE 471/598, CBS 598 by Surendra Singhi5 Function "build-classifier" which should take the dataset structure (returned by read-data) and an optional impurity function as its parameter. The function should build a decision tree using a given impurity function. The reason why your function should take another function as a parameter is that in case if you want to use a different impurity measure you should have the flexibility of doing that. This function should return the built classifier (some structure). (build-classifier train-data #'entropy)

CSE 471/598, CBS 598 by Surendra Singhi6 A functions named "entropy" should take probability values (any number of them) and return the impurity (purity) value. (entropy ) (entropy 1) How to do it? Look at “&rest” keyword.

CSE 471/598, CBS 598 by Surendra Singhi7 A function named "evaluate-classifier", it should take as input parameter a classifier and a dataset and return the classification error (percentage) on it. It should print the classification of all the instances in the dataset and also print the confusion matrix. A confusion matrix is a matrix showing the predicted and actual classifications. It is of size L x L, where L is the number of different label values.

CSE 471/598, CBS 598 by Surendra Singhi8 (evaluate-classifier (build-classifier train-data) train-data) (evaluate-classifier (build-classifier train-data) test-data)

CSE 471/598, CBS 598 by Surendra Singhi9 Confusion Matrix Act/Pred Class1 Class2 Class3 Class1 a b c Class2 d e f Class3 g h i

CSE 471/598, CBS 598 by Surendra Singhi10 Tips Try to make extensive use of Ansi Lisp functions. Functions – sort, reduce, map, max, min Control statements – if, when, unless, cond, case, loop while, loop until, loop for Global variables - *i-am-a-global-variable* Use “let” to create local variables

CSE 471/598, CBS 598 by Surendra Singhi11 Use a good editor, something better than “Notepad” ) ) – is irritating for lisp hackers Please comment all print statements which are used for testing purpose. Please do not use “progn” unnecessarily

CSE 471/598, CBS 598 by Surendra Singhi12 Some code snippets Parsing the tsp problem: 1. (defun read-tsp-problem (file-name) 2. (let (city-list matrix len) 3. (with-open-file (fptr file-name :direction :input) 4. (setf city-list (with-input-from-string (cities (read-line fptr)) 5. (loop for city = (read cities nil cities) 6. until (eq city cities) 7. collect city))) 8. (setf len (length city-list)) 9. (setf matrix (make-array (list len len))) 10. (dotimes (i len) 11. (dotimes (j len) 12. (setf (aref matrix i j) (read fptr))))) 13. (print matrix)))

CSE 471/598, CBS 598 by Surendra Singhi13 Some more code….. Helper function for parsing input file 1. (defun read-till-delimiter (stream delimiter) 2. (string-trim '(#\Space #\Tab #\Newline) 3. (with-output-to-string (str) 4. (loop for ch = (read-char stream nil stream) 5. until (or (eq ch stream) (eql ch delimiter)) 6. do (princ ch str)))))

CSE 471/598, CBS 598 by Surendra Singhi14 Question Time!!!!