Publicité
Publicité

Contenu connexe

Publicité

ANN-Lecture2-Python Startup.pptx

  1. ATNW-4118 Artificial Neural Networks BSCS-8 / BSSE-8 Lecture # 2
  2. Python Introduction • Interpreted high-level programming language for general-purpose programming • Developed by Guido van Rossum • First released in 1991 • Free ware • Determines variable types implicitly • Relies on indentation as a control structure • Developer is not forced to define classes • By default installed on Mac OS X and Linux • Using Windows, download the latest version of Python from: • http://www.python.org • For Jupyter notebook: • https://jupyter.org/install Instructor: Tanzila Kehkashan 2
  3. Python IDEs • Spyder • Open source cross-platform IDE for data science • Integrates the essentials libraries for data science, such as NumPy, SciPy, Matplotlib and IPython • Jupyter Notebook • It is a web application based on the server-client structure, and it allows you to create and manipulate notebook documents - or just “notebooks”. • RStudio • IDE for R, a programming language for statistical computing and graphics • Orange • Open-source data visualization, machine learning and data mining toolkit • VSCode • Includes support for debugging, embedded Git control and GitHub, syntax highlighting, intelligent code completion, snippets, and code refactoring Instructor: Tanzila Kehkashan 3
  4. Python Libraries 1. TensorFlow • developed by Google • Is used in almost every Google application for machine learning • For writing new algorithms that involve a large number of tensor operations • Easily Trainable on CPU as well as GPU for distributed computing • You can train multiple neural networksand multiple GPUs which makes the models very efficient on large-scale systems 2. Scikit-Learn • Associated with NumPy and SciPy • Contains a numerous number of algorithms for implementing standard machine learning and data mining tasks like reducing dimensionality, classification, regression, clustering, and model selection. • Cross-validation: There are various methods to check the accuracy of supervised models on unseen data • Offers many unsupervised learning algorithms e.g; clustering, factor analysis, principal component analysis to unsupervised neural networks. Instructor: Tanzila Kehkashan 4
  5. Python Libraries • Useful for Feature Extraction from images and text (e.g. Bag of words) 3. Numpy • TensorFlow and other libraries uses Numpy internally for performing multiple operations on Tensors. • Array interface is the best and the most important feature of Numpy. • Can be utilized for expressing images, sound waves, and other binary raw streams as an array of real numbers in N-dimensional. 4. Keras • Provides some of the best utilities for compiling models, processing data-sets, visualization of graphs, and much more • Keras is comparatively slow • runs smoothly on both CPU and GPU • In use at Netflix, Uber, Yelp, Instacart, Zocdoc, Square, and many others. • Popular among startups that place deep learning at the core of their products. • provides many pre-processed data-sets and pre-trained models like MNIST, VGG, Inception, SqueezeNet, ResNet etc Instructor: Tanzila Kehkashan 5
  6. Python Libraries 5. PyTorch • primarily used for applications such as NLP • It is primarily developed by Facebook’s artificial-intelligence research group and Uber’s “Pyro” software for probabilistic programming is built on it. 6. LightGBM, XGBoost, and CatBoost • helps developers in building new algorithms by using redefined elementary models and namely decision trees. 7. Eli5 • Mathematical applications which requires a lot of computation in a short time 8. SciPy • SciPy library contains modules for optimization, linear algebra, integration, and statistics • Solving mathematical functions • Tasks including linear algebra, integration (calculus), ordinary differential equation solving and signal processing Instructor: Tanzila Kehkashan 6
  7. Python Libraries 9. Theano • For computing multidimensional arrays • Can also be used on a distributed or parallel environments just similar to TensorFlow 10.Pandas • Have so many inbuilt methods for grouping, combining data, and filtering, as well as time-series functionality • Re-indexing, Iteration, Sorting, Aggregations, Concatenations and Visualizations 11.NLTK • Natural language toolkit and commonly called the mother of all NLP libraries. • It is one of the mature primary resources when it comes to Python and NLP. Instructor: Tanzila Kehkashan 7
  8. Python Commands Arithmetic Operators • +, - , /, *, ** Comments • # this is single line comments • “““ this is multiline comments””” Instructor: Tanzila Kehkashan 8
  9. range() Function • Generates arithmetic progressions Control Flow – for statement Instructor: Tanzila Kehkashan 9
  10. Control Flow – for statement Sr.No. Control Statement Description 1 break statement Terminates loop statement and transfers execution to statement immediately following loop. 2 continue statement Causes loop to skip remainder of its body and immediately retest its condition prior to reiterating. 3 pass statement Pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute. Instructor: Tanzila Kehkashan 10
  11. Defining Functions >>> def f(x): ... return x*x ... Function header Function body >>> f(2) 4 >>> f(2.5) 6.25 Function call def function-name(Parameter list): statements, i.e. the function body • Syntax • Example • Arbitrary Number of Parameters def arbitrary(x, y, *more): print "x=", x, ", y=", y print "arbitrary: ", more >>> arbitrary(3,4) x= 3 , y= 4 arbitrary: () >>> arbitrary(3,4, "Hello World", 3 ,4) x= 3 , y= 4 arbitrary: ('Hello World', 3, 4) Instructor: Tanzila Kehkashan 11
  12. Defining Functions Instructor: Tanzila Kehkashan 12
  13. Modules (files) • Use any text editor to type the code into a file with extension .py • To test the code, import it into a Python session and try to run it • indentation is still important • Syntax • File’s extension (.py) is omitted in the import command from file-name import function-name Instructor: Tanzila Kehkashan 13
  14. Python Built-in Data Structures • Lists are enclosed in brackets. Tuples are enclosed in parentheses. Dictionaries are built with curly brackets. l = [1, 2, "a"] t = (1, 2, "a") d = {"a":1, "b":2} Data Structure Sequence Data Can Contain 1 Lists Ordered Mutable Any type of objects 2 Tuples Ordered Immutable Any type of objects 3 Strings Ordered Mutable Only characters 4 Dictionaries Unordered Keys immutable Any type of objects 5 Sets Unordered Mutable Any type of unique objects 6 Frozensets Unordered Immutable Any type of unique objects Instructor: Tanzila Kehkashan 14
  15. Instructor: Tanzila Kehkashan 15
Publicité