我对 Keras 很陌生,我想从教程开始。在那里,让我们几乎在开始时说,代码行
将预混洗的 MNIST 数据加载到训练集和测试集
(X_train, y_train), (X_test, y_test) = mnist.load_data()
出现。我想知道 Keras 如何知道哪些数据是训练的一部分,哪些是测试的一部分?虽然这是一个非常基本的问题,但我无法在 Keras 文档中看到特定的定义(搜索甚至没有在那里提供任何结果)。因此,我感谢任何帮助,因为我经常在Keras 中找不到任何命令定义。对于其他语言,如 C++、R、Python 等,很容易找到一些定义。但是对于 Keras,即使是 google 也没有为我提供有用的搜索结果(至少在前 2 页中没有)。
TL;DR:load_data() 如何知道数据集的训练和测试是什么?
我有一个混合效果模型,我想看到R²-和p值.我认为这可以通过summary()获得,但事实并非如此.或者至少我没有意识到这一点.
> summary(fit1.lme <- lmer(log(log(Amplification)) ~ poly(Voltage, 3) + (1 | Serial_number), data = bdf))
Linear mixed model fit by REML ['lmerMod']
Formula: log(log(Amplification)) ~ poly(Voltage, 3) + (1 | Serial_number)
Data: bdf
REML criterion at convergence: -253237.6
Scaled residuals:
Min 1Q Median 3Q Max
-14.8183 -0.4863 -0.0681 0.2941 9.3292
Random effects:
Groups Name Variance Std.Dev.
Serial_number (Intercept) 0.008435 0.09184
Residual 0.001985 0.04456
Number of obs: 76914, groups: Serial_number, 1270
Fixed effects:
Estimate Std. Error t value
(Intercept) 0.826745 0.002582 …Run Code Online (Sandbox Code Playgroud) 在C++中计算二项式系数的最佳方法是什么?我已经看到了一些代码片段,但在我看来,它总是只在某个特定区域可行.我需要一个非常非常可靠的计算.我尝试使用gamma功能:
unsigned n=N;
unsigned k=2;
number = tgammal(n + 1) / (tgammal(k + 1) * tgammal(n - k + 1));
Run Code Online (Sandbox Code Playgroud)
但它在n = 8时已经不同,k = 2的1(并且n = 30,k = 2它崩溃).我"仅"需要计算大约至少n = 3000,其中k = 2.
我有一个包含5个变量的数据框:批/晶圆/序列号/电压/放大.在该数据帧中,有1020个子集由Serial_number分组.每个子集具有一定数量的测量数据点(针对电压的放大).
我适合数据
summary(fit2.lme <- lmer(log(log(Amplification)) ~ poly(Voltage, 3) + (poly(Voltage, 1) | Serial_number),
+ data = APD))
Run Code Online (Sandbox Code Playgroud)
产量:
Linear mixed model fit by REML ['lmerMod']
Formula: log(log(Amplification)) ~ poly(Voltage, 3) + (poly(Voltage, 1) | Serial_number)
Data: APD
REML criterion at convergence: 35286.1
Scaled residuals:
Min 1Q Median 3Q Max
-20.7724 -0.2438 -0.1297 0.2434 13.2663
Random effects:
Groups Name Variance Std.Dev. Corr
Serial_number (Intercept) 1.439e-02 0.1199
poly(Voltage, 1) 2.042e+03 45.1908 -0.76
Residual 8.701e-02 0.2950
Number of obs: 76219, groups: Serial_number, 1020 …Run Code Online (Sandbox Code Playgroud) 我用Rstudio。根据https://stats.stackexchange.com/questions/135694/using-b-splines-within-a-linear-mixed-effects-model-in-r我想将所谓的 b-splines 添加到我的型号:
degree<- 3\nfit<- lmer(log(log(Amplification)) ~ bs(poly(Voltage, degree)) + bs(poly(Voltage, degree) | Serial_number),data = APD))\nRun Code Online (Sandbox Code Playgroud)\n\n但这会导致
\n\nError in splineDesign(Aknots, x, ord) : \n length of \'derivs\' is larger than length of \'x\'\nIn addition: Warning messages:\n1: In Ops.factor(poly(Voltage, 3), Serial_number) :\n \xe2\x80\x98+\xe2\x80\x99 not meaningful for factors\n2: In min(x, na.rm = na.rm) :\n no non-missing arguments to min; returning Inf\n3: In max(x, na.rm = na.rm) :\n no non-missing arguments to max; returning -Inf\nRun Code Online (Sandbox Code Playgroud)\n\n … 我有一个数据框如下:
Serial_number Amplification Voltage
(...)
51 912009913 50.8258 335.965
52 912009913 54.3855 337.966
53 912009913 58.3014 339.959
54 912009913 62.6758 341.956
55 912009913 67.5537 343.965
56 912009913 72.9996 345.965
57 912009913 79.1489 347.964
58 912009913 86.1111 349.965
59 912009913 94.0453 351.957
60 912009913 103.2320 353.957
61 912009913 113.9780 355.964
62 912009913 126.5830 357.964
63 912009913 141.6830 359.963
64 912009913 160.0800 361.962
65 912009913 182.8440 363.955
66 912009913 211.9870 365.957
67 912009913 250.4290 367.965
(...)
119 912009897 50.8925 329.968
120 912009897 …Run Code Online (Sandbox Code Playgroud) 我有这些数据:
> dput(df)
structure(list(Freq = c(41L, 31L, 11L, 0L), group = structure(c(1L,
1L, 2L, 2L), .Label = c("A", "B"), class = "factor"), Survived = structure(c(2L,
1L, 2L, 1L), .Label = c("No", "Yes"), class = "factor")), row.names = c(NA,
4L), class = "data.frame")
Run Code Online (Sandbox Code Playgroud)
Freq group Survived
1 41 A Yes
2 31 A No
3 11 B Yes
4 0 B No
Run Code Online (Sandbox Code Playgroud)
我尝试遵循https://data-flair.training/blogs/chi-square-test-in-r/但我不确定如何使用这些数据。例如,当我使用时chisq.test(df$group, df$Survived)我收到
> chisq.test(df$group, df$Survived)
Pearson's Chi-squared test
data: df$group and df$Survived
X-squared = 0, …Run Code Online (Sandbox Code Playgroud) 我无法更改 ggpair-plot 中的对角线图。我想总体上改变它们的外观,也许从让它们空白开始。这就是我认为应该是这样的:
ggpairs(data=df,
columns=1:3,
diag = list(discrete = "blank"),
title="APD pool",
mapping=ggplot2::aes(colour = Irradiated)
)
Run Code Online (Sandbox Code Playgroud)
但它以对角元素中的密度曲线(?!)结束。由于罗宾的评论,我尝试了
ggpairs(data=df,
columns=1:3,
diag = list(continous = "blank"),
title="APD pool",
mapping=ggplot2::aes(colour = Irradiated)
)
Run Code Online (Sandbox Code Playgroud)
但它不会改变。
我究竟做错了什么?谢谢!
R 中是否有一个函数可以生成给定函数的反函数?更具体地说:我有一个三阶多项式,我需要它的倒数。这是严格单调的。
我读过几次,uniroot 和/或多根可以提供帮助。但如何呢?Uniroot 产生函数的根,polyroot 产生函数的零点。我怎样才能用它来求逆呢?也许是一个愚蠢的问题,但我不明白..
是什么目的-c,并nrow在这个功能呢?
bdf <- by(bdf, bdf$Serial_number, function(SN, k) {
SN[-c(1:k, (nrow(SN)-k+1):nrow(SN)),]
}, k = 10)
Run Code Online (Sandbox Code Playgroud)
by()通过第二个参数Serial_number拆分数据帧bdf,并在第三个参数中拆分apply函数函数(SN,k).我不明白这个功能的主体.