A neural network can be understood as a network of hidden layers, an input layer and an output layer that tries to mimic the working of a human brain.The hidden layers can be visualized as an abstract representation of the input data itself. These layers help the neural network understand various features of the data with the help of its own internal logic.These neural networks are non-interpretable models. Non-interpretable models are those which can’t be interpreted or understood even if we observe the hidden layers. This is because the neural networks have an internal logic working on its own, that ... Read More
The basic example of a neural network is a ‘perceptron’. It was invented by Frank Rosenblatt in 1957. The perceptron is a classification algorithm similar to logistic regression. This because, similar to logistic regression, a perceptron has weights, w, and an output function, ‘f’, which is a dot product of the weights and the input.The only difference is that ‘f’ is a simple step function, where a logistic regression rule is applied to the output of the logistic function. On the other hand, perceptron can be understood as an example of a simple one-layer neural feedforward network.The perceptron was considered ... Read More
Neural networks have been around for many years, through which they have been praised as well as criticised for their characteristics.But off late, they have gained attention over other machine learning algorithms. Of course, Machine learning algorithms are important as they help achieve certain goals. But what should we do when machine learning algorithms can’t achieve higher accuracy?This is where deep learning algorithms come into play. They mimic the layers of the human brain, and try to take optimal decisions by passing an input from one layer to the next.Neural networks, as the name suggests, tries to follow the pattern ... Read More
We previously understood how Q-learning works, with the help of Q-value and Q-table. Q-learning is a type of reinforcement learning algorithm that contains an ‘agent’ that takes actions required to reach the optimal solution. This is achieved with the help of Q-table that is present as a neural network. It helps take the right step that maximizes the reward, thereby reaching the optimal solution.Now, let us see how the agent uses the policy to decide on the next step that it needs to take to achieve optimum results.The policy considers the Q-values of all possible actions that could be taken, ... Read More
Q-learning is a type of reinforcement learning algorithm that contains an ‘agent’ that takes actions required to reach the optimal solution.Reinforcement learning is a part of the ‘semi-supervised’ machine learning algorithms. When an input dataset is provided to a reinforcement learning algorithm, it learns from such a dataset, otherwise it learns from its experiences and surroundings.When the ‘reinforcement agent’ performs an action, it is awarded or punished (awards and punishments are different, as they depend on the data available in hand) based on whether it predicted correctly (or took the right path or took a path that was least expensive).If ... Read More
We will be writing two JavaScript functions, the job of both the functions will be to take in a number and return its factorial.The first function should make use of a for loop or while loop to compute the factorial. Whereas the second function should compute the factorial using a recursive approach.Lastly, we should compare the times taken by these functions over a large number of iterations.ExampleFollowing is the code −const factorial = (num = 1) => { let result = 1; for (let i = 2; i { if(num > 1){ return ... Read More
We are required to write a JavaScript function that takes in a string as the first argument and a number as the second argument and a single character as the third argument, let’s call this argument char.The number is guaranteed to be smaller than the length of the array. The function should insert the character char after every n characters in the string and return the newly formed string.For example −If the arguments are −const str = 'NewDelhi'; const n = 3; const char = ' ';Then the output string should be −const output = 'Ne wDe lhi';ExampleFollowing is the ... Read More
We are required to write a JavaScript function that takes in a string as the only argument. The string is likely to contain question marks (?) in the beginning and the end. The function should trim off all these question marks from the beginning and the end keeping everything else in place.For example −If the input string is −const str = '??this is a ? string?';Then the output should be −const output = 'this is a ? string';ExampleFollowing is the code −const str = '??this is a ? string?'; const specialTrim = (str = '', char = '?') => { ... Read More
Suppose we have an array of arrays that contains the performance of a cricket player like this −const arr = [ ['Name', 'V Kohli'], ['Matches', 13], ['Runs', 590], ['Highest', 183], ['NO', 3], ['SR', 131.5] ];We are required to write a JavaScript function that takes in one such array of arrays. Here, each subarray represents one key-value pair, the first element being the key and the second its value. The function should construct an object based on the key-value pairs in the array and return the object.Therefore, for the above array, the output should look ... Read More
Suppose we have an object that contains information about the weather of a city −const obj = { city: "New Delhi", maxTemp: 32, minTemp: 21, humidity: 78, aqi: 456, day: 'Tuesday', };We are required to write a JavaScript function that takes in one such object. The function should construct an array of arrays based on this object where each subarray contains exactly two properties −the corresponding keythat key's valueTherefore, for the above object, the output should look like −const output = [ [ 'city', 'New Delhi' ], [ 'maxTemp', 32 ], ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP