Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use python pipeline

Shulou Source: shulou.com Published: 2022-06-01 02:48:53 10月02日 Update

This article mainly explains "how to use python pipeline". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use python pipeline.

Description

1. Open it in settings before using it.

2. The key in settings indicates the location of pipeline (that is, the location of pipeline in the project can be customized), and the value indicates the distance from the engine. The closer the data is, the first to pass: the priority is given to those with small weight values.

3. When there are more pipeline, the method of process_item must be returnitem, otherwise the data obtained by the latter pipeline is the value of None.

There must be a process_item method in pipeline, otherwise item cannot receive and process it.

Instance from sklearn.pipeline import Pipelinefrom sklearn.svm import SVCfrom sklearn.decomposition import PCAestimators = [("reduce_dim", PCA ()), ("clf", SVC ())] pipe = Pipeline (estimators) pipe

Content extension:

The sklearn.pipeline.Pipeline () function of Python can package multiple "data processing nodes" in order, and the result of the data processed by the previous node will be transferred to the next node for processing. Except for the last node, all nodes must implement the "fit ()" and "transform ()" methods, and the last node needs to implement the fit () method. When the training sample data is sent to Pipeline for processing, it invokes the node's fit () and transform () methods one by one, and then uses the fit () method of the last node to fit the data.

From sklearn.linear_model import LinearRegressionfrom sklearn.preprocessing import PolynomialFeaturesfrom sklearn.pipeline import Pipeline def polynomial_model (degree = 1): polynomial_features = PolynomialFeatures (degree = degree, include_bias = False) linear_regression = LinearRegression () pipeline = Pipeline ([("polynomial_features", polynomial_features), ("linear_regression", linear_regression)]) return pipeline here, I believe you have a deeper understanding of "how to use python pipeline", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Node method data processing content location learning practical deeper interest function multiple instance practical practical that is engine easy to operate more friends Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Linux Huawei MariaDB Microsoft