MODULE IAA
(ML-PYTHON)
PR ESENTED BY: K H OUM S I M A NE
INTRODUCTION TO
PYTHON
Hi g h- l evel , v ers a ti l e p rogra mmi n g l a n gua ge
R eadabl e and us er- f ri en dl y
Ex t ensi ve l i b ra ri es a n d p a ck a ges
I de al f or web dev el op me n t , d a t a s ci en ce,
aut omati on, AI , a n d more
S i mpl e and e l eg a n t s yn ta x
Fr e e and ope n s ourc e
Lar g e, suppo rti v e c ommun i t y
PYTHON
INSTALLATION
Steps to install Python:
Downl oad Pyth on : http s: / / www. p yth on . org/ d own l oa d s /
R un t he I nsta l l er
Ver i f y the I n s ta l l a ti on : ( pyt h on --v ers i on or pyt ho n3 --v er sio n)
Lat est Python v ers i on 3 . 1 2 . . .
PYTHON I DEs :
Python Basics
1 PR I NTI NG TO T H E CO NSO L E :
2 READI NG AN I N PU T
Python Basics
1 VAR I ABLES AN D D AT A TY P E S:
2 ARI THMETI C O PER AT I O N S
Python Basics
4 LI S TS
5 TUPLES
6 DI CTI ONARI ES
Python Basics
7 CONDI TI ON AL S T AT EME N T
Python Basics
7 F OR LOOP
8 WHI LE LOOP
Python Basics
7 CONTI NUE A N D B R EAK STA TE ME N T
Python Basics
7 F UNCTI ONS
The r e e xi st o t he r pr e de fi ne d funct i ons l i k e : l e n(),
r a nge ( ) , sum ( ) , ma x( ) , mi n( ) , r ound ( ) , i nt ( ) , s t r ( ) ,
a pp e nd( ) . . .
Python Basics
7 FILES
Fi l es are ver y us ef ul , es peci a l l y wh en t h e v ol um e o f d a ta i s i mportant .
Ex ampl es of op era ti on s : ope n( ) , c l os e ( ) . .
Python Basics
7 CSV
Usi ng the cs v modul e i n P yt h on , you ca n ea s i l y rea d f r o m a nd w r ite to
CS V f i l es.
Python Basics
7 CSV
Usi ng the cs v modul e i n P yt h on , you ca n ea s i l y rea d f r o m a nd w r ite to
CS V f i l es.
PACKAGES AN D L I B R ARIE S
WHAT ARE PACKAGES?
A package is a way to organize related Python modules
Example: math package
PACKAGES AN D L I B R ARIE S
PYTHON LIBRARIES
A library is a collection of pre-written code/modules
Example: Numpay, Pandas, Requests, Datetime, Json,Scikit-learn...
ARR AYS AND N U MPY
ARR AYS AND N U MPY
PANDAS AN D D AT A MAN IP U L A TIO N
Pandas i s a p o pu l a r Pyt hon l i b r ar y t hat i s w i d e l y u se d for data
mani p ul at i on a nd a na l ysi s . It p r ov i d e s d at a s t r uctu re s l i ke S e ri e s
and Dat aFr a me
LINEAIR REGRESSION
Li ne ar r e gr e s s i o n i s a s t at i s t i cal me t hod us e d t o mode l th e re l ati on sh i p
be t we e n one o r mo r e i n d e p e nd e nt v ar i ab l e s and a de pe n de n t vari abl e . us i ng
var i ous l i br ar i e s s u c h a s N umP y , P and as , and s c i ki t- l e arn .
LINEAIR REGRESSION
Li ne ar r e gr e s s i o n i s a s t at i s t i cal me t hod us e d t o mode l th e re l ati on sh i p
be t we e n one o r mo r e i n d e p e nd e nt v ar i ab l e s and a de pe n de n t vari abl e . us i ng
var i ous l i br ar i e s s u c h a s N umP y , P and as , and s c i ki t- l e arn .
REGRESSI ON
I n t hi s e xam pl e , w e f i rs t g e ne r at e s ome r and o m data for de mon strati on pu rpose s.
The n, we pe r f o r m bo t h l i ne ar r e g r e s s i on and mu l ti pl e re g re ssi on on th e data u si n g
t he Li ne ar Re g r e s s i o n cl as s fr om s ci k i t - l e ar n. T h e code pri n ts th e i n te rce pt an d
c oe ffi c i e nt s f o r bo t h t he l i ne ar and mul t i p l e r e g re ssi on mode l s.