Linear models and logistic regression
In this section, we will create a linear model, train it, and display the values of the features produced. We want to visualize the output of the linear model first. Then, we will explore the theoretical aspect of linear models.
Creating, training, and visualizing the output of a linear model
First, let's create, train, and visualize the output of a linear model using logistic regression:
# @title Linear model, logistic regression
model = sklearn.linear_model.LogisticRegression(C=0.1)
model.fit(X_train, y_train)
The program now displays the output of the trained linear model.
First, the program displays the positive values:
# print positive coefficients
lc = len(model.coef_[0])
for cf in range(0, lc):
if (model.coef_[0][cf] >= 0):
print(round(model.coef_[0][cf], 5), feature_names[cf])
Then, the program displays the negative values:
# print negative coefficients
for cf in range(0, lc):
if (model...