In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the Python machine learning interview questions". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the Python machine learning interview questions"?
1. What's the difference between supervised learning and unsupervised learning?
Supervised learning: learn the marked training samples to classify and predict the data outside the training sample set as much as possible. (LR,SVM,BP,RF,GBDT)
Unsupervised learning: training and learning of unlabeled samples is better than discovering the structural knowledge in these samples. (KMeans,DL)
two。 What is regularization?
Regularization is proposed for overfitting, thinking that the best solution to the model is the minimum empirical risk of general optimization. now, the empirical risk is added to the empirical risk (the regularization term is the norm of the model parameter vector), and a rate ratio is used to weigh the model complexity with the previous empirical risk. if the model complexity is higher, the structured empirical risk will be greater. Now the goal is to optimize the structural empirical risk, which can prevent the over-complexity of model training and effectively reduce the risk of over-fitting.
Occam's razor principle, which can well explain known data and is very simple, is the best model.
3. What is the generation model and discriminant model?
Generation model: the joint probability distribution P (XMagi Y) is learned from the data, and then the conditional probability distribution P (Y | X) is obtained as the prediction model, that is, the generation model: P (Y | X) = P (XQuery Y) / P (X). (naive Bayes, Kmeans)
The generated model can restore the joint probability distribution p (Xrecine Y), and has a fast learning convergence speed, and can also be used for the learning of hidden variables.
Discriminant model: the discriminant model is used to learn the decision function Y (X) or conditional probability distribution P (Y | X) as the prediction model directly from the data. (K nearest neighbor, decision tree, SVM)
In the face of prediction directly, the accuracy is often high, and the data are abstracted to various degrees directly, so the model can be simplified.
4. The difference between linear classifier and nonlinear classifier and their advantages and disadvantages
If the model is a linear function of parameters and there is a linear classification surface, then it is a linear classifier, otherwise it is not.
Common linear classifiers are: LR, Bayesian classification, single-layer perceptron, linear regression.
Common nonlinear classifiers: decision tree, RF, GBDT, multilayer perceptron
SVM has both (see linear kernel or Gaussian kernel)
The linear classifier is fast and easy to program, but the fitting effect may not be very good.
The programming of nonlinear classifier is complicated, but the effect fitting ability is strong.
5. When the feature is larger than the amount of data, what kind of classifier should be chosen?
Linear classifier, because when the dimension is high, the data is generally sparse in the dimension space and is likely to be linearly separable.
For features with high dimensions, do you choose linear or non-linear classifiers?
The reason is the same as above
For features with very low dimensions, do you choose linear or non-linear classifiers?
Nonlinear classifier, because many features in low-dimensional space may run together, resulting in linear inseparability.
The following is Wu Enda's opinion:
1. If the number of Feature is large, which is about the same as the number of samples, choose LR or SVM of Linear Kernel.
two。 If the number of Feature is small, and the number of samples is general, neither large nor small, choose SVM+Gaussian Kernel.
3. If the number of Feature is small and the number of samples is large, you need to add some feature manually to become the first case.
6. Why do some machine learning models need to normalize data?
Normalization is to limit the data you need to process (through some algorithm) to the range you need.
The main results are as follows: 1) after normalization, the speed of gradient descent to find the optimal solution is accelerated. The contours become smooth and converge faster when the gradient is reduced. If normalization is not done, the gradient descent process is easy to go, and it is difficult to converge or even unable to converge.
2) it is possible to improve the accuracy by changing the dimensionless expression into a dimensionless expression. Some classifiers need to calculate the distance between samples (such as Euclidean distance), such as KNN. If a feature range is very large, the distance calculation mainly depends on this feature, which is contrary to the actual situation (for example, the feature with a small range is more important).
3) the a priori hypothesis data of logical regression model obeys normal distribution.
7. Which machine learning algorithms do not need to be normalized?
Probability models do not need normalization because they do not care about the value of variables, but care about the distribution of variables and conditional probabilities between variables, such as decision tree and rf. Optimization problems such as adaboost, gbdt, xgboost, svm, lr, KNN, KMeans and so on need to be normalized.
8. The difference between standardization and normalization
To put it simply, standardization is to process data according to the columns of the eigenmatrix, which converts the eigenvalues of the samples to the same dimension by finding the z-score. Normalization processes data according to the rows of the feature matrix, and its purpose is that the sample vector has a unified standard when calculating similarity by point multiplication or other kernel functions, that is to say, it is transformed into "unit vector". The normalization formula with rule L2 is as follows:
9. How to deal with missing values in Random Forest
Method 1 (na.roughfix) is simple and rough, for the training set, the data under the same class, if the classification variable is missing, use the mode to make up, if it is the continuous variable missing, use the median to fill.
Method 2 (rfImpute) this method has a large amount of calculation, but is better or worse than method 1? It's hard to judge. First fill in the missing values with na.roughfix, then build the forest and calculate the proximity matrix, and then look back at the missing values. If it is a classification variable, vote with the weight in the proximity with no missing observation examples. If it is a continuous variable, the missing value is filled by the weighted average method of proximity matrix. Then iterate 4-6 times, and the idea of filling missing values is similar to KNN 12.
10. How to make feature selection?
Feature selection is an important data preprocessing process for two reasons: one is to reduce the number of features and dimensionality, so as to make the model have stronger generalization ability and reduce overfitting, and the other is to enhance the understanding between features and eigenvalues.
Common feature selection methods:
1. Remove features with small variance
two。 Regularization. 1 regularization can generate sparse models. The performance of L2 regularization is more stable, because the corresponding coefficients of useful features are often non-zero.
3. For random forests, Gini impurity or information gain is usually used for classification problems, and variance or least square fitting is usually used for regression problems. Generally, there is no need for tedious steps such as feature engineering and parameter adjustment. Its two main problems, 1 is that the important features may have a low score (associated feature problem), and 2 is that this method is more advantageous to the features with more categories of feature variables (biased problem).
4. Stability choice. It is a relatively new method based on the combination of secondary sampling and selection algorithm, which can be regression, SVM or other similar methods. Its main idea is to run the feature selection algorithm on different data subsets and feature subsets, repeat constantly, and finally summarize the feature selection results. for example, you can count the frequency at which a feature is considered to be an important feature (the number of times it is selected as an important feature divided by the number of times its subset is tested). Ideally, the score for important features would be close to 100%. The slightly weaker feature score will be a non-zero number, while the most useless feature score will be close to 0.
Thank you for your reading, the above is the content of "what are the Python machine learning interview questions". After the study of this article, I believe you have a deeper understanding of what Python machine learning interview questions there are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un