![]() Scripts to manage continuous integration (testing on Linux and Windows) Which helps in the creation of Python packages containing scikit-learn compatible estimators.Īn initial git repository with Python package directory structureĪn initial test suite including use of check_estimatorĭirectory structures and scripts to compile documentation and example Selection tools such as model_selection.GridSearchCV andīefore detailing the required interface below, we describe two ways to achieve Interface might be that you want to use it together with model evaluation and The main motivation to make a class compatible to the scikit-learn estimator ![]() > from _checks import check_estimator > from sklearn.svm import LinearSVC > check_estimator ( LinearSVC ()) # passes You can check whether your estimatorĪdheres to the scikit-learn interface and standards by runningĭecorator can also be used (see its docstring for details and possible Several internals of scikit-learn that you should be aware of in addition to Whether it is just for you or for contributing it to scikit-learn, there are If you want to implement a new estimator that is scikit-learn-compatible, Universal attributes ¶Įstimators that expect tabular input should set a n_features_in_Īttribute at fit time to indicate the number of features that the estimatorĮxpects for subsequent calls to predict or transform.įor details. In iterative algorithms, the number of iterations should be specified byĪn integer called n_iter. The estimated attributes are expected to be overridden when you call fit Some regression estimator would be stored in a coef_ attribute after Estimated Attributes ¶Īttributes that have been estimated from the data must always have a nameĮnding with trailing underscore, for example the coefficients of Trainable parameters of the estimator are reused instead of using theĭefault initialization strategy. warm_start=True means that the previous state of the Hyper-parameter warm_start is set to True for estimators that Another exception to this rule is when the True in practice when fit depends on some random process, see General, calling estimator.fit(X1) and then estimator.fit(X2) shouldīe the same as only calling estimator.fit(X2). When fit is called, any previous call to fit should be ignored. A tolerance stopping criterion tol is not directlyĭata dependent (although the optimal value according to some scoring For instance a Gram matrix orĪn affinity matrix which are precomputed from the data matrix X areĭata dependent. Have a value assigned prior to having access to the data should be an ![]() predict ( X_test )ĭepending on the nature of the algorithm, fit can sometimes alsoĪccept additional keywords arguments. To be able to implement quick one liners in an IPython session such as: The method should return the object ( self). The second place if they are implemented. The second position that is just ignored by the estimator.įor the same reason, fit_predict, fit_transform, scoreĪnd partial_fit methods need to accept a y argument in Mix both supervised and unsupervised transformers, even unsupervisedĮstimators need to accept a y=None keyword argument in Make it possible to use the estimator as part of a pipeline that can Y might be ignored in the case of unsupervised learning. Is not met, an exception of type ValueError should be raised. The case of precomputed kernels where this data must be stored for use byĪrray-like of shape (n_samples, n_features) There are, however, some exceptions to this, as in Note that the model is fitted using X and y, but the object holds no The fit() method takes the training data as arguments, which can be oneĪrray in the case of unsupervised learning, or two arrays in the case The next thing you will probably want to do is to estimate some Which is used in algorithms like GridSearchCV. Would have to be performed in set_params, The reason for postponing the validation is that the same validation param1 = param1 # WRONG: the object's attributes should have exactly the name of # the argument in the constructor self. Def _init_ ( self, param1 = 1, param2 = 2, param3 = 3 ): # WRONG: parameters should not be modified if param1 > 1 : param2 += 1 self.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |