简体   繁体   中英

Machine Learning model that takes dataset and creates a linear regression model that gives answers based user response

I'm trying to write a Machine Learning model that takes my dataset and creates a linear regression plot, and takes a user given response and outputs the value that correspond to the given integer. How would I do that? Any code examples would help greatly. I'm pretty sure I have a suitable algorithm.

def simple_linear_regression(train, test):
    predictions = list()
    b0, b1 = coefficients(train)
    for row in test:
        yhat = b0 + b1 * row[0]
        predictions.append(yhat)
    return predictions

If I understood the question correctly we can do it using sklearn or without sklearn

To see the code sample with sklearn you can check below link https://scikit-learn.org/stable/auto_examples/linear_model/plot_ols.html

To work without sklearn, you can check https://medium.com/better-programming/simple-linear-regression-using-only-python-5c86af200bca

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM