小编Sh.*_*vel的帖子

在 GridSearchCV 中使用精度作为评分时如何指定正标签

model = sklearn.model_selection.GridSearchCV(
        estimator = est, 
        param_grid = param_grid,
        scoring = 'precision',
        verbose = 1,
        n_jobs = 1,
        iid = True,
        cv = 3)
Run Code Online (Sandbox Code Playgroud)

在 中sklearn.metrics.precision_score(y, y_pred,pos_label=[0]),我可以指定正标签,如何在 GridSearchCV 中也指定它?

如果无法指定,使用自定义评分时,如何定义?

我试过这个:

custom_score = make_scorer(precision_score(y, y_pred,pos_label=[0]),  
                          greater_is_better=True)  
Run Code Online (Sandbox Code Playgroud)

但我有错误:

NameError: name 'y_pred' is not defined
Run Code Online (Sandbox Code Playgroud)

scoring scikit-learn grid-search

5
推荐指数
1
解决办法
1574
查看次数

如何从 Spring Boot 获取操作系统环境变量?

我是java和spring框架的新手。我的问题是如何将 OS(ubuntu) 环境变量注入 spring boot bean。我试过的:

@Configuration
@EnableWebMvc
public class CorsConfig implements WebMvcConfigurer {
 @Value("${COMPONENT_PARAM_CORS}")
 private String COMPONENT_PARAM_CORS;

 @Override
 public void addCorsMappings(CorsRegistry registry) {
  registry.addMapping("/"+COMPONENT_PARAM_CORS);
 }
}
Run Code Online (Sandbox Code Playgroud)

导出 COMPONENT_PARAM_CORS=**

打印环境

告诉我它存在,但是当我尝试 mvn clean install 时:发生错误

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'corsConfig': Injection of autowired dependencies 
failed; nested exception is java.lang.IllegalArgumentException: Could not 
resolve placeholder 'COMPONENT_PARAM_CORS' in value "${COMPONENT_PARAM_CORS}"
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 
'COMPONENT_PARAM_CORS' in value "${COMPONENT_PARAM_CORS}"
Run Code Online (Sandbox Code Playgroud)

然后我的单元测试也下降了(我试图搜索这个错误,但所有主题都是旧的并且使用来自 application.properties 的参数,但我需要使用 …

java spring environment-variables

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