Start learning from best platform

Study any topic, anytime. explore thousands of courses for the lowest price ever!

15 Online courses

Explore a variety of fresh topics

Expert instruction

Find the right course for you

Lifetime access

Learn on your schedule

Latest blogs

PostgreSQL vs. MySQL: Which SQL Platform Should You Use?

Created by - admin admin

PostgreSQL vs. MySQL: Which SQL Platform Should You Use?

MySQL and PostgreSQL are both leading database technologies built on a foundation of SQL: Structured Query Language. SQL forms the basis of how to create, access, update, and otherwise interact with data stored in a relational database. While MySQL has been the most popular platform for many years, PostgreSQL is another major contender. Many database administrators and developers will know both technologies, which are much more similar than they are different. You can learn more about the history of SQL and how the various “flavors” came to be by watching this brief video:Depending on what you’re trying to create, the data you’re trying to manage, and your own background as a programmer or analyst, you may find one language preferable over the other. But in terms of popularity and marketability, both are widely used, with MySQL maintaining the advantage here. Compared to PostgreSQL, MySQL has the largest market share and, therefore, the most job opportunities.Here’s what you need to know about MySQL vs. PostgreSQL — the differences, benefits, and disadvantages — as well as some basic information about SQL and database platforms.What is SQL? Learning standard SQL syntaxBoth MySQL and PostgreSQL are implementations of SQL. Syntactically, they are almost identical. I often tell students the syntax is roughly 95% similar, with minor differences. Despite this, many consider PostgreSQL to be a more advanced database than MySQL — while MySQL is easier, has a lower barrier to entry, and greater levels of adoption.Notably, PostgreSQL supports partial, bitmap, and expression indexes. It also provides for table inheritance and materialized views. PostgreSQL is an object-based relational database rather than just a relational database, and many of its advanced features relate to this. However, many developers and analysts will never need these advanced features.That being said, the SQL used in MySQL and PostgreSQL will be nearly identical in terms of syntax. That means that anyone learning SQL will be able to use both products — it’s merely a question of what features and customizations are available to them. Someone who is trying to create data, query data, or delete data from either platform will be writing the exact same queries in most cases, with minor variations in syntax being the exception and not the rule. For example, the “Big 6” of SQL will be exactly the same across both MySQL and PostgreSQL, as well as other syntax languages: Many developers and analysts use MySQL first because it does have a lower barrier to entry and is very intuitive. There is nothing stopping developers from then moving onto PostgreSQL if they find themselves in need of those features. In fact, almost all of the concepts and query syntax learned in MySQL will be transferable to PostgreSQL or any of the other SQL platforms if you end up switching later on, like I did when changing employers. Advanced data types, such as arrays, hstore, and user-defined types, may be important for some developers — but may be entirely non-essential for others.It is important to remember that both MySQL and PostgreSQL are SQL products — with all the advantages and drawbacks this engenders. Both will be vulnerable to SQL injection, a common hacking technique. Both will use the same general syntax, protocols, and best practices. Having a non-standard form of database management can protect from SQL injection (which involves trying to run SQL statements in an unanticipated fashion through an application), but that may not be enough of a reason to choose an alternative SQL product. The differences between MySQL and PostgreSQLPostgreSQL first launched in 1996, and MySQL debuted in 1995. While similar in age, MySQL has been more popular for a significant amount of time. This is due to its accessibility as well as its status as an open-source solution; PostgreSQL only became open-source later.For the most part, the advantages of PostgreSQL are its greater control and customization of data sets, support for many languages, advanced security features, geo-tagging support, and superior resource management and load balancing. PostgreSQL is also known to be more standards-compliant. These are important features for large, enterprise-grade applications and proprietary software. But it’s not necessary for most situations — just areas in which data warehousing and data integrity are particularly important. In MySQL’s corner, the advantages are being fast, easy, and reliable. MySQL has an extensive amount of documentation and a very large community. It can be used for small and large applications alike and is extremely scalable. Learning MySQL makes for an easy entry point to SQL, and means that someone can move onto PostgreSQL or other SQL variations easily in the future. MySQL is well-supported by many programming languages and particularly popular with web applications.Right now, developers build 15.04 percent of their web applications on MySQL, and 5.2 percent on PostgreSQL, making MySQL about three times more popular. Popularity matters for a few reasons, including the availability of documentation, career options, and third-party support.Object-relational databases vs. relational databasesPostgreSQL is an object-relational database, whereas MySQL is a purely relational database. An object-relational database has object support — it is object-oriented in much the same way an object-oriented language is. Thus, PostgreSQL supports advanced features such as inheritance while MySQL does not. While MySQL doesn’t support inheritance, not every web application requires it. Furthermore, there are ways to model inheritance or support inheritance through code rather than directly through the database. Developers who want to work through MySQL with object-relational functionality and inheritance will need to program this in, but it still can be done — it just isn’t inherent with the platform.Apart from inheritance, the object-oriented approach and some advanced security features, the majority of how PostgreSQL interacts with data is identical to MySQL. Both PostgreSQL and MySQL will work essentially the same, using a SQL server and client along with modules for language support. Many developers and analysts would almost never notice any difference between the two platforms. Developing new web applications with MySQL or PostgreSQLAt the end of the day, most developers and analysts will support getting a project finished rather than getting it perfect. MySQL is easier to use and generally quicker to finish a project. Comparatively, new developers and analysts may find PostgreSQL’s learning curve too steep. PostgreSQL support may also not be as robust or active compared to the MySQL database community.MySQL can be easily installed either as a standalone product or as a stack, such as the LAMP stack. As of late, most web hosting packages come with MySQL databases included, which you can also get through platforms such as phpMyAdmin.With PostgreSQL, it’s more likely that you would need to run a virtual server and install PostgreSQL yourself, or you might need to set up a development machine. MySQL has the advantage here in terms of accessibility for new developers and analysts.That’s not to say that PostgreSQL can’t be the ideal solution for a given application, especially resource-intensive applications that may benefit from greater levels of security and superior load balancing. But MySQL does tend to be more accessible because it is more available.In addition to the platform itself, you will also need to consider what third-party applications and integrations you need for your infrastructure. For instance, you may already be developing an application that has some reliance or dependencies on MySQL technology. This is often more likely than PostgreSQL because MySQL is so popular within the open-source development community.Of course, you should also note that MySQL and PostgreSQL aren’t the only two solutions. Today, many Windows servers also come with Microsoft SQL, which has been catching up significantly in market share over the past decade. Still, for most developers (especially startups and solo developers), MySQL will be the most popular choice. Microsoft SQL is proprietary and therefore more expensive. You can use MySQL for free.Hosting your own database serversIn addition to paying for shared hosting, developers can also use Virtual Private Servers (VPS) or dedicated servers to run their SQL installations. Through a VPS or dedicated server, you’ll be able to control every element of your installation and your configuration. You can install the operating system, SQL platform, and compilers you need. A VPS or dedicated server is by far the more advanced option, but it’s also an excellent way to maintain complete control.When you have more freedom with your servers, you can also make different choices for your back-end database and operating systems. While most hosting services come with MySQL, you might be more interested in Microsoft SQL or PostgreSQL. In addition to a VPS or dedicated server, developers can also work on their own machines rather than going through a hosting service at all, but this generally isn’t a long-term solution.For beginners, using MySQL through a hosting service is usually more advantageous. Under managed hosting services, MySQL will automatically update for you, which will improve your security. And your hosting service will have balanced your technology, software, and hardware to provide better protection and performance. Further, it’s simpler; hosts have automated services designed to perform a significant amount of management for you.If you have a hosting package, you should make sure that MySQL or PostgreSQL will work with the resources allotted. If they don’t have the minimum server requirements or the right technology, your installation may not work. The advantage of hosting your own services or taking control over your hosting is that you have greater levels of flexibility and control. But the disadvantage is that it will take more time, and you won’t be able to automate as many of the services that could keep your server safe from potential intrusion.Working with open-source projects in MySQL and PostgreSQLOriginally, only MySQL was open-source. But today, even Microsoft has started to embrace open-source solutions. PostgreSQL became open-source within the last decade. Open-source technologies have a lot of advantages: They have broader communities, are more transparent, and are often better secured. With an open-source solution, the source code is available for everyone to look at and improve upon.Open-source technology is free, which means businesses can use MySQL and PostgreSQL for development without having to pay. That doesn’t, however, mean that there aren’t paid hosting services or paid options. Open-source technology often has far more third-party applications, modules, modifications, and utilities because developers can freely develop for it.MySQL is a leading database engine in no small part because it has been a leading open-source solution for a very long time. MySQL also has several security elements and redundancy options to protect data, even under a physical crash. Meanwhile, PostgreSQL has many advanced, enterprise-grade features still under an open-source structure.If you’re trying to choose between open-source platforms, you should first research support options for each database design. Both MySQL and PostgreSQL have thriving communities, but it’s undoubtedly true that there is more documentation and activity within the MySQL community. You may also want to look at the tools available for MySQL or PostgreSQL and the paid services available for either.Otherwise, developing for open-source applications does not have to be very different. You simply need to ensure that the technology you’re using is compatible with an open-source licensing model.MySQL and PostgreSQL compared to proprietary SQL databasesNot all leading database solutions are open-source. MySQL and PostgreSQL are leading open-source database solutions, while Microsoft SQL and OracleDB are both proprietary database solutions. There are advantages to using either.While Microsoft SQL and OracleDB may not be as affordable as MySQL or PostgreSQL, they generally come with superior levels of support when you pay for the proprietary solution. In general, proprietary SQL databases will be more suited to enterprise-grade applications, while MySQL will be better for smaller projects or those with budget considerations.MySQL is most often known as the back-end solution for WordPress sites. For these types of applications, it’s more than suitable — even for complex queries or many niche data types.Compared to MySQL and PostgreSQL, proprietary SQL platforms may have more features, more flexibility, and greater levels of reliability. While they may not have the extensive online documentation that open-source solutions have, they will usually have 24/7 available technical support. They are built to be secure, balance heavy loads, and deploy resources as needed.For nearly any small to mid-sized application, either MySQL or PostgreSQL should be suitable. But for those looking at extensive resource usage or building enterprise-level applications, Oracle or Microsoft SQL may be superior, especially in the long run.Asynchronous data calls for SQLPopular for both websites and networking projects (and, particularly, web applications), asynchronous calls let your database run queries without waiting for the previous query to finish. You can apply Asynchronous data calls to many types of code, including website code and SQL queries. PostgreSQL handles asynchronous database calls, and consequently, can be essential for high-traffic sites that need to manage a significant amount of load. Asynchronous calls are beneficial when you have several queries on one of your web pages that don’t depend on the others. This means that the query runs for one part of the page, and other queries can also run without waiting for the first to finish. The result is that your web pages can display data as the data set is returned without loading when it completes all of the queries. It’s not only a faster data query technique, but it’s also better for your website viewers. In the old days, you would likely see a blank page while all queries loaded. Today, you’ll start to see data right away.That being said, there are ways to support asynchronous calls (also known as async) within MySQL. There are a number of async libraries available, but this may take some additional work to implement. Learning MySQL or PostgreSQLWhether you’re interested in learning MySQL or PostgreSQL, the most important thing to keep in mind is that the two are extremely similar, and your skills will be transferable from one platform to the other. One of the fastest ways to learn is through an online course, boot camp, or workshop. SQL’s intuitive syntax makes it one of the least intimidating languages to learn, and allows it to serve as an excellent introduction to programming as a whole. Personally, I never studied computer science in school and was able to teach myself SQL and make it a cornerstone of my career. If I can do it, so can you! You can see how easy and intuitive the SQL syntax is by checking out this quick video on table creation: For analysts, learning SQL can go a long way toward making you marketable and increasing the value you can deliver to any organization. Almost any large company will be storing large amounts of data in a relational database and will need competent SQL analysts to help extract data and analyze it to steer business decisions. For developers implementing web applications that interface with SQL databases, you will also need to be well-versed in PHP, JavaScript, or a similar web-based language. Those who are implementing desktop applications may need to know Java or some variant of C. This language will control how calls are made to the database to introduce, access, and change the information.Once someone learns one of the SQL variants, they can likely successfully transition to any SQL-based platform. Whether the platform is PostgreSQL, Microsoft SQL, or some other SQL platform, the SQL syntax itself should be the same. However, developers may also need to learn the different ways of interfacing with that platform if they change languages, such as going from PHP to C++.Overview of the differences between MySQL and PostgreSQL Parameter PostgreSQL MySQL Architecture Multiprocess and object relational Single process and relational Data types Numeric, date/time, character, boolean, enumerated, geometric, network address, JSON, XML, HSTORE, arrays, ranges, composite Numeric, date/time, character, spatial, JSON Indexes B-tree, hash, GiST, SP-GiST, GIN, and BRIN Primarily B-tree; R-tree, hash, and inverted indexes Performance Capable of high-volume reads and writes Capable of high-volume reads Security Access control and multiple encrypted connection Access control and encrypted connections Support Community support of the default version and some support by companies that released custom versions Community support and support contracts through the vendor Open source Open source under the PostgreSQL license Open source under the terms of the GNU General Public License Best suited for Executing complex queries Where only fast reads are needed ACID compliance Fully ACID compliant ACID complaint with InnoDB and NDB Cluster Storage engines SQL compliance PostgreSQL is mostly SQL compliant MySQL is only partially SQL compliant JSON support Only JSON data type supportJSON data type support as well as indexing and some NoSQL features Only JSON data type support Ecosystem PostgreSQL has many third-party extensions that can add new features to it.  There are many variants of the MySQL database including Percona, MariaDB and Galera. Materialized view support Supports both temporary tables and materialized views Only support temporary tables Stack Overflow questions 152K 644K Github stars 9.9K 7.6K Github forks 3.2K 3K ConclusionSQL remains one of the most popular and flexible languages today. Not only is it fast and intuitive to learn, but it’s also a dynamic way of managing, controlling, and analyzing data. Learning SQL is something anyone can do, and it will help secure job opportunities and increase the value one can provide an organization.When it comes to SQL, you have a choice regarding the technology you use. You can use MySQL, Microsoft SQL, PostgreSQL, or any of the other top SQL platforms. Just remember, they are more similar than they are different, and the skills you learn on one platform will transfer well to each of the others. MySQL has long been considered one of the most flexible and accessible options; it’s easy to use, well-supported, and open-source.For experienced developers designing complex, large-scale applications, you may want to think long and hard about the feature sets of the various platforms and select the one that best suits your needs. For new developers and analysts looking to learn SQL, don’t overthink it. Focus on accessibility and just start learning. MySQL is a great option for beginners. It is a popular language, with free tools, great documentation, and a large community. For those who want to integrate database management into their web applications, or learn how to analyze data in relational databases, few technologies are better. Frequently Asked QuestionsWhich is easier to learn and use, PostgreSQL or MySQL?MySQL is generally easier to learn and use than PostgreSQL. You can find a lot of resources, help, and documentation online. PostgreSQL has more advanced functionality with a steeper learning curve.When should you use PostgreSQL?You should use PostgreSQL when you need a database that has advanced features and security or will be using complex SQL to access data.When should you use MySQL?You should use MySQL when you do not need to do advanced computations or run complex queries, but want fast access to simple data.Why is PostgreSQL popular?PostgreSQL is popular because it offers the advanced functionality and security features of many proprietary database management systems that require a license, but it is free and open source.Why is MySQL popular?MySQL is popular because it is open-source, easier to use than many other databases, and is available on just about any hosting platform. Its use in projects like WordPress and Drupal has also added to its popularity.  

