Try to create new train matrix
X_train_sparse_new = crs_matrix(hstack((X_train_sparse, new_feat_train['year_month_scaled'].values.reshape(-1,1))))
but get error name 'crs_matrix' is not defined. Anyway, I have imported it:
from scipy.sparse import csr_matrix, hstack
and want to ran my own class:
def get_auc_lr_valid(X, y, C=1.0, ratio=0.9, seed=17):
train_len = int(ratio*X.shape[0])
X_train = X[:train_len, :]
X_valid = X[train_len:, :]
y_train = y[:train_len]
y_valid = y[train_len:]
logit = LogisticRegression(C=C, n_jobs=-1, random_state=seed) #объект логистическая регрессия, задействуем все ядра
#передали то занчаений C, которое пришло вызовом из аргумента значений функции
logit.fit(X_train, y_train)
valid_pred = logit.predict_proba(X_valid)[:, 1] #прогноз для отложеннрой части, который дает вероятности для Элис
return roc_auc_score(y_valid, valid_pred)
for kaggle dataset https://www.kaggle.com/c/catch-me-if-you-can-intruder-detection-through-webpage-session-tracking2
Can you please help me to deal with crs_matrix, please
Expect to get matrix which I can use for my class
it's just because of a small spelling mistake in,
X_train_sparse_new = crs_matrix(hstack((X_train_sparse, new_feat_train['year_month_scaled'].values.reshape(-1,1))))
swap r and s in crs_matrix
.
Correct code is
X_train_sparse_new = csr_matrix(hstack((X_train_sparse, new_feat_train['year_month_scaled'].values.reshape(-1,1))))