In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "case Analysis of python Model Optimization". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "python model optimization case analysis" it!
Hyperparameters are parameters that are not learned directly in the estimator. In the scikit-learn package, they are passed as parameters to the constructor in the estimator class. Typical examples are: C, kernel and gamma for support vector classifier, alpha for Lasso and so on.
The method of searching the hyperparametric space to obtain the best cross-validation score is possible and worth advocating.
Searching the hyperparameter space to optimize the hyperparameter requires the following aspects to be clear:
Estimator
Hyperparametric space
Cross-validation scheme
Scoring function
Search or sampling method (grid search or random search)
The common methods of optimizing models include grid search method, random search method, model-specific cross-validation and information criterion optimization.
First, grid search method GridSearchCV
The grid search method cross-validates each possible situation in the specified hyperparameter space and selects the best hyperparameter combination.
The grid search method or random search method can be used to optimize the parameters of Pipeline, and multiple evaluation indicators can be specified.
Second, random search method
RandomizedSearchCV
The function of random search method is similar to that of grid search method, but only different sampling times are carried out in hyperparametric space. The number of samples is specified by the n_iter parameter, and a balance between efficiency and performance can be achieved by resizing it. The sampling method calls the ParameterSampler function, and the sampling space must be specified in a dictionary.
The grid search method can only carry out violent search in the limited hyperparametric space, but the random search method can randomly search in the infinite hyperparametric space.
Third, model specific cross-validation
For some specific models, sklearn has built some estimators with internal cross-validation optimization mechanisms.
They are mainly in the linear_model module.
For example:
Linear_model.ElasticNetCV
Linear_model.LogisticRegressionCV
Linear_model.RidgeCV
Wait
Fourth, optimization of information criteria.
There are two main ways to choose the model.
Explanatory framework: a good model should be the one that best explains the existing data. The likelihood function can be used to measure the ability of the model to describe data sets.
Predictive framework: a good model should be the one that can best predict the results. In general, the more parameters of the model, the more complex it is, and the more likely it is to over-fit.
Therefore, the problem of model selection seeks the best balance between the complexity of the model and the ability of the model to describe the dataset (i.e. likelihood function).
AIC (Chichi Information Criterion) and BIC (Bayesian Information Criterion) provide a criterion for the selection of models.
The AIC information criterion chooses the model with the largest AIC.
The BIC information criterion chooses the model with the largest BIC. When the number of samples is large, the penalty of BIC on the number of parameters is greater than that of AIC.
Where L is the likelihood function, k is the number of model parameters, and n is the number of samples.
Linear_model.LassoLarsIC adopts information criterion for optimization.
At this point, I believe that everyone on the "python model optimization case analysis" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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
© 2024 shulou.com SLNews company. All rights reserved.