More details

Published - Mon, 30 May 2022

60 Common C# Interview Questions in 2022: Ace Your Next Interview

Created by - admin admin

60 Common C# Interview Questions in 2022: Ace Your Next Interview

These questions can be hard to answer if you haven’t properly prepared. In this article, I’ll help you prepare to ace your next interview with these questions related to the C# programming language. At the same time, you might want to practice with some C# projects.These 50 essential C# questions and answers will help you understand the technical concepts of the language. You’ll walk into a meeting with the hiring manager with confidence. As a developer myself, I use these concepts daily. Complete C# MasterclassLast Updated May 2022·         282 lectures ·         All Levels  4.6 (19,673)Learn C# Programming – WPF, Databases, Linq, Collections, Game Development with Unity. More than just the C# basics! | By Denis Panjuta, Tutorials.eu by Denis PanjutaExplore CourseWhat is C#?C#, released in 2000, is a C-based programming language used for everything from desktop applications to web services. Today, C# is one of the most popular programming languages in the world — and it’s a language that is highly sought after in the programming field.C# differs from C++ in a few major ways. The most obvious is that C# is a component-based language, whereas C++ is an object-oriented language. C# is considered to be more heavyweight than C++, but it’s used in many modern systems, such as game development kits. Beginner C# Interview Questions and Answers1. What is a class?A class is a template to create an object. It contains properties as well as methods. We can create many instances of objects from a single class.Below is an example of a class: public class Student       {         //data members         public int rollNumber { get; set; }         public string fullName { get; set; }           //function         public void PrintDetails()         {             //login of function         }  } 2. What are the main concepts of object-oriented programming?Encapsulation, abstraction, polymorphism, and inheritance are the main concepts of object-oriented programming. Be prepared to describe each of these. Object-oriented programming differs from procedural programming insofar as procedural programming happens chronologically, step-by-step, whereas object-oriented programming is far more flexible.3. What is an object?An object is an instance of a class through which we access the functions of that class. We can use the “new” keyword to create an object. A class that creates an object in memory holds information about the functions, data members, and behavior of that class.See the syntax of an object below. //Class       public class Employee       {         //private members         private string fName { get; set; }         private string lName { get; set; }           //function         public void Display()         {             Console.WriteLine("Full name is {0} {1}", fName, lName);         }           public void SetName(string firstName, string lastName)         {             fName = firstName;             lName = lastName;         }       }         class Program       {         static void Main(string[] args)         {             //this is object             Employee employee = new Employee();             employee.SetName("John", "Grande");             employee.Display();         }       } 4. What is a constructor, and what are its different types?A constructor is like a method with the same name as the class, but it is a unique method. Even if it is not created, the compiler creates a default constructor in memory at the time of creating an object of the class.The constructor is used to initialize the object with some default values.Default constructor, parameterized constructor, copy constructor, static constructor, and private constructor are all different constructor types.Below are examples of different constructor types. public class Student       {         private int rollNumber { get; set; }         private string fullName { get; set; }           //default constructor         public Student()         {             //code goes here         }           //parameterized constructor         public Student(int rNum, string fName)         {             this.rollNumber = rNum;             this.fullName = fName;         }           //static constructor         static Student()         {             //code goes here         }           //copy constructor         public Student(Student student)         {             rollNumber = student.rollNumber;             fullName = student.fullName;         }  } 5. What is a destructor in C#?A destructor clears out the memory to free up resources and is managed automatically by the garbage collector. System.GC.collect() is called internally for this purpose. However, if required, it can be done explicitly using a destructor. public class Purchase       {         //Syntax to write a destructor.         ~Purchase()         {             //code here to release resources.         } } 6. Is C# code managed or unmanaged code?C# is managed code because Common Language Runtime compiles the code to intermediate language code. C++ would provide examples of unmanaged code. Managed code simply refers to code that has its execution managed by the runtime.7. What are value types and reference types?We can categorize variables into value type and reference type. Variables of value type contain the value directly while a reference type variable contains the reference of the memory address where the value is stored actually in the memory.Bool, byte, int, char, and decimal are value types.String, class, delegates are reference types.Below is the pictorial representation of the value type.Below is the pictorial representation of the reference type.8. What is a namespace and is it compulsory?A namespace is a way of organizing classes of the same group or functionality under the same name. We can call it a module. Although it is not compulsory to put class in a namespace.Refer to the syntax below. namespace demoapp {     class SomeClass     {         public static void someMethod()         {             Console.WriteLine("Creating my namespace");         }       } } 9. Explain types of comments in C# with examples.There are three types of comments in C#. Single line comments Multiline comments XML comments An example of a single-line comment is://Hey, this is a single line commentAn example of a multiline comment is:/*This is a multiline commentwritten in two lines2*/An example of an XML comment is:10. Please explain encapsulation.Encapsulation is a process of wrapping function and data members together in a class; it’s like a capsule, a single unit.Encapsulation prevents an unauthorized or unwanted change of data from outside of the function. It is used for better control and standardization of your code.Below is an example of encapsulation. class User       {         private string address;         private string name;         public string Address         {             get             {                 return address;             }             set             {                 address = value;             }         }         public string Name         {             get             {                 return name;             }             set             {                 name = value;             }         }     }     class MyProgram     {         static void Main(string[] args)         {             User u = new User();             // set accessor will invoke             u.Name = "Ravi";             // set accessor will invoke             u.Address = "New Delhi";             // get accessor will invoke             Console.WriteLine("Name: " + u.Name);             // get accessor will invoke             Console.WriteLine("Location: " + u.Address);             Console.WriteLine("\nPress Enter Key");             Console.ReadLine();         } } 11. What is an abstraction?Abstraction is the method of exposing only the required features of the class and hiding unnecessary information.We can try to understand it with the example of a motorbike:A rider knows the color, name, and model of the bike. Still, they do not know the internal engine and exhaust functionality. Likewise, abstraction focuses on providing access for a specific functionality without exposing how that functionality works internally.12. What is polymorphism?Polymorphism means the same method but different implementation. There are two types of polymorphism. Compile-time polymorphism is achieved by method overloading as seen in the example below.  public class cellphone       {         //function with the same name but different parameters.         public void Typing()         {             Console.WriteLine("Using keypad");         }           public void Typing(bool isSmartPhone)         {             Console.WriteLine("Using qwerty keyboard");         } } Run time polymorphism is achieved by method overriding as seen in the example below.  public class CellPhone       {         public virtual void Typing()         {             Console.WriteLine("Using keypad");         }       }         public class SmartPhone : CellPhone       {         //method override         public override void Typing()         {             Console.WriteLine("Typing function from child class");         } } 13. Define an interface and show an example. An interface is another form of an abstract class that has only abstract public methods. These methods only have the declaration and not the definition. A class implementing the interface must have the implementation of all the methods of the interface.For example: interface IPencil       {         void Write(string text);         void Sharpen(string text);       }         class Pencil : IPencil       {         public void Write(string text)         {             //some code here         }           public void Sharpen(string text)         {             //some code here         }       }         public class CellPhone       {         public virtual void Typing()         {             Console.WriteLine("Using keypad");         } } 14. What is inheritance?A class can inherit data members and methods from another class, which is known as its parent class. The class that inherits properties and methods will be called a child class, derived class, or subclass. Some properties can be overridden in the derived class.The ability to inherit characteristics from classes makes the entire process of managing classes much easier, as you can create subclasses that are customized. The originating class will be called either a parent class or base class.Refer to the below example: class Mobile  // base class (parent)       {         public void call()         {             Console.WriteLine("calling...!");         }       }         class Nokia : Mobile  // derived class (child)       {         public string modelName = "Nokia";       }         class MyProgram       {         static void Main(string[] args)         {             // Create a myNokia object             Nokia myNokia = new Nokia();               // Calls the call() method (From the Mobile class) on the myNokia object             myNokia.call();         } } Intermediate C# Programming Questions15. How would you implement multiple interfaces with the same method name in the same class?To implement multiple interfaces with the same method name, you would avoid implementation within the body of the function. Instead, you would explicitly provide the name of the interface to the body of the method. The compiler will understand which interface methods are being referred to, therefore resolving the issue.This can be seen in the following example: interface myInterface1       {         void Print();       }       interface myInterface2       {         void Print();       }       class Student : myInterface1,         myInterface2       {         void myInterface1.Print()         {             Console.WriteLine("For myInterface1 !!");         }         void myInterface2.Print()         {             Console.WriteLine("For myInterface2 !!");         } } 16. What is the virtual method and how is it different from the abstract method?A virtual method must have a default implementation, and we can override this virtual method using the override keyword in the derived class.The abstract method is without implementation and is created inside the abstract class only. In the case of an abstract class, the class derived from the abstract class must have an implementation of that abstract method.Here’s an example of virtual method: public class CellPhone       {         public virtual void Typing()         {             Console.WriteLine("Using old keypad");         }       }         public class SmartPhone : CellPhone       {         public override void Typing()         {             Console.WriteLine("Using qwerty keyboard");         } } Here’s an example of an abstract method: public abstract class CellPhones       {         //no default implementation         public abstract void Typing();       }         public class OldPhones : CellPhones       {         //function override         public override void Typing()         {             Console.WriteLine("Using keypad");         }       }         public class SmartPhones : CellPhones       {         //function override         public override void Typing()         {             Console.WriteLine("Using Qwerty keyboard");         } } 17. What is method overloading and method overriding?Both method overloading and overriding are a type of polymorphism. Method overloading is when we have a function with the same name but a different signature. Method overriding is when we override the virtual method of a base class in the child class using the override keyword. 18. What is the static keyword?We use the static keyword to create a static class, a static method, or static properties.When we create a static class there can be only static data members and static methods in that class.Static means that we cannot create the instance of that class. That class can be used directly like ClassName.methodName.When there is a need for special functions, which are typical for all the instances of other classes, then we use static class.For example, there is a requirement to load some default application-level values. We create a static class with static functions. That class is then accessible to all other classes without creating any instance. It also shares the same data with all the classes.Refer to the below example: public static class Setting       {         public static int fetchDefault()         {             int maxAmount = 0;             //code to fetch and set the value from config or some file.             return maxAmount;         }       }         public class Sales       {           //not required to create an instance.           int maxAmount = Setting.fetchDefault(); } 19. Can we use “this” with the static class?No.“This” cannot be used with a static class because we can only use static variables and static methods in the static class.20. What is the difference between constants and read-only?There are a few differences: Constant variables have to be assigned a value at the time of declaration only, and we cannot change the value of that variable throughout the program.  We can assign the value to the read-only variable at the time of declaration or in a constructor of the same class. Here is an example of constants: using System; namespace demoapp {     class DemoClass     {         // Constant fields         public const int myvar = 101;         public const string str = "staticstring";           // Main method         static public void Main()         {             // Display the value of Constant fields             Console.WriteLine("The value of myvar: {0}", myvar);             Console.WriteLine("The value of str: {0}", str);         }     } } Here is an example of read-only: using System; namespace demoapp {     class MyClass     {         // readonly variables         public readonly int myvar1;         public readonly int myvar2;           // Values of the readonly         // variables are assigned         // Using constructor         public MyClass(int b, int c)         {             myvar1 = b;             myvar2 = c;             Console.WriteLine("Display value of myvar1 {0}, " +              "and myvar2 {1}", myvar1, myvar2);         }           // Main method         static public void Main()         {             MyClass obj1 = new MyClass(100, 200);         }     } } 21. What is the difference between string and string builder in C#?A string is an immutable object. When we have to do some actions to change a string or append a new string it clears out the old value of the string object, and it creates a new instance in memory to hold the new value in a string object. It uses System.String class, for example. using System; namespace demoapp {     class StringClass     {         public static void main(String[] {             string val = "Hello";             //creates a new instance of the string             val += "World";             Console.WriteLine(val);         }     } } StringBuilder is a mutable object, meaning that it creates a new instance every time for the operations like adding string (append), replace string (replace). It uses the old object only for any of the operations done to the string and thus increases the performance. It uses System.Text.StringBuilder class, for example. using System; using System.Text; namespace demoapp {     class StringClass     {         public static void main(String[] {             StringBuilder val = new StringBuilder("Hello");             val.Append("World");             Console.WriteLine(val);         }     } } The output of both the program is the same, “Hello World.”22. Explain the “continue” and “break” statement.We can use continue and break statements in a loop in C#. Using a break statement, we can break the loop execution, while using the continue statement, we can break one iteration of the loop.Here’s an example of the break statement: using System; namespace demoapp {     class LoopingStatements     {         public static void main(String[] args)         {             for (int i = 0; i <= 5; i++)             {                 if (i == 4)                 {                     break; //this will break the loop                 }                 Console.WriteLine("The number is " + i);                 Console.ReadLine();             }  //control will jump here after the break statement.         }     } } Here is the same example with a continue statement: using System; namespace demoapp {     class LoopingStatements     {         public static void main(String[] args)         {             for (int i = 0; i <= 5; i++)             {                 if (i == 4)                 {                     continue;// it will skip the single iteration                 }                 Console.WriteLine("The number is " + i);                 Console.ReadLine();             }         }     } } 23. What are boxing and unboxing?Conversion of value type datatype to reference type (object) datatype is called boxing.For example: namespace demoapp {     class Conversion     {         public void DoSomething()         {             int i = 10;             object o = i;         }     } } Unboxing is the conversion of reference type datatype to value type.For example:  namespace demoapp {     class Conversion     {         public void DoSomething()         {             object o = 222;             int i = (int)o;         }     } } 24. What is a sealed class?We use a “sealed” keyword to create a sealed class. Classes are created as a sealed class when there is no need to inherit that further or when there is a need to restrict that class from being inherited.Refer to the syntax below. public sealed class MyClass {    //properties and methods } 25. What is a partial class?There is a feature in the C# language to divide a single class file into multiple physical files. To achieve this, we have to use the “partial” keyword. At compile time, it is logically one file only; we cannot have a method with the same name or a variable with the same name in two different partial class files. Here, to facilitate the developers to break down the big class files into multiple small physical files, this feature is provided.26. What is enum?The “enum” keyword is frequent across many languages. An enum is a type of value. It serves as a collection of related constants, which are referred to as an enumerated list. An enum can be int, float, double, or byte. But if it’s not an int, explicit casting is required.The .NET framework enum can be used to create a numeric constant. Int is the default of the enumeration element. By default, the first enumerator has the value 0, and each successive enumerator is increased by 1, much like an array.Refer to the below syntax:enum Day { Sat, Sun, Mon, Tue, Wed, Thu, Fri };27. What is dependency injection, and how can it be achieved?Dependency injection is a design pattern. Instead of creating an object of a class in another class (dependent class) directly, we are passing the object as an argument in the constructor of the dependent class. It helps to write loosely coupled code and helps to make the code more modular and easy to test.There are three ways to achieve dependency injection: Constructor injection: This is the most commonly used Injection type. In constructor injection, we can pass the dependency into the constructor. We have to make sure that we do not have a default constructor here, and the only one should be a parameterized constructor. Property injection: There are cases when we need the default constructor of a class, so in that case, we can use property injection. Method injection: In method injection, we need to pass the dependency in the method only. When the entire class does not require that dependency, there is no need to implement constructor injection. When we have a dependency on multiple objects, then instead of passing that dependency in the constructor, we pass that dependency in the function itself where it is required. 28. Please explain the “using” statement.The keyword “using” is used to define the scope of the resources used in that using statement block. All the resources used inside the using code block get disposed of once the code block completes execution.Refer to the below example. class Books : IDisposable       {         private string _name { get; set; }         private decimal _price { get; set; }           public Books(string name, decimal price)         {             _name = name;             _price = price;         }           public void Print()         {             Console.WriteLine("Book name is {0} and price is {1}", _name, _price);         }           public void Dispose()         {             throw new NotImplementedException();         }       }         class Students       {         public void DoSomething()         {             using (Books myBook = new Books("book name", 12.45))             {                 myBook.Print();             }         } } 29. What are the access modifiers? Explain each type.Access modifiers are keywords used to provide accessibility to a class, member, or a function.Below are its types: Public: Can be accessed anywhere without any restriction Protected: Access is limited up to the class, which inherits this class Internal: Can be accessed only within the current assembly Private: Cannot be accessed outside Syntax of access modifier: public class Product {         public void Print()         {             //code to print something.         } } 30. What are delegates?Delegates are like function pointers, it is a reference data type that holds the reference of a method. We use delegates to write generic type-safe functions. All delegates derive from System.Delegate.A delegate can be declared using the delegate keyword followed by a function signature, as shown below.These are the characteristics of delegates: Delegates derive from the System.Delegate class Delegates have a signature as well as return type. A function assigned to delegates must be fit with this signature Delegates can point to instance methods or static Delegate objects, once created, can dynamically invoke the methods it points to at runtime Delegates can call methods synchronously and asynchronously Refer to the below example: using System; namespace demoapp {     class DelegateClass     {         // declare delegate         public delegate void Print(int value);           static void Main(string[] args)         {             // Print delegate points to PrintNumber             Print printDel = PrintNumber;             // or             // Print printDel = new Print(PrintNumber);               printDel(100000);             printDel(200);               // Print delegate points to PrintMoney             printDel = PrintMoney;             printDel(10000);             printDel(200);         }           public static void PrintNumber(int num)         {             Console.WriteLine("Number: {0,-12:N0}", num);         }           public static void PrintMoney(int money)         {             Console.WriteLine("Money: {0:C}", money);         }     } } 31. What are the different types of delegates?There are three types of delegates:  Single delegates can invoke a single method Multicast delegates can invoke multiple methods. The delegate method can do multicasting. We can add a method in the delegate instance using + operator, and we can remove a method using – operator. All the methods are invoked in sequence as they are assigned. Generic delegates are introduced by .Net Framework 3.5. There is no need to create an instance in a generic delegate. 32. What is an array? Explain single and multi-dimensional arrays.The array stores the value of the same type. It is a collection of variable stores into a memory location.For example:int[] marks = new int[3] { 25, 34, 89 };A single-dimensional array is a linear array. Single-dimensional array stores variables in a single row. The above example is a single-dimensional array.Arrays can have more than one dimension. Multi-dimensional arrays are also called rectangular arrays.For example:int[,] numbers = new int[3, 2] { { 1, 2 }, { 2, 3 }, { 3, 4 } };33. What is the difference between the System.Array.CopyTo() and System.Array.Clone() ?Using the Clone() method, we can create a new array object containing all the elements of the original array and using the CopyTo() method. All the items of existing array copies into another existing array. Both ways create a shallow copy.34. What is the difference between array and ArrayList?An array and ArrayList are similar. When you want to store items of the same type, you can use an array. An array has a fixed size. When you want to store any type of data, we use an ArrayList. An ArrayList doesn’t have a fixed size.Refer to the example of an array and ArrayList: using System.Collections; namespace demoapp {     class Sample     {         //Array and Araraylist.         public void ArrayFunction()         {             string[] country = new string[3];             country[0] = "USA"; //only string value can be added             country[1] = "Denmark";             country[2] = "Russia";               //can store different data types             ArrayList arraylist = new ArrayList();             arraylist.Add(3);             arraylist.Add("USA");             arraylist.Add(false);         }     } } 35. What is a jagged array in C#?A jagged array is like a nested array where each element of a jagged array is an array in itself. The item of a jagged array can be of different dimensions and sizes.A jagged array is a special type of array introduced in C#. A jagged array is an array of an array in which the length of each array index can differ.Refer to the below example: namespace demoapp {     public class JaggedArrayClass     {         public void ShowJaggedArray()         {             int[][] jaddedArray = new int[2][];               jaddedArray[0] = new int[3] { 1, 2, 3 };               jaddedArray[1] = new int[4] { 1, 2, 3, 4 };         }     } } 36. What is the difference between struct and class?Class and struct are both user-defined but have significant differences.A struct inherits from System.Value type, thus it’s a value type. Structs are preferable when there is a small amount of data. A structure cannot be abstract. There is no need to create an object with a new keyword. Struct does not have permission to create any default constructor.Syntax of struct: struct MyStruct       {         public int MyProperty1 { get; set; }         public int MyProperty2 { get; set; } } A class is a reference type in C#, and it inherits from the System.Object Type. When there is a large amount of data, classes are used. We can inherit one class from another class. A class can be an abstract type.37. What is the difference between “throw” and “throw ex”?The “throw” statement will keep the original error stack of the previous function, while the “throw ex” statement will retain the stack trace from the throw point. Usually, it’s advised to use “throw” because it provides exact error information and trace data.38. Explain the difference between “finally” and “finalize block”?These are two different concepts, though they sound similar: Finally is a code block part of execution handling. This code block executes irrespective of whether the exception occurs or not. Finalize is a method called just before garbage collection. The compiler calls this method automatically when not called explicitly in code. Thus, finally is related to execution handling, whereas finalize is used relative to garbage collection.39. Explain var and dynamic.We can declare the var type of a variable without specifying the .net data types explicitly. The compiler automatically detects the type of a variable at the compile-time based on the value assigned to it. We cannot declare a var type variable without assigning a value to it. The value of the var type variable cannot be changed later in the code.Dynamic is the opposite of var. We can change the value of a variable of type dynamic in the code later. It also decides the type of the variable based on the value assigned to it. Like at the time of creating a variable of type dynamic, a value of integer type is assigned to it, then also in the code further, we can assign a string type value to that variable. It holds the last changed value and acts like the data type of the latest values it holds.Let us see the example to understand it in more detail. public class Bike       {         dynamic someValue = 21;           public Bike()         {             //assigned string value later             someValue = "Hello";         } } In the above example, if we declare the variable “someValue” to type var instead of dynamic, it throws an error. The reason for that error is that in the next line, we changed the value of the variable and assigned a string value.Advanced C# Programming Questions40. What are Anonymous types in C#?Sometimes we may need to create a new type without defining it. This will be known as an anonymous type. This is helpful when there is a need to define read-only properties in a single object without defining each type. Here, a compiler generates type and is accessible only for the current block of code.Refer to the below example. public class SomeClass       {      public void print()      {         var anonymousData = new         {              FirstName = "John",              SurName = "lastname"         };          Console.WriteLine("First Name : " + anonymousData.FirstName);      } } 41. What is multithreading, and what are its different states?Any code block in C# runs in a process called a thread. A thread is the execution path of the program. Simple applications can run on a single thread, but today’s programs frequently use multithreading. Multithreading divides the execution of the process among multiple threads to execute it simultaneously and, consequently, more efficiently. Through multithreading, we can run more than a single task at a time. Programs are more efficient and fast. But we also need to understand how threads work. Unstarted State: In this state, the compiler creates the instance of the thread but waits for the start method. Started: It is the state when the thread is ready to run and waiting for the CPU cycle. Not Runnable State: A thread is not executable in the below conditions. When we call the “sleep” or “wait” method. I/O operations block the thread. 42. How is exception handling done in C#?Exception handling is managed through a try, catch, finally, and throw model. These are the keywords used throughout the model.Below is the explanation of each keyword: Try: We keep the code in the try block for which we want to handle the exception. Catch: When any exception occurs in a try block, then it is caught in a catch block with the help of an exception handler. Finally: To execute a code block irrespective of error, we place that code in the finally block to get executed. Throw: Throws an exception when an issue occurs. Below is the example of exception handling: public class SomeClass       {     public void GetData()     {          try          {             //write some code here          }          catch (Exception)          {              throw;          }          finally          {             /*code to execute in the last             like dispose objects and resource*/          }     }  } 43. What are custom exceptions?Custom exceptions are used for errors that are being caught per user requirements rather than built into the compiler. Custom exceptions are an easy way to instance user-defined exceptions.Refer to the below example: public class Purchase {      public void DoPurchase(int quantity)      {          if (quantity == 0)          {              //this will throw error here with the custom message              throw new Exception("Quantity cannot be zero");          }      } } 44. What is LINQ in C#?LINQ refers to Language INtegrated Query. LINQ is a method of querying data using .NET capabilities and a C# syntax that’s similar to SQL. The advantage of LINQ is that we can query different sources of data. The data source could be either a collection of objects, XML files, JSON files, in-memory data or lists or database objects. We can easily retrieve data from any object that implements the IEnumerable<T> interface.Below is the syntax of LINQ. public class Devices       {            public void GetData()            {             List<string> mobiles = new List<string>() {                 "Iphone","Samsung","Nokia","MI"             };               //linq syntax             var result = from s in mobiles                          where s.Contains("Nokia")                          select s;              } }     45. What is serialization?When we want to send an object through a network, then we have to convert that object into a stream of bytes. Serialization is the process of converting an object into a stream of bytes. To facilitate the object for serializable, it should implement ISerialize Interface. The process of de-serialization is the reverse process of creating an object from a stream of bytes. 46. What are generics in C#?Generics in C#:  increase performance. increase type safety. reduce repeated code. make reusable code. Using generics, we can create collection classes. It is preferred to use System.Collections.Generic namespace instead of classes such as ArrayList in the System.Collections namespace to create a generic collection.Generics encourage the usage of parameterized types as seen in the example below: using System; namespace demoapp {     //We use < > to specify Parameter type     public class GFG<T>     {         //private data members         private T data;           //using properties         public T value         {             /using accessors             get             {                 return this.data;             }             set             {                 this.data = value;             }         }     }       //vehicle class     class Vehicle     {         //Main method         static void Main(string[] args)         {             //instance of string type             GFG<string> company = new GFG<string>();             company.value = "Tata motors";               //instance of float type             GFG<float> version = new GFG<float>();             version.value = 6.0F;               //display Tata motors             Console.WriteLine(company.value);               //display 6             Console.WriteLine(version.value);         }     } } 47. What is reflection?Reflection is a particular class in C# used to access the metadata of the assembly or the class.The following information can be retrieved using reflection: Assembly name Class name Method name Object type It Identifies properties and methods. 48. How to use nullable types?A null value can be assigned to a variable in C#. These types are called nullable types. Most variable types are nullable types.Example below: namespace demoapp {     class Calculate     {         int? number = null;         public Calculate(int num)         {             number = num;         }           public void DoCalculation()         {             if (number.HasValue)             {                //do something             }         }     } } 49. Which is the parent class of all classes which we create in C#?This is a simple question to answer:50. Explain code compilation in C#.A programmer writes code that is readable to people. That code is then fed into a C# compiler. The C# compiler will compile the code into efficient, machine-readable, managed code, known as bytecode. Then, the Just in Time Compiler (JIT) will compile the bytecode into native or machine language. When the program is run, it is this code that will be directly executed by the CPU.51. What is a hashtable in C#?A hashtable is a collection of pairs, generally “keys” and “values.” Frequently, you will hear about “hashtables” in regards to passwords; a password hash can be created for a given password. But a hashtable itself is just a general-purpose collection of key objects and value objects, in which the values have to be accessed using the keys; they cannot be accessed otherwise.52. How can you create a derived class object from a base class?This is a trick question! You cannot. A derived class will inherit variables and methods from the base class. Further, a derived class can have only a single base class. You would need to do your work with your base class directly. 53. What is an immutable string?An immutable string is an object that cannot be changed, although you can change the reference to it. In general, an immutable string should be used whenever you have a constant that absolutely should not be changed. However, you should use this trick sparingly because an immutable string may throw an error if you try to change it later. 54. What is reflection in C#?Reflection refers to methods and processes by which a system is able to look at and modify itself. In C#, reflection would refer to inspecting the contents of a system. It needs to be included manually within C# through the “System.Reflection” namespace. Reflection is particularly useful to debugging tools. 55. What is a generic class?A generic class is a class that can handle any type. This is unique because most classes follow strict typing; you have to declare a type, and that type has to be consistent. Defining a generic class would go as follows: class dataStore<T> {       public T data {               get; set;       } } 56. What is the params keyword, and how to use it?.By using the params keyword, you can specify a method parameter that takes a variable number of arguments. The parameter type must be a single-dimensional array.   public static void CalcListSum(params int[] list)     {         int sum =0         for (int i = 0; i < list.Length; i++)         {             sum+=list[i];         }         Console.WriteLine("The sum is " + sum);     } 57. What is NuGet?NuGet is a package manager for developers. It enables developers to share and consume useful code. A NuGet package is a single ZIP file that bears a .nupack or .nupkg filename extension and contains .NET assemblies and their needed files.58. What are DLL files, and what are the advantages of using them?A DLL is a library that contains code and data that can be used by more than one program at the same time. Each program can use the functionality that is contained in a DLL. This helps promote code reusability and efficient memory usage.By using a DLL, a program can be modularized into separate components. Because the modules are separate, the load time of the program is faster. And a module is only loaded when that functionality is requested.Additionally, updates are easier to apply to each module without affecting other parts of the program. When these changes are isolated to a DLL, you can apply an update without needing to build or install the whole program again.59. What does POCO mean?POCO stands for Plain Old CLR Objects. A POCO is a class that doesn’t depend on any framework-specific base class. It is like any other normal .NET class. Hence the name Plain Old CLR Objects. These POCO entities (also known as persistence-ignorant objects) support most of the same LINQ queries as Entity Object derived entities.60. What is a DTO?A Data Transfer Object (commonly known as a DTO) is usually an instance of a POCO (plain old CLR object) class used as a container to encapsulate data and pass it from one layer of the application to another. You would typically find DTOs being used in the service layer (backend) to return data back to the presentation layer (frontend).Referring to the above questions and answers gives us in-depth knowledge of all essential concepts of C# language. These technical answers can help to sharpen our knowledge and help to increase our comprehension of the language. If you need to brush up on C#, a bootcamp or refresher course can help.  

