Recitation for BigData Jay Gu Jan 10 HW1 preview and Java Review.

Slides:



Advertisements
Similar presentations
ArrayLists The lazy mans array. Whats the matter here? int[] list = new int[10]; list[0] = 5; list[2] = hey; list[3] = 15; list[4] = 23;
Advertisements

Java Programming 2 Dr. Priti Srinivas Sajja Introductory concepts of java programming as specified in PGDCA 203:Object Technology, S P University.
David Notkin Autumn 2009 CSE303 Lecture 13 This space for rent.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
INTERFACES IN JAVA 1.Java Does not support Multiple Inheritance directly. Multiple inheritance can be achieved in java by the use of interfaces. 2.We need.
1 Class Design CS 3331 Fall Outline  Organizing classes  Design guidelines  Canonical forms of classes equals method hashCode method.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
CS 206 Introduction to Computer Science II 01 / 21 / 2009 Instructor: Michael Eckmann.
1 Lab Session-3 CSIT221 Spring 2003 b Group Worksheet 3 Exercise (Demo Required) b No new lab demo will be assigned to allow you to focus on HW#1.
Alice in Action with Java
Unit 011 Inheritance Recall What Inheritance is About The extends Keyword The Object Class Overriding versus Overloading What is Actually Inherited? Single.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 10 Using arrays to create collections.
Chapter 10 2D Arrays Collection Classes. Topics Arrays with more than one dimension Java Collections API ArrayList Map.
® IBM Software Group © 2006 IBM Corporation How to read/write XML using EGL This Learning Module shows how to utilize an EGL Library to read/write an XML.
OOP Languages: Java vs C++
Programming Languages and Paradigms Object-Oriented Programming.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
Learning with large datasets Machine Learning Large scale machine learning.
1 Week 4 Questions / Concerns Comments about Lab1 What’s due: Lab1 check off this week (see schedule) Homework #3 due Wednesday (Define grammar for your.
Recitation 1 CS0445 Data Structures Mehmud Abliz.
Object Oriented Programming: Java Edition By: Samuel Robinson.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
The Java Collections Framework (Part 2) By the end of this lecture you should be able to: Use the HashMap class to store objects in a map; Create objects.
Efficient Logistic Regression with Stochastic Gradient Descent – part 2 William Cohen.
5-Aug-2002cse Arrays © 2002 University of Washington1 Arrays CSE 142, Summer 2002 Computer Programming 1
1 Java: AP Curriculum Focus and Java Subset Alyce Brady.
Problem Solving using the Java Programming Language May 2010 Mok Heng Ngee Day 5: Arrays.
Efficient Logistic Regression with Stochastic Gradient Descent William Cohen.
Collections. The Plan ● Why use collections? ● What collections are available? ● How are the collections different? ● Examples ● Practice.
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
Simulated Pointers Limitations Of Java Pointers May be used for internal data structures only. Data structure backup requires serialization and deserialization.
Chapter 18 Java Collections Framework
1/20/03A2-1 CS494 Interfaces and Collection in Java.
Chapter 4 Grouping Objects. Flexible Sized Collections  When writing a program, we often need to be able to group objects into collections  It is typical.
Java Basics.  To checkout, use: svn co scb07f12/UTORid  Before starting coding always use: svn update.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
RECITATION 4. Classes public class Student { } Data Members public class Student { private String name; public String id; }
Session 7 Methods Strings Constructors this Inheritance.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Shipping Hub Application.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
CS 11 java track: lecture 2 This week: more on object-oriented programming (OOP) objects vs. primitive types creating new objects with new calling methods.
Working With Objects Tonga Institute of Higher Education.
Copyright 2010 by Pearson Education Building Java Programs Chapter 10, 11 Lecture 22: 143 Preview optional reading: 10.1,
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
COMP 121 Week 8: Generic Collections. Objectives To understand type variables and how they are used in generic programming To be able to implement and.
Chapter 4 Generic Vector Class. Agenda A systemic problem with Vector of Object – Several approaches at a solution – Generic structures Converting classes.
Recitation 5 Enums and The Java Collections classes/interfaces 1.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
List Interface and Linked List Mrs. Furman March 25, 2010.
Efficient Logistic Regression with Stochastic Gradient Descent William Cohen 1.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Efficient Logistic Regression with Stochastic Gradient Descent
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
Lecture 9:FXML and Useful Java Collections Michael Hsu CSULA.
Apache Avro CMSC 491 Hadoop-Based Distributed Computing Spring 2016 Adam Shook.
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
Review of Java … or maybe not.
C++ -> Java - A High School Teacher's Perspective
An Introduction to Java – Part II
The Boolean (logical) data type boolean
Implementation Based on Inverted Files
Object Oriented Programming in java
Welcome to CSE 143! Go to pollev.com/cse143.
CS2011 Introduction to Programming I Objects and Classes
1.4 ทบทวน JAVA OO Programming Concepts Declaring and Creating Objects
Creating and Modifying Text part 3
Java: Variables, Input and Arrays
Presentation transcript:

Recitation for BigData Jay Gu Jan 10 HW1 preview and Java Review

Outline HW1 preview Review of java basics An example of gradient descent for linear regression in Java

HW1 Preview On ~1 million size data. Warm up exercise Stochastic Gradient Descent for Logistic Regression SGD with Hashing Kernel Extra credit: Personalized Logistic Regression

Starter Code – Class for parsing the input file and iterate over the dataset. Dataset dataset = new Dataset(your_path, is_training, size) While(dataset.hasNext()) { DataInstance d = dataset.next(); … some action on d … }

Starter Code public class DataInstance { int clicks; // number of clicks, -1 if it is testing data. int impressions; // number of impressions, -1 if it is testing data. // Feature of the session int depth; // depth of the session. int[] query; // List of token ids in the query field // Feature of the ad …. // Feature of the user …. }

Starter Code public class Weights { double w0; /* * query.get("123") will return the weight for the feature: * "token 123 in the query field". */ Map query; Map title; Map keyword; Map description; double wPosition; double wDepth; double wAge; double wGender; }

BigData is often sparse Be as lazy as you can … Update only when necessary…

Avoid O(d): Sparse and lazy update Although the feature space d is huge, each data point only has a few tokens. – Only update what is changed. But even so, regularization should be applied to all d weights at each step. – Delay and batch the regularization.

Java Review Not required but good to know: Interface, Inheritance, Access Modifier, I/O,… Language: Class, Object, variable, method Data Structure: Java Collections – Array – List : ArrayList – Map: HashMap

Class public class DataInstance { // Feature of the session int[] query …. // Feature of the ad int[] title … DataInstance(String line, … ) { // parse the line, and set the field } public void print() { System.out.println( “title: “); for (int token : title) System.out.print(token + “\t”); } Members or fields Constructor Method

Object DataInstance data = new DataInstance(); int clicked = data.clicked data.print()

Collections Array – int[] tokens – double[] weights ArrayList – ArrayList HashMap – HashMap Fixed Length, Most compact Dynamically Increasing (double the size every time) Constant time key value look up Dynamically Increasing, use more memory

Variables “Everything” in Java is an Object – Except for primitive types : int, double All object variables are reference/pointers to the Object Function passes variables by value

Example: SGD for linear regression Demo