28 Machine Learning Engineer - Python Interview Questions & Answers
1. What is an epoch?
This question focuses on the developer's understanding of machine learning terminology.
An epoch refers to the training of neural networks. It is known as a hyperparameter. An epoch means training a neural network with all the training data for one cycle.
In an epoch, all the data is used exactly once when training the algorithm.
In summary, an epoch is a hyperparameter that defines the number of times that the learning algorithm works through the entire training set.
This is an example of a question targeted at your knowledge of machine learning terminology.
Written by Ryan Brown on July 6th, 2021
2. What are some of the ethical considerations that are taken into account when designing machine learning algorithms?
This question targets the candidate's knowledge and understanding of the ethics surrounding AI and machine learning. This is a new field and many large technology companies are employing ethics officers to bring AI and ethics to the fore.
Ethical arguments are raised due to the objective of the algorithm not being in line with the well-being or interests of the users. For example, an algorithm designed to improve user experience on a website may determine that the best way for the user to have a good experience is to make them want to stay on the site as long as possible. This is not necessarily a great outcome for the user as they may spend too much time on a platform or website.
The outputs of machine learning algorithms must be cross-checked and verified that they are indeed acting in the best interests of the users.
The interviewer wants you to demonstrate that you are aware of ethical concerns and that you have an understanding of how and when they may arise.
Written by Ryan Brown on July 6th, 2021
3. What is the event commonly referred to as the singularity?
This question is targeted at individuals with a keen interest in the high-level theory and thought experiments surrounding machine learning. An interviewer may ask this as an open question and is not necessarily looking for a technical detailed answer. They may frame the questions as a thought experiment and attempt to understand your opinions on the future of the industry.
The term singularity also referred to as the technological singularity is a hypothetical point in the future where technological growth becomes uncontrollable and irreversible as machine learning algorithms and AI systems make improvements to themselves and become smarter and better to the point where they overtake the intelligence of a human.
This question is posed more out of curiosity and is an opportunity to ask the technical interviewer what they think to build a rapport and an open dialogue while also showing you are interested and knowledgeable about the space.
Written by Ryan Brown on July 6th, 2021
4. What is deep learning?
This question shows the developer's knowledge of machine learning terminology.
As machine learning is a subset of AI (Artificial Intelligence) Deep learning is a subset of machine learning. Deep learning refers to a class of machine learning algorithms that use multiple layers to extract higher-level features from raw data input.
This question is similar to distinguishing between what AI is and what machine learning is. The technical interviewer wants you to demonstrate an understanding of the terminology.
Some examples of the uses of deep learning are neural networks used for computer vision and natural language processing (NLP).
Written by Ryan Brown on July 6th, 2021
5. Have you ever used TensorFlow?
This question shows the developer's understanding of the machine learning library.
TensorFlow is Google's custom machine learning library. It is an open-source library for machine learning. It is particularly useful for training neural networks.
The technical interviewer will want to see if you are familiar with this library as it is widely used in the industry. It is similar to sci-kit learn in the sense that it is possible to create deep learning models using the library as well as using wrapper libraries to simplify the process.
Many large companies use TensorFlow for their machine learning projects. It is possible to train algorithms using TensorFlow using either python or javascript. Keras is a high-level API within TensorFlow that can be leveraged to create machine learning models.
Written by Ryan Brown on July 6th, 2021
6. Do you know any libraries that are useful for machine learning?
The interviewer may ask if you are familiar with the following python libraries as they can be particularly useful for machine learning and development:
1. NumPy
2. SciPy
3. Scikit-learn
NumPy and SciPy offer a lot of the math functionality required for machine learning whereas scikit-learn provides the ability to easily split a data set into train and test, implement a particular algorithm based on your specification and then test the accuracy and calculate the F1 score all in a few lines of code.
This is a very useful abstraction in the day to day work for a machine learning engineer, however, in an interview, the technical interviewer may ask for you to create the algorithms from scratch using very few python libraries in order to test your knowledge of Python syntax and your understanding of the algorithm.
Written by Ryan Brown on July 6th, 2021
7. Why is python often used for machine learning?
This question shows the developer's understanding of how machine learning and python relate.
Python is often used when creating machine learning algorithms as it contains a lot of libraries that are incredibly useful for designing, training, and testing machine learning algorithms.
Python offers the ability to developers to write concise and readable code which is particularly useful when writing complex machine learning algorithms.
Many technical interviews regarding machine learning revolve around using python. Sometimes a technical interviewer will ask you to write a simple algorithm not using a library to demonstrate a familiarity with the syntax and an understanding of the fundamental logic of the algorithms.
In the intermediate and advanced machine learning courses we will write machine learning algorithms using python. A popular IDE for python in Jupyter notebooks. This is a commonly used IDE amongst data scientists.
Written by Ryan Brown on July 6th, 2021
8. What is a loss function? How does this differ from a cost function?
This interview question focuses on the developer's knowledge of machine learning terminology.
A loss function is used to determine how far an estimated value is from the true value.
A loss function is sometimes referred to as an error function. A cost function refers to the average loss over the entire training data set.
The primary difference between a cost function and a loss function is that the loss function is for a single training example whereas the cost function is calculated over the entire data set.
Written by Ryan Brown on July 6th, 2021
9. What is the F1 score? And how is it calculated?
This question shows the developer's knowledge of machine learning algorithms and analysis.
The F1 score is a statistical measure of the accuracy of a given algorithm.
It is calculated by analyzing the true positives, False positives, and false negatives produced when testing a machine learning algorithm.
The F1 formula is as follows:
F1 = TP / (TP + 0.5(FP + FN)
A true positive (TP) is a classification of data points in the test data set that is correct.
A false positive (FP) is an incorrect classification of a data point within the test set similar to a false negative (FN).
F1 scores are commonly used when the false negatives and false positives produced by a system are crucial.
The technical interviewer will want to examine your ability to effectively analyze the performance of a machine learning algorithm using particular metrics such as the F1 metric.
Written by Ryan Brown on July 6th, 2021
10. What is normalization? And what problem does it solve in machine learning?
This question shows the developer's knowledge of machine learning terminology and its purpose.
Normalization is the process of assigning values to a specific data set. Normalizing a data set will return a set of values between 0 and 1.
For example, let's say you have a data set represented as "x" below, and you wanted to find the average of that data set. We can see that there are 4 values in a similar range however the fifth value is much larger than the other 4. Therefore an average would be skewed by including this very large value and we would not learn a lot about our data set.
Normalization assigns a value between 0 and 1 based on the magnitude (size) of the value in the data set.
This mitigates the chances of the data being skewed by one or two very large numbers. This is a common technique used when creating machine learning algorithms.
Below is an example of a data set before normalization and after normalization:
#Raw Data set
x = [1, 5, 10, 23, 300]
#Normalised data set
x_norm = [0, 0.013, 0.03, 0.07 , 1]
The formula associated with normalising a data set is:
X_norm = (X - X_min)/(X_max - X_min)
Where:
X = value to be normalised
X_max = Maximum value in the data set
X_min = Minimum value in the data set
X_norm = normalised value
#Raw Data set
x = [1, 5, 10, 23, 300]
#Normalised data set
x_norm = [0, 0.013, 0.03, 0.07 , 1]
Written by Tiarnan Brady on May 24th, 2021
11. What is regularization?
This question shows the developer's knowledge of machine learning processes.
Regularization is a technique used to reduce errors by fitting the function appropriately on the training data set. This technique is used to prevent overfitting.
There are three types of regularization:
1. L1 regularization
2. L2 regularization
3. Dropout regularization
The technical interviewer may ask this as a high-level question in order to determine if you know what the process of regularisation is used for. The specific details of each regularisation technique is a much more advanced topic and many interviewers would not expect a highly detailed explanation of each as this is a very niche technique.
Written by Ryan Brown on July 6th, 2021
12. What is underfitting?
This question shows the developer's knowledge of machine learning issues.
Underfitting is similar to overfitting in the sense that the algorithm or system does not identify trends or relationships effectively or accurately.
Underfitting refers to an algorithm's inability to correctly capture the trend of underlying data. Similar to overfitting, underfitting will negatively impact the accuracy of the algorithm.
The interviewer will ask these types of questions to test your knowledge of some of the potential issues you may face as a machine learning engineer. Much of a software developer's time is spent debugging existing code. The technical interviewer wants you to demonstrate your knowledge of common bugs and errors when working with machine learning algorithms.
Written by Ryan Brown on July 6th, 2021
13. How can you prevent or avoid overfitting?
This question shows the developer's knowledge of machine learning algorithm.
Cross-Validation is a technique used to avoid overfitting data. This is the process of splitting the data set into k subsets, often referred to as folds.
These folds are then used to train the algorithm iteratively and are an example of a variation of the train/test model used when creating machine learning algorithms.
Written by Ryan Brown on July 6th, 2021
14. What is overfitting?
This question shows the developer's knowledge of machine learning errors.
Overfitting is a modeling error that occurs when a function fits too closely to the data used to train the algorithm.
This happens when the model learns the detail and the noise in the data set and fits too closely to the noise. This has a negative impact on the accuracy of the algorithm.
The technical interviewer asks this question to determine if you are aware of some of the potential errors that can occur when creating and training machine learning algorithms.
You may also add that overfitting may be identified when the accuracy of the algorithm is very high when using the training data set but much lower when using the testing data set.
Written by Ryan Brown on July 6th, 2021
15. What is Machine Learning? What is the difference between Artificial Intelligence and Machine Learning?
Machine Learning and AI (Artificial Intelligence) are often used interchangeably however a technical interviewer will want to verify that you know the difference and can explain in detail what constitutes "Machine Learning".
Simply put, Machine learning is a subset of AI. It refers to a system or program's ability to automatically learn and improve without being explicitly programmed.
One of the key characteristics of machine learning is that Machine Learning focuses on the development of computer programs that can access data and learn for themselves.
Written by Ryan Brown on July 6th, 2021
16. What is a neural network?
This question shows the developer's knowledge of machine learning terminology.
A neural network is an interconnected system of perceptrons. They are computing systems based around neural networks within animals' brains.
These networks are used to recognize relationships and patterns within data.
The technical interviewer may ask "can you provide a use case for such a network?" A general answer to this question is when you have so much data and computing power and the accuracy of the decision really matters. For example, in self-driving cars and cancer detection algorithms.
Written by Ryan Brown on July 6th, 2021
17. What is a perceptron?
This question shows the developer's knowledge of machine learning terminology.
Perceptrons are the foundations of neural networks. Perceptrons can be viewed as the building blocks of neural networks. They are comprised of 4 components:
1. Input Values
2. Weights and Bias
3. Net Sum
4. Activation function
The way a perceptron works is that it takes some inputs, applies weight and bias to each input then sums the inputs (adds all the inputs).
This value is then passed through an activation function which standardizes the value and produces an output of 0 or 1.
The decision made by the perceptron is then passed to the next layer of perceptrons hence forming a neural network!
Written by Ryan Brown on July 6th, 2021
18. What is meant by K-means clustering? Is this a supervised or unsupervised machine learning technique?
A technical recruiter may ask these questions in preparation for a more detailed follow-up question. For now, we will just look at the high-level overview and in more advanced courses we will examine the mathematics and the python code that can be used to build a k-means clustering algorithm.
K-means clustering is an advanced machine learning algorithm that is classified as unsupervised. It attempts to identify subgroups within a data set. This means the data points in one cluster are more similar to each other than to the data points in another subgroup.
This then allows you to determine or classify a particular data point into one of the subgroups allowing you to make a prediction.
Written by Ryan Brown on July 6th, 2021
19. What is a random forest? And what is the bagging method?
This question focuses on the developer's knowledge of machine learning terminology and its purpose.
A random forest is a complex example of a decision tree. A random forest is a supervised machine learning algorithm usually trained using the "bagging method". A random forest is a collection of decision trees hence the name forest.
It builds multiple decision trees to get a more accurate and stable prediction. One of the key advantages of a random forest is that it can be used for either regression or classification.
The general concept of the bagging method is that by combining machine learning models you can improve and increase the accuracy of the overall results.
Written by Ryan Brown on July 6th, 2021
20. What are some of the advantages and disadvantages of using decision trees?
This question shows the developer's understanding of machine learning decision trees.
Advantages and Disadvantages of using decision trees:
Advantage:
1. New Scenarios can be easily added and accounted for
2. Easy to understand the structure and interpret the tree
3. Hard data can be used alongside expert opinion allowing for more context when making decisions.
Disadvantage:
1. Calculations can become complex when the tree increases in size.
The advantages of using a decision tree far outweigh the disadvantages. The technical recruiter will ask this question in order to examine your knowledge of decision trees as well as your logic and thinking behind why and when you could or should use them.
Written by Ryan Brown on July 6th, 2021
21. What are decision trees?
This is a core concept in machine learning. The technical interviewer is attempting to examine your knowledge of the fundamentals of what a decision tree is and when it may be used.
A decision tree is a "Tree" model of decisions and their possible consequences. These may include the probability of an event occurring or the cost of such an event. The decision tree allows you to make a decision based on these inputs.
An example of a use case for a decision tree is an image classifier, where the algorithm distinguishes images by determining common characteristics from the training data set.
Written by Ryan Brown on July 6th, 2021
22. When might you use classification and not regression?
This question is targeted primarily at your knowledge of the application of machine learning algorithms. You should aim to provide real-life use case examples for both classification and regression algorithms.
Classification algorithms can only be used with discrete data. Whereas regression algorithms can only be used on continuous data. This is the key difference between the two algorithms.
You may be promoted to give an example of discrete or continuous data. Discrete data can only take certain values such as Yes or No, Correct or Incorrect, Tall or Small. Continuous data can take data such as length or temperature.
Written by Ryan Brown on July 6th, 2021
23. What is the difference between classification and regression?
This question shows the developer's knowledge of machine learning terminology and differences.
Classification algorithms are used to predict discrete values such as True or Fale, Yes or No, etc. An example of the use case of a classification algorithm is an algorithm that can be used to determine if an image shows a cat or a dog. A more advanced use case could be medical detection, an algorithm that is used to determine if a medical scan shows signs of cancer or not.
Regression algorithms are used to predict continuous values such as prices, age, or salary. These algorithms can be used to predict the salary of a person within an organization based on their age or years of experience.
Providing tangible examples of use cases for regression and classification algorithms shows the technical interviewer that you understand the limitations of these algorithms.
Written by Ryan Brown on July 6th, 2021
24. What is Linear Regression and what can it be used for?
This question shows the developer's understanding of machine learning basic algorithm.
Linear Regression is an algorithm used to make predictions based on a data set that is provided. For example, a real-life example of linear regression is used to predict house prices based on the square footage.
You train the algorithm using data that outlines the price of a property and the square footage of that property. Linear regression is used to determine the relationship between the price and the square footage.
The algorithm can then provide a prediction of the price of a property based on the square footage. If you use square footage as an input, you will receive a price as an output.
There are two kinds of linear regression:
1. Simple Linear Regression
2. Multiple Linear Regression
As the names suggest simple linear regression is characterized by one independent variable. In the example above the independent variable is house price.
For Multiple Linear Regression, there are multiple independent variables. The regression algorithm may fit a curve or a polynomial. This is called either curvilinear or polynomial regression.
The technical interviewer asks this question to determine whether or not you are aware of the basics when it comes to simple machine learning algorithms and if you can apply this knowledge to real-life use cases.
Written by Ryan Brown on July 6th, 2021
25. What is the difference between supervised and unsupervised Machine Learning?
This question shows the developer's knowledge of machine learning data sets.
The are two primary types of machine learning:
1. Supervised
2. Unsupervised
The supervised version of machine learning means that the algorithm or system in question requires the input from a developer to label a data set in order to train the algorithm. This is said to be supervised as it requires input from a human.
An unsupervised algorithm learns or is "trained" from unlabeled or untagged data. It does not require the input from a human to label the data set used to train the algorithm. This can be an advantage as labeling data can be tedious and time-consuming for developers.
The purpose of this question is to enlighten the interviewer whether or not you are aware of the types of algorithms used in Machine Learning and if you understand the training process enough to distinguish between the two types.
Written by Ryan Brown on July 6th, 2021
26. What is Data Labeling?
This question shows the developer's knowledge of machine learning terminology.
Data Labelling is the process of identifying the content of an image or data point in order to train the machine learning algorithm.
For example, if you had a data set composed of images of cats and dogs and you wanted to train an algorithm to identify an image based on whether it is a cat or a dog you first must label your data set. This allows your algorithm to identify the characteristics of a correctly labeled image during the training process.
The algorithm can then identify and distinguish between images in the test set as it has been "trained" using the labeled data.
Data labeling can be a very tedious part of designing machine learning algorithms as these algorithms often require a very large data set for training.
Written by Ryan Brown on July 6th, 2021
27. Provide some examples of well known and commonly used Machine Learning Algorithms? please identify if they are supervised or unsupervised
This question provided the interviewee the opportunity to demonstrate their background knowledge in machine learning algorithms. This question can also be a good opportunity to elaborate and explain a use case of a particular algorithm you are familiar with.
Below are some examples of commonly used algorithms:
K-mean clustering
Linear Regression
Logistic Regression
SVM (Support Vector Machine)
Written by Ryan Brown on July 6th, 2021
28. What can Machine Learning be used for?
Machine learning can be used for a variety of different use cases. The technical interviewer is attempting to ascertain your level of understanding of the applications of ML (Machine Learning) in the real world when asking this question.
Some examples of use cases are as follows:
1. Image Recognition
2. Speech Recognition
3. Medical Diagnosis
4. Predictive analysis
To further impress a technical interviewer it is often advised to specify a particular project you are aware of that is implementing Machine Learning. This could be Tesla's self-driving car technology as an example of both image recognition and predictive analysis or Quantitative hedge funds using financial data to perform predictive analysis of future stock prices.
This demonstrates knowledge of current developments and innovations in the space and shows the interviewer you have context for the application of ML and understand the current and future use cases.
Written by Ryan Brown on July 6th, 2021