Scikit-learn model options not available? If so, is there an alternative to ML workbench?

I do machine learning using scikit-learn, as recommended in this question . To my surprise, he does not provide access to the actual models that he trains. For example, if I create an SVM, linear classifier, or even a decision tree, it does not seem to give me the opportunity to see the parameters selected for the actually trained model.

A vision of a real model is useful if the model is partially created in order to get a clearer idea of ​​what functions it uses (for example, decision trees). Seeing a model is also an important issue if you want to use Python to train the model and some other code to implement it.

Am I missing something in scikit-learn or is there some way to get this in scikit-learn? If not, what good working tool for machine learning, not necessarily in python , in which models are transparently accessible ?

+4
source share
1 answer

The set model parameters are stored directly as attributes of the model instance. There is a specific naming convention for these set parameters: they all end with a trailing underscore, as opposed to constructor parameters provided by the user (aka hyperparameters) that do not.

The type of attributes set depends on the algorithm. For example, for the Support Vector Machine core you will have array support vectors, double coefficients and intercepts, and for random forests and extremely randomized trees you will have a collection of binary trees (internally represented in memory as continuous numpy arrays for performance: structure representations of arrays).

For details, see the Attributes section of the docstring of each model, for example, for SVC:

http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC

For tree models, you also have a helper function for generating graphivz_export learned trees:

http://scikit-learn.org/stable/modules/tree.html#classification

To find the importance of features in forest models, you should also look at the compute_importances parameter, for example, the following examples:

http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html#example-ensemble-plot-forest-importances-py

http://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances_faces.html#example-ensemble-plot-forest-importances-faces-py

+7
source

Source: https://habr.com/ru/post/1416633/


All Articles