[Python] How to interpret the Coefficient of nonlinear regression in scikit learn?

Discussão em 'Python' iniciado por Stack, Agosto 8, 2025.

  1. Stack

    Stack Membro Participativo

    I am using the following code to do a nonlinear regression, and I am getting an intercept & 20 coefficients. How to interpret those coefficients to be able to construct a formula Y = intercept + coeff*feat_a + .....?

    data = pd.read_csv("data.csv")

    # Step 2: Preprocess the data
    X = data[['feat_a', 'feat_b', 'feat_c', 'feat_d', 'feat_e' ]] # Independent variables including blue (b)
    y = data['Y']

    #splitting Train and Test
    from sklearn.model_selection import train_test_split
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.15, random_state=101)

    # Dependent variable

    # Step 3: Fit a polynomial regression model
    degree = 2 # Adjust the degree of the polynomial as needed
    poly_features = PolynomialFeatures(degree=degree, include_bias=False)
    X_poly = poly_features.fit_transform(X_train)

    model = LinearRegression()
    model.fit(X_poly, y_train)

    # Step 4: Evaluate the model (optional)

    # Step 5: Extract the formula and parameters
    intercept = model.intercept_
    coefficients = model.coef_

    print("coeff size{}".format(len(coefficients)))
    print(coefficients)

    Continue reading...

Compartilhe esta Página