Introduction to Big Data and Machine Learning Preliminaries
- Dr. Mihail
August 20, 2019
(Dr. Mihail) Intro Big Data August 20, 2019 1 / 2
Introduction to Big Data and Machine Learning Preliminaries Dr. - - PowerPoint PPT Presentation
Introduction to Big Data and Machine Learning Preliminaries Dr. Mihail August 20, 2019 (Dr. Mihail) Intro Big Data August 20, 2019 1 / 2 Big Data Course The plight of the professor I have to develop a structured learning framework for
(Dr. Mihail) Intro Big Data August 20, 2019 1 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 2 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 2 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 2 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 2 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 2 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 2 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 3 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 3 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 3 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 3 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 3 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 4 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 5 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 6 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 7 / 2
> > > sample = [ 1 , [” another ” , ” l i s t ” ] , (” a ” , ” t u p l e ” ) ] > > > m y l i s t = [” L i s t item 1” , 2 , 3 . 1 4 ] > > > m y l i s t [ 0 ] = ” L i s t item 1 again ” # We’ re changing the item . > > > m y l i s t [−1] = 3.21 # Here , we r e f e r to the l a s t item . > > > mydict = {”Key 1”: ” Value 1” , 2: 3 , ” p i ” : 3.14} > > > mydict [” p i ”] = 3.15 # This i s how you change d i c t i o n a r y v a l u e s . > > > mytuple = (1 , 2 , 3) > > > myfunction = l e n > > > p r i n t ( myfunction ( m y l i s t )) (Dr. Mihail) Intro Big Data August 20, 2019 8 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 9 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 10 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 11 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 12 / 2
# Same as def f u n c v a r ( x ) : r e t u r n x + 1 f u n c v a r = lambda x : x + 1 > > > p r i n t ( f u n c v a r ( 1 ) ) 2 # a n i n t and a s t r i n g are
they have d e f a u l t v a l u e s # i f
i s not passed (2 and ”A d e f a u l t s t r i n g ” , r e s p e c t i v e l y ) . def passing example ( a l i s t , a n i n t =2, a s t r i n g =”A d e f a u l t s t r i n g ” ) : a l i s t . append (”A new item ”) a n i n t = 4 r e t u r n a l i s t , a n i nt , a s t r i n g > > > m y l i s t = [ 1 , 2 , 3] > > > my int = 10 > > > p r i n t ( passing example ( m y l i s t , my int ) ) ( [ 1 , 2 , 3 , ’A new item ’ ] , 4 , ”A d e f a u l t s t r i n g ”) > > > m y l i s t [ 1 , 2 , 3 , ’A new item ’ ] > > > my int 10 (Dr. Mihail) Intro Big Data August 20, 2019 13 / 2
def some function ( ) : t r y : # D i v i s i o n by zero r a i s e s an e x c e p t i o n 10 / 0 except Z e r o D i v i s i o n E r r o r : p r i n t (” Oops , i n v a l i d . ” ) e l s e : # Exception didn ’ t
we ’ re good . pass f i n a l l y : # This i s executed a f t e r the code block i s run # and a l l e x c e p t i o n s have been handled , even # i f a new e x c e p t i o n i s r a i s e d w h i l e h a n d l i n g . p r i n t (”We’ re done with that . ” ) > > > some function () Oops , i n v a l i d . We’ re done with that . (Dr. Mihail) Intro Big Data August 20, 2019 14 / 2
import p i c k l e m y l i s t = [” This ” , ” i s ” , 4 , 13327] # Open the f i l e C:\\ b i n a r y . dat f o r w r i t i n g . The l e t t e r r b e f o r e the # f i l e n a m e s t r i n g i s used to prevent b a c k s l a s h e s c a p i n g . m y f i l e = open ( r ”C:\\ b i n a r y . dat ” , ”wb”) p i c k l e . dump( myli st , m y f i l e ) m y f i l e . c l o s e ( ) m y f i l e = open ( r ”C:\\ t e x t . t x t ” , ”w”) m y f i l e . w r i t e (” This i s a sample s t r i n g ”) m y f i l e . c l o s e ( ) m y f i l e = open ( r ”C:\\ t e x t . t x t ”) > > > p r i n t ( m y f i l e . read ( ) ) ’ This i s a sample s t r i n g ’ m y f i l e . c l o s e ( ) # Open the f i l e f o r r e a d i n g . m y f i l e = open ( r ”C:\\ b i n a r y . dat ” , ” rb ”) l o a d e d l i s t = p i c k l e . load ( m y f i l e ) m y f i l e . c l o s e ( ) > > > p r i n t ( l o a d e d l i s t ) [ ’ This ’ , ’ i s ’ , 4 , 13327] (Dr. Mihail) Intro Big Data August 20, 2019 15 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 16 / 2
(Dr. Mihail) Intro Big Data August 20, 2019 17 / 2