More details

Published - Mon, 30 May 2022

Careers in Data Science: Data Analyst vs. Data Scientist

Created by - admin admin

Careers in Data Science: Data Analyst vs. Data Scientist

Analyzing data allows businesses, governments, institutions, and individuals to make more informed decisions in our increasingly complex, interconnected world. More data is being collected now than at any point in human history. Most of this data hasn’t yet been analyzed.As the data landscape has grown, many new jobs and positions have sprung into existence. Two job titles you’ve likely heard about are data scientist and data analyst. Although they sound similar, there is a difference between them. What skills, education, and experience do you need to work in these roles, and how much can you expect to make in each one? Read on to find out!Role responsibilities of a data analystThe primary responsibility of a data analyst is to derive insights from data. The process they use has three stages: extraction, manipulation, and presentation. An analyst queries data, contorts it into the proper shape for analysis, and presents their conclusions. A skilled data analyst possesses both technical skills and business acumen. They need to know not just how to crunch numbers but which numbers to crunch and what they mean for the business. Their goal is to explain the why and the how simply and effectively.In the extraction stage, the analyst acquires a data set from one or more sources. This may involve ingesting a file of a certain format like CSV, XLSX, or JSON. It may involve querying a database for the correct data by specifying the right combination of filters. It may involve joining multiple data sets from different sources together.In the manipulation stage, the analyst contorts or shapes the data into a format suitable for a calculation. The calculation does not have to involve a complex statistical operation. For example, a business stakeholder may only need a count of records or an average of numbers to make an informed decision. A data analyst seeks to answer the question, “How do I get the data into the right shape so it can reveal its hidden meaning?”In the presentation stage, the data analyst determines the best way to “tell a story” with the data. Sometimes that is as simple as delivering a single conclusive number to a stakeholder. Other times it may involve creating a spreadsheet with a subset of important rows from a larger data set. In some cases, you can include visual aids like bar graphs, pie charts, or histograms. Regardless of the medium, the analyst seeks to present the conclusion compellingly.A data analyst working at Udemy may answer questions like:What were the five top-selling courses in each category last month?What was the average revenue for all photography courses in the last year?What percentage of a course does the average student complete?A data analyst can work with various technologies, including:Graphical spreadsheet applications like Microsoft Excel or Google SheetsGeneralist programming languages like Python, Java, or ScalaStatistical programming languages like RComputing environments like MATLAB or SASData analysis libraries like PandasRelational database management systems like Postgres or MySQLData visualization software like Tableau or Power BIAs a data analyst gains experience, they learn which tool is best for each job. There is rarely one “perfect” solution. Rather, each tool has its own advantages and disadvantages.Role responsibilities of a data scientistThe key distinction between data analysts and data scientists is that the latter build predictive models. A data analyst aims to understand what has happened. A data scientist seeks to predict what will happen.There are several areas of specialization within the data science ecosystem. For example, machine learning focuses on teaching computers to recognize patterns based on experience. On a site like Udemy, machine learning models help predict what courses will be appealing to you based on what courses you’ve already purchased. Another example is natural language processing (NLP), which focuses on programming computers to process and understand written text and human language. On Udemy’s site, NLP models can generate automatic subtitles for videos by identifying common patterns in human communication.There are additional specializations in data science, including artificial intelligence, deep learning, cloud computing, and more.Data scientists build predictive models based on existing data. This additional requirement requires additional technical skills. A data scientist’s background may include experience in:Software development, programming, and computer scienceMath, statistics, and complex algebraA specialized domain like physics or financeA data scientist is likely to have experience in a greater breadth of technologies than a data analyst. They may work with:Distributed processing solutions like Spark or HadoopMachine-learning software like TensorFlow or PyTorchCloud storage solutions like AWS, GCP, or AzureData scientists may find data engineering duties in their job requirements. Data engineers build the pipelines that collect and store data. They have to consider questions such as:Where is the data going to be stored? How are we going to connect to it?What size is the data? What is a suitable software solution for that scale?How is the data being stored? What details can be discarded?What details must be modified?What details can be kept in their original format?Certain professions define concrete boundaries for roles. For example, an otolaryngologist is a doctor who diagnoses ear, nose, and throat problems, while a podiatrist is a doctor who treats conditions with the foot and ankle. Each doctor has their domain of expertise. The world of data is a lot more fluid. If you search for “data” jobs, you’ll find roles for a data analyst and a data scientist alongside other titles like data engineer, data architect, big data developer, statistician, and business intelligence analyst.

