- Take a look at this blog post, maybe you will understand. < font size = "3" > logistic regression to solve binary classification problems(a) < / font > < / a > < / li >
0 Answer
the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > according to the code, you provide train has been reshape correctly into the shape of a(num_examples, 5), Each row represents a training sample and each column represents the value of a feature(factor). Therefore, if you want to train for this logistic regression dichotomy problem, you only need to use the dependent variable as the target variable and x_train as the independent variable. For example:
from sklearn.linear_model import LogisticRegression
# 假设y_train是长度为num_examples的目标变量
clf = LogisticRegression().fit(x_train, y_train)
After training, you can use clf.predict to predict new samples. For example:
y_pred = clf.predict(x_new)
Where x_new is an array of the shape(num_new_examples, 5) representing the eigenvalues of the new sample. y_pred is a one-dimensional array of length num_new_examples that represents the logistic regression classification of these new samples.
这家伙很懒,什么都没留下...