简体   繁体   English

机器学习模型采用数据集并创建线性回归模型,根据用户响应给出答案

[英]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如果我正确理解了这个问题,我们可以使用 sklearn 或不使用 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要查看 sklearn 的代码示例,您可以查看以下链接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要在没有 sklearn 的情况下工作,您可以查看https://medium.com/better-programming/simple-linear-regression-using-only-python-5c86af200bca

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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