More details

Published - Mon, 30 May 2022

Machine Learning vs. Deep Learning: What’s the Difference?

Created by - admin admin

Machine Learning vs. Deep Learning: What’s the Difference?

Machine learning and deep learning are both hot topics and buzzwords in the tech industry. You’ll hear these topics in the context of artificial intelligence (AI), self-driving cars, computers beating humans at games, and other newsworthy technology developments. If you’re new to the AI field, you might wonder what the difference is between the two.Think of it this way: deep learning and machine learning are both subsets of artificial intelligence. And, deep learning is a subset of machine learning. Machine learning is an AI technique, and deep learning is a machine learning technique.Machine Learning is One of Many AI TechniquesIn the early days of AI, the field relied on hard-coded rules and algorithms. Playing chess against an AI is an exercise in brute computational force; the computer program looks ahead at every possible series of moves and chooses the move with the best outcome. AI chatbots can hold a “conversation” with you by looking for certain words and phrases provided by the user. It then replies with canned responses a programmer thought of ahead of time (modern virtual assistants still rely on this technique). While these systems may seem intelligent, they depend on their programmed intelligence – they have no ability to learn with experience on their own.Machine learning flips that on its head. Instead of relying on hard-coded rules to solve problems, a machine learning algorithm is trained by feeding it real-world data. Machine learning then builds a model that looks for patterns between the data you give it and the thing you’re trying to predict. That model can make predictions for new things it’s never seen before. As the model is exposed to more and more training data, its accuracy gets better and better.As a simple example, imagine you want to build a system that can predict the sale price of a house based on the attributes of that house. You might train a machine learning algorithm by feeding it historical data of house sale prices, together with things like the home’s location, square footage, number of bathrooms, age, etc. The algorithm would start to find how these different properties of a house affect its sales price and build up a model that understands how each attribute affects the ultimate price of the home. For new houses going on the market, this machine learning algorithm could use the model to predict its sales price automatically. And as more and more home sales are fed into the system over time, its accuracy will get better and better.This machine learning system isn’t relying on ruled programmed by a human; rather, it is learning them based on real data.Deep Learning is One of Many Machine Learning TechniquesHow might that house pricing system work? It’s actually rather simple; you could plot the various attributes such as square footage against the sale prices you are training the system with, fit a curve to each one, and use those curves to predict prices of new houses that are hitting the market. That’s called multiple regression. Or, you could build a decision tree that learns a hierarchical series of decision points that lead to an accurate price prediction. It might start with a price range for a given area, refine that by the size of the house, refine that further by the house’s age, and so on until a final price is estimated. These are just two of many machine learning algorithms we might employ, but neither of them is what we call “deep learning.”Deep Learning as Complex Artificial Neural NetworksThough deep learning is another machine learning technique, it has attracted attention because it is very flexible – and inspired by how our own human brain works.Deep learning systems are made of layers of virtual neurons. Each neuron’s job is to simply add up the inputs coming into it and decide whether to fire off an output signal to the next layer of neurons above it.Every neuron in a layer is connected to every neuron in the layers of the network above and below it. By learning the optimal weights for each of these connections, this neural network can solve a wide variety of problems, in much the same way your own brain does. Even though a neural network is a simple concept, the sheer number of connections between neurons means they can represent very complex problems.Coming back to the real estate pricing example, all the attributes in your training data (location, size, etc.) are processed to be on a similar scale and fed into the neurons at the bottom-most layer of your neural network. Through multiple iterations, the neural network arrives at the best set of weights between its connections to produce an accurate price prediction at the output of its top-most layer. Once this neural network has been trained with the best weights between neurons, it can start to quickly predict prices for new houses the model hasn’t seen before.When the number of layers in a neural network is more than one, we say it is a deep neural network. And this is what we mean by the term deep learning. A deep learning model is a machine learning system implemented by a deep neural network.It’s not a case of machine learning vs. deep learning; deep learning is a machine learning technique – and a very exciting one! We’ve only scratched the surface of it here; there’s much more to learn.

More details

Published - Mon, 30 May 2022

Join now to start learning

Get started

Become instructor

Join now