我想计算回归模型建立与使用交叉验证和感到困惑,这两个功能scikitlearn cross_val_score和cross_val_predict我应该使用.一种选择是:
cvs = DecisionTreeRegressor(max_depth = depth)
scores = cross_val_score(cvs, predictors, target, cv=cvfolds, scoring='r2')
print("R2-Score: %0.2f (+/- %0.2f)" % (scores.mean(), scores.std() * 2))
Run Code Online (Sandbox Code Playgroud)
另一个,使用标准的cv预测r2_score:
cvp = DecisionTreeRegressor(max_depth = depth)
predictions = cross_val_predict(cvp, predictors, target, cv=cvfolds)
print ("CV R^2-Score: {}".format(r2_score(df[target], predictions_cv)))
Run Code Online (Sandbox Code Playgroud)
我认为这两种方法都是有效的,并给出类似的结果.但这只是小k倍的情况.虽然r ^ 2对于10倍-cv大致相同,但是对于使用"cross_vall_score"的第一版本的情况,对于更高的k值,它变得越来越低.第二个版本大多不受折叠次数变化的影响.
这种行为是否可以预期,我是否对SKLearn中的CV缺乏了解?
python regression machine-learning scikit-learn cross-validation
我想知道何时应该使用ld链接器代替gcc.我刚用c ++写了一个简单的hello world,当然我包含了iostream库.如果我想用gcc制作一个二进制文件,我只需使用:
g++ hello hello.cpp
我有我的二进制文件.
后来我尝试使用ld链接器.要获取目标文件我使用:
g++ -c hello.cpp.好的,这很简单,但链接命令很糟糕:
ld -o hello.out hello.o \
-L /usr/lib/gcc/x86_64-linux-gnu/4.8.4/ \
/usr/lib/gcc/x86_64-linux-gnu/4.8.4/crtbegin.o \
/usr/lib/gcc/x86_64-linux-gnu/4.8.4/crtend.o \
/usr/lib/x86_64-linux-gnu/crti.o \
/usr/lib/x86_64-linux-gnu/crtn.o \
/usr/lib/x86_64-linux-gnu/crt1.o \
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -lstdc++ -lc
Run Code Online (Sandbox Code Playgroud)
我知道gcc 使用ld的事实.gcc在所有情况下或仅在大多数情况下使用更好?请告诉我有关ld链接器有优势的案例的一些想法.
那是我的代码:
int const const_global_init = 2;
int const const_global;
int global_init = 4;
int global;
static int static_global_init = 3;
static int static_global;
static int static_function(){
return 2;
}
double function_with_param(int a){
static int static_local_init = 3;
static int static_local;
return 2.2;
}
int main(){
}
Run Code Online (Sandbox Code Playgroud)
我生成main.o并尝试理解nm输出.我使用后nm main.o --printfile-name -a得到这个输出:
main.o:0000000000000000 b .bss
main.o:0000000000000000 n .comment
main.o:0000000000000004 C const_global
main.o:0000000000000000 R const_global_init
main.o:0000000000000000 d .data
main.o:0000000000000000 r .eh_frame
main.o:000000000000000b T function_with_param
main.o:0000000000000004 C global …Run Code Online (Sandbox Code Playgroud) 我想覆盖 pod 容器上的文件。现在我已经elasticsearch.yml在位置了/usr/share/elasticsearch/config。
我试图通过initContainerkubernetes 部署文件来实现这一点,所以我添加了如下内容:
- name: disabled-the-xpack-security
image: busybox
command:
- /bin/sh
- -c
- |
sleep 20
rm /usr/share/elasticsearch/config/elasticsearch.yml
cp /home/x/IdeaProjects/BD/infra/istio/kube/elasticsearch.yml /usr/share/elasticsearch/config/
securityContext:
privileged: true
Run Code Online (Sandbox Code Playgroud)
但这不起作用,错误看起来像:
rm: can't remove '/usr/share/elasticsearch/config/elasticsearch.yml': No such file or directory
cp: can't stat '/home/x/IdeaProjects/BD/infra/istio/kube/elasticsearch.yml': No such file or directory
Run Code Online (Sandbox Code Playgroud)
我试图使用一些echo "some yaml config" >> elasticsearch.yml,但这种解决方法不起作用,因为我能够保持正确的 yaml 格式。
您有什么建议吗?我该怎么做?
我知道如何使用gcc和创建共享ln库,但是仅ld当我有目标文件(来自 c++ 或 c 代码)作为输入时,如何创建共享库以及如何交换到新版本的库?
我spyk从mockk图书馆有:
my = spyk(My())
Run Code Online (Sandbox Code Playgroud)
后来我嘲笑其中一种返回类似内容的方法:
every { my.method("someString") } returns something
Run Code Online (Sandbox Code Playgroud)
我正在spyk一个@BeforeAll方法中创建它,并且我重复使用它几次,但是,有时我需要调用真实my.method("someString")而不是模拟版本,但这every{}在任何地方都嘲笑它。
my在某些情况下如何强制调用真正的方法?有没有可能做到这一点?
我听说有可能使用select from dual table生成更新/插入语句.我试图创建一些声明但是,我总是得到无效的标识符.
我的声明:
select 'update some_table_1 t1 set t1.s_name = ' || some_table_2.s_name ||'
where some_table_2.s_code = some_table_1.code; ' from dual;
Run Code Online (Sandbox Code Playgroud)
例如我的情况是:表some_table_1列s_name由从数据更新some_table_2列 s_name,我想创建更新statments,但仅适用于需要行.
怎么做正确?
编辑:看看我的回答,理解我的意思是非常有帮助的.
如何从终端的网站显示数据(股票名称,资本,收盘价,市场价值)?我有这个网站:
http://www.tpex.org.tw/web/stock/aftertrading/daily_mktval/mkt.php?l=en-us
,我创造了一些想法.
my $url = 'http://www.tpex.org.tw/web/stock/aftertrading/daily_mktval/mkt.php?l=en-us';
use LWP::Simple;
my $content = get $url;
die "Couldn't get $url" unless defined $content;
Run Code Online (Sandbox Code Playgroud)
但我真的不知道如何使用$content打印我需要的数据.
我会感激每一个帮助:)