Multivariate polynomial regression with numpy

前端 未结 3 1333
死守一世寂寞
死守一世寂寞 2020-12-02 23:38

I have many samples (y_i, (a_i, b_i, c_i)) where y is presumed to vary as a polynomial in a,b,c up to a certain degree. For example f

3条回答
  •  臣服心动
    2020-12-02 23:51

    sklearn has a nice example using their Pipeline here. Here's the core of their example:

    polynomial_features = PolynomialFeatures(degree=degrees[i],
                                             include_bias=False)
    linear_regression = LinearRegression()
    pipeline = Pipeline([("polynomial_features", polynomial_features),
                         ("linear_regression", linear_regression)])
    pipeline.fit(X[:, np.newaxis], y)
    

    You don't need to transform your data yourself -- just pass it into the Pipeline.

提交回复
热议问题