小编ROS*_*ILI的帖子

类型错误:此数据类型不允许缩减操作“argmax”

我实际上不知道我的代码有什么问题。有人可以帮忙吗?

from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import KFold, cross_val_score
from sklearn.metrics import confusion_matrix,precision_recall_curve,auc,roc_auc_score,roc_curve,recall_score,classification_report

def printing_Kfold_scores(x_train_data,y_train_data):
    fold = KFold(len(y_train_data),5,shuffle=False) 

    # Different C parameters
    c_param_range = [0.01,0.1,1,10,100]

    results_table = pd.DataFrame(index = range(len(c_param_range),2), columns = ['C_parameter','Mean recall score'])
    results_table['C_parameter'] = c_param_range

    # the k-fold will give 2 lists: train_indices = indices[0], test_indices = indices[1]
    j = 0
    for c_param in c_param_range:
        print('-------------------------------------------')
        print('C parameter: ', c_param)
        print('-------------------------------------------')
        print('')

        recall_accs = []
        for iteration, indices in enumerate(fold,start=1):

            # Call the logistic regression model …
Run Code Online (Sandbox Code Playgroud)

python machine-learning

7
推荐指数
1
解决办法
1万
查看次数

文件 ../MatrixOps/cholmod_sdmult.c,第 90 行中的 Cholmod 错误“X 和/或 Y 的尺寸错误”

它只是报告:

Cholmod 错误“X 和/或 Y 的尺寸错误”位于文件 ../MatrixOps/cholmod_sdmult.c,第 90 行。

我不知道为什么。

    x.m <- data.matrix(train[,c(1:43)])
    x.m [is.na(x.m)] <- 0
    y.m <- train$NPL
    cv.m <-data.matrix(cv)
    set.seed(356)


    cvfit.m.lasso = cv.glmnet(x.m, y.m, 
                      family = "binomial", 
                      alpha = 1,
                      type.measure = "class")
    par(mfrow=c(1,2))
    plot(cvfit.m.lasso, main = "Lasso")
    coef(cvfit.m.lasso, s = "lambda.min")
    predTrain.M = predict(cvfit.m.lasso, newx=cv.m, type="class")
    table(cv$NPL, predTrain.M)
Run Code Online (Sandbox Code Playgroud)

r glmnet

6
推荐指数
1
解决办法
4824
查看次数

标签 统计

glmnet ×1

machine-learning ×1

python ×1

r ×1