fit_intercept = False
means the bias b
is set to 0, and expit
from scipy.special.expit
is the logistic (sigmoid) activation function.
model = LogisticRegression(fit_intercept = False)
model.fit(train[xcols], train[ycol])
pred_y = model.predict(test[xcols])
X = test[xcols].values
c = model.coef_.reshape(-1, 1)
pred_y = expit(X @ c) > 0.5
pred_y = expit(X @ c)
pred_y = X @ c > 0.5
pred_y = X @ c
c1
is a categorical column containing 4 categories, and c2
is a numerical column. How many columns will be produced after we apply the following custom_transformer
?
custom_transformer = make_column_transformer(
(OneHotEncoder(), ["c1"]),
(PolynomialFeatures(degree = 2, include_bias = False), ["c2"]),
)
6 A = numpy.array([[1, 0], [0, 1]])
and b = numpy.array([[2], [3]])
, what is A @ b
? numpy.array([[2], [3]])
numpy.array([2, 3])
numpy.array([[2, 0], [0, 3]])
numpy.array([[2, 2], [3, 3]])
X @ numpy.linalg.solve(X, y)
, assuming the code runs without error (and numerical instability)? y
X
X @ y
y @ X
A
is (2, 3), the shape of B
is (3, 3), and the shape of C
is (3, 4). What is the shape of A @ B @ C
? (2, 4)
(3, 3)
(4, 2)
X @ c
, where X
is the design matrix and c
is the coefficient vector. LinearRegression.predict
LinearRegression.predict_proba
LogisticRegression.predict
LogisticRegression.predict_proba
sklearn.neural_network.MLPClassifier(hidden_layer_sizes = [3, 4])
with 2 input features and used for binary classifications, how many weights and biases does the network has? x0
has three columns, and x = sklearn.preprocessing.PolynomialFeatures(2).fit_transform(x0)
is used as the design matrix, how many weights (include coefficients and biases) will a linear regression estimate? Feature | Coefficient | Score if Dropped |
1 | 1 | 0.6 |
2 | 10 | 0.8 |
3 | -10 | 0.7 |
4 | 5 | 0.5 |
Last Updated: November 18, 2024 at 11:43 PM