Skip to main content

Posts

Regularization in Deep Learning / Machine Learning - Prevent Overfitting

image source: mlexplained Overfittng happens in every machine learning (ML) problem.  Learning how to deal with overfitting is essential to mastering machine learning.  The fundamental issue in machine learning is the tension between optimization  and generalization. Optimization refers to the process of adjusting a model to get the  best performance possible on the training data (the learning in machine learning ),  whereas generalization refers to how well the trained model performs on data it has  never seen before . The goal of the game is to get good generalization, of course, but you don’t control generalization; you can only adjust the model based on its training  data.  The processing of fighting overfitting is a way  called regularization . [1].  How do you know whether a model is overfitting? The best initial method is to measure error on a training and test set. If you see a low error on the training set and...

Encapsulation VS Abstraction in Object-Oriented Programming

Encapsulation  binds together the data and functions that manipulate the data, keeping it safe from interference and misuse. Real-World Example:   Every time you log into your email account( Gmail, Yahoo, Hotmail or official mail), you have a whole lot of processes taking place in the backend, that you have no control over. So your password, would probably be retrieved in an encrypted form, verified and only then you are given access. You do not have any control, over how the password is verified, and this keeps it safe from misuse. Abstraction  is a process of hiding the implementation from the user, only the functionality is exposed here. So you are aware only of what the application does, not how it does it. Real-World Example:   When you log into your email, compose and send a mail. Again there is a whole lot of background processing involved, verifying the recipient, sending a request to the email server, sending your email. Here you are only interested in compo...

Lambda, Map, and Filter in Python

Lambda: Lambda functions are known as the anonymous functions in Python. This kind of functions are declared without any name. Can accept any number of argument.  Restricted to only a single expression.  Used only one-time. Lambda function is used when you need a function for a short period of time.  Basic syntax:  lambda arguments : expression Example: Map: Map is a built-in function that takes a function object and iterable list (list/dictionary) as its parameter. Basic syntax: map (function_object, iterable_1, iterable_2, ... ) Few examples of Map in python: Filter: It works similar way like map. The difference is it makes a new list from the element in the list that satisfy some condition . In case of of parameters, it takes a function and one iterable. Basic syntax: filter (function, iterable) Normally used with lambda functions. Example is given below:

Differences between MVC and MVT framework

MVC (Model-View-Controller) is a software design pattern for developing web applications. It consists of the following parts: Model : It is responsible for managing data of the application. It can be a database, a single object, or some structure of objects etc. It can also have logic to update controller if its data changes. View : View represents the visualization of the data that a model contains. It is responsible for which data should be displayed for a particular request.  Controller : It connects the View with the Model. It controls the data flow and keeps Model and View separate. It is responsible for responding to the user input and perform interactions on the data model objects.  Django - MVT (Model-View-Template ) pattern is slightly different from MVC pattern. The main difference is Django itself take care of the Controller part. In the Template, it's just HTML file mixed with DTL - Django Template Language. 

Python's Web Framework - Django Fundamentals

image source: djangoproject What is  middleware in Django? A middleware is a class with methods that are globally executed  during the request or response phase. For example, Django includes a middleware component called AuthenticationMiddleware which associates users with requests using sessions. See Doc .  What are the models added by the Django authentication framework? Django authentication framework includes the following models: User : A user model with basic fields; the main fields of this model are username , password , email , first_name , last_name , and is_active. Group : A group model to categorize users. Permission : Flags for users or groups to perform certain actions. Which parameters is accepted by the render method? (django.shortcuts -> render)? Render accepts three parameter. (request, template_name, context) For example: return render(request, 'account/login.html', {'form': form}) What is SMTP  and why do we use i...

Database - SQL fundamental concepts

The difference of null, zero and blank space:   They are not the same. The null value is a value which is unavailable, unassigned, unknown or not applicable. Zero is a number and blank space is a character. DDL, DML and DCL commands : DDL(Data Definition Language): CREATE, ALTER, DROP  [CAD] DML(Data Manupulation language): SELECT, INSERT, DELETE, UPDATE [SIDU] DCL (Data Control Langauge):   GRANT, REVOKE Grant and Revoke: Grant gives a privilege to the user and revoke takes back privileges granted from the user. ACID property in a database:    A transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability − commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity. A: Atomicity: This property states that a transaction must be treated as an atomic unit, that is, either all of its operations are executed or none. Refers to the transactions which are either comp...

Difference between abstract class and interface in OOP

Source: Amit Sethi In Interface: > All variables must be public static final. > No constructors. An interface can not be instantiated using the new operator.   > All methods must be public abstract .