# Week 1 Note ( Acumos ) ## Name : Christofel Rio Goenawan ## University : Bandung Institute of Technology (ITB) ## Date : 6/1/2020-11/1/2020 ## Objective : 1. Understand some famous open source package in Python to implement machine learning model. 2. Understand how to use package in Python to implement machine learning model. 3. Understand advantage and disadvantage of some machine learning package in Python and how it works. ## 1. Package for Machine Learning in Python Because of complexity in machine learning algorithm it's hard to make ML model from scratch. Hence some organization in the world make some open source package in Python so create ML model can be easier and user can more focus on another things like best parameter etc. There are a lot of ML package in Python in the world. 1. TensorFlow 2. Keras 3. ScikitLearn 4. PyTorch 5. Theano 6. OpenCV 7. etc Three most famous and usually used package is TensorFlow, Keras , and ScikitLearn. #### 1. TensorFlow ![](https://i.imgur.com/kxW9BHt.png =300x) \ TensorFlow is an end-to-end python machine learning library for performing high-end numerical computations. TensorFlow can handle deep neural networks for image recognition, handwritten digit classification, recurrent neural networks, NLP (Natural Language Processing), word embedding and PDE (Partial Differential Equation). TensorFlow Python ensures excellent architecture support to allow easy computation deployments across a wide range of platforms, including desktops, servers, and mobile devices. Abstraction is the major benefit of TensorFlow Python towards machine learning and AI projects. This feature allows the developers to focus on comprehensive logic of the app instead of dealing with the mundane details of implementing algorithms. With this library, python developers can now effortlessly leverage AI and ML to create unique responsive applications, which responds to user inputs like facial or voice expression. #### 2. Keras ![](https://i.imgur.com/qURPCRH.png =300x) \ Keras is a open source Python library written for constructing neural networks and machine learning projects. It can run on Theano or TensorFlow. It offers almost all standalone modules including optimizers, neural layers, activation functions, initialization schemes, cost functions, and regularization schemes. It makes it easy to add new modules just like adding new functions and classes. As the model is already defined in the code user don’t need to have a separate model config files. Keras Python also deals with convolution neural networks. It includes algorithms for normalization, optimizer, and activation layers. Instead of being an end-to-end Python machine learning library, Keras functions as a user-friendly, extensible interface that enhances modularity & total expressiveness. #### 3. ScikitLearn ![](https://i.imgur.com/VqjCinc.png =300x) \ Scikit-learn is another prominent open-source Python machine learning library with a broad range of clustering, regression and classification algorithms. DBSCAN, gradient boosting, random forests, vector machines, and k-means are a few examples. It can interoperate with numeric and scientific libraries of Python like NumPy and SciPy. This package is most used package for ML product. There are a lot of benefit in this package such reduction dimensionality , advance probably modelling etc. To apply machine learning in Python it can be hard in the script because we cannot watch the process easily. Then usually people use Python notebook to apply ML. Most famous Python notebook for data analysis and ML model in Jupyter Notebook. \ ![](https://i.imgur.com/9DJ6wUn.png =300x) \ ![](https://i.imgur.com/6NXIfpM.png =500x) \ Jupyter notebook make data analysing easier because we can process the data without make entire script but only needed part. ## 2. Implement Machine Learning model in Python using Package To implement ML using package in Python there are several ways depend on the package we used because although they usually use same algorithm they have different partition of function to create the model. ### a. Implement Scikit Learn To implement sckit learn in ML there are some step to do that. 1. Import the Needed Package, ex : for XGBoost model import xgboost 2. Create ML task depend on the model user want and needed parameter or default. 3. Train the model by input data ( data train ) and particular eval metrics. 4. Create prediction of data that want to be predict ( data target ) Writer try to implement the scikit learn package with xgboost classifier model and this is what writer got. ![](https://i.imgur.com/K1cRKYT.png) ![](https://i.imgur.com/b9zQ1zQ.png) ### b. Implement Tensor Flow To implement tensor flow in ML there are some step to do that. 1. Import the Needed Package 2. Launch Session. 3. Initialized Variables. 4. Run session by iterayion. Writer try to implement the tensorflow package for image recognition and this is what writer got. ![](https://i.imgur.com/lkY1dWS.png) ## 3. Comparison of Some Machine Learning Packages TensorFlow is a library for array data calculations and computations that can be used to conduct neural network and deep learning. It provides low level programming to work with mathematics as well as methods for defining neural network layers. Advantage of TensorFlow can be described as below. 1. Easy Model Building: TensorFlow offers multiple levels of abstraction to build and train models. 2. Robust ML Production Anywhere: TensorFlow lets you train and deploy your model easily, no matter what language or platform you use. 3. Powerful Experimentation For Research: TensorFlow gives you the flexibility and control with features like the Keras Functional API and Model Subclassing API for creation of complex topologies. TensorFlow doesn't provide other machine learning method, like decision tree, logistic regression, k-means or PCA. The ecosystem of Tensor Flow can be explained with this diagram. \ ![](https://i.imgur.com/vpGBWxh.png =400x) \ Keras is a high-level neural networks library which is running on the top of TensorFlow, CNTK, and Theano. Using Keras in deep learning allows for easy and fast prototyping as well as running seamlessly on CPU and GPU. This framework is written in Python code which is easy to debug and allows ease for extensibility. The main advantages of Keras are described below: 1. User-Friendly: Keras has a simple, consistent interface optimized for common use cases which provides clear and actionable feedback for user errors. 2. Modular and Composable: Keras models are made by connecting configurable building blocks together, with few restrictions. 3. Easy To Extend: With the help of Keras, you can easily write custom building blocks for new ideas and researches. 4. Easy To Use: Keras offers consistent & simple APIs which helps in minimizing the number of user actions required for common use cases, also it provides clear and actionable feedback upon user error. The difference of Keras and Tensor Flow can be describe in this diagram. \ ![](https://i.imgur.com/SM5vTdb.png =400x) Scikit-learn is a library for data mining and machine learning. It provides machine learning methods, including various supervised and unsupervised learnings. On the contrary to TensorFlow, it doesn't have deep learning framework.The advantage of scikit learn can be seen below. 1. Most Simple package in Python to create ML model. 2. Provide all ML model (because of open source)