如何在Jupyter笔记本中键入“是”或“否”

问题描述

我已经提到了这个post和这个post。但这不能解决我的问题。请不要将其标记为重复

我正在尝试使用 {% for items in ipsec %} <tbody> <tr> <td>{{ items.tunnel_name }}</td> <td class="text-center">{{ items.tunnel_ip }}</td> <td class="identifyingClass"><a data-toggle="modal" data-target="#myModal{{ items.id }}" href="/ipsecacl/?acl={{ items.tunnel_acl }}">{{ items.tunnel_acl }}</a></td> <td> <label class="switch"> <div id="statvalue">{{ items.tunnel_status }}</div> <input type="checkBox" id="stats"> <span class="slider round"></span> </label> </td> </tr> {% endfor %} Jupyter Notebook中运行以下代码

R kernel

我收到如下错误消息

model_predictors <- buildModel(flag,fv_full_data,outcomeName,folder)

如何避免此错误并防止jupyter选择Model about to be built # this is log message and not error 1 package is needed for this model and is not installed. (randomForest). Would you like to try to install it Now? # here I see that it asks for a question but without my input it selects `No` Error: required package is missing Traceback: 1. buildModel(flag,folder) 2. train(x = trainDF[,predictorsNames],y = factor(trainLabels),. method = "rf",metric = "Fscore",trControl = objControl,. tuneGrid = rf_grid,preProcess = c("center","scale")) 3. train.default(x = trainDF[,"scale")) 4. checkInstall(models$library) 5. stop("required package is missing",call. = FALSE) 作为动态提示认设置?

解决方法

在您的示例中,您实际上从未到达处理输入的代码部分。这些输入仅适用于交互式会话,而Jupyter则不会。您可以使用

进行检查
<SecretModel>
    <id>3181</id>
    <name>Test</name>
    <secretTemplateId>6044</secretTemplateId>
    <folderId>674</folderId>
    <active>true</active>
    <items>
        <itemId>13960</itemId>
        <fileAttachmentId/>
        <filename/>
        <itemValue>Test</itemValue>
        <fieldId>287</fieldId>
        <fieldName>Username</fieldName>
        <slug>username</slug>
        <fieldDescription>The Amazon IAM username.</fieldDescription>
        <isFile>false</isFile>
        <isNotes>false</isNotes>
        <isPassword>false</isPassword>
    </items>
    <items>
        <itemId>13961</itemId>
        <fileAttachmentId/>
        <filename/>
        <itemValue>AKIAU5G4MQBA2TKQOWNW</itemValue>
        <fieldId>284</fieldId>
        <fieldName>Access Key</fieldName>
        <slug>access-key</slug>
        <fieldDescription>The Amazon IAM access key.</fieldDescription>
        <isFile>false</isFile>
        <isNotes>false</isNotes>
        <isPassword>false</isPassword>
    </items>
</secretModel>

SecretModel.cs:
   
   Public class SecretModel
   {
    public int? id {get; set;}
    public string name {get; set;}
    public string SecretTemplateID {get; set;}
    public string folderId {get; set;}
    public string active {get; set;}
    public string List<RestSecretItem> {get; set;}
    }   
    
    
    public partial class RestSecretItem : IEquatable<RestSecretItem>
    { 
        
        public string FieldDescription { get; set; }

        public int? FieldId { get; set; }

        public string FieldName { get; set; }

        public int? FileAttachmentId { get; set; }
        public string Filename { get; set; }
        public bool? IsFile { get; set; }

        public bool? IsNotes { get; set; }

        public bool? IsPassword { get; set; }
        public int? ItemId { get; set; }

        public string ItemValue { get; set; }

        public string Slug { get; set; }
}

interactive() #> FALSE menu(c("yes","no")) #> Error in menu(c("yes","no")): menu() cannot be used non-interactively #> Traceback: #> #> 1. menu(c("yes","no")) #> 2. stop("menu() cannot be used non-interactively") 打印出消息“您想立即安装x吗?”,但它仅接受交互式会话的输入。

这是caret::checkInstall和我的评论的代码。

caret::checkInstall

根据您的情况,function (pkg) { good <- rep(TRUE,length(pkg)) for (i in seq(along = pkg)) { tested <- try(find.package(pkg[i]),silent = TRUE) if (inherits(tested,"try-error")) good[i] <- FALSE } if (any(!good)) { pkList <- paste(pkg[!good],collapse = ",") msg <- paste(sum(!good),ifelse(sum(!good) > 1," packages are"," package is")," needed for this model and"," are"," is")," not installed. (",pkList,"). Would you like to try to install"," them"," it")," now?",sep = "") cat(msg) # Print the message if (interactive()) { # In Jupyter,`interactive()` is `FALSE`. bioc <- c("affy","logicFS","gpls","vbmp") installChoice <- menu(c("yes","no")) # This is where it gets input if (installChoice == 1) { hasBioc <- any(pkg[!good] %in% bioc) if (!hasBioc) { install.packages(pkg[!good]) } else { inst <- pkg[!good] instC <- inst[!(inst %in% bioc)] instB <- inst[inst %in% bioc] if (length(instC) > 0) install.packages(instC) biocLite <- NULL source("http://bioconductor.org/biocLite.R") biocLite(instB) } } else stop("Required package is missing",call. = FALSE) } else stop("Required package is missing",call. = FALSE) # Because `interactive()` is `FALSE`,this `stop` is called } } 是最佳选择。

如果您在install.packages("randomForest")中,则可以像这样使用RStudio

rstudioapi

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...