我有一个由20个特征和大约300,000个观测值组成的数据集.我正在使用插入符号来训练带有doParallel和四个核心的模型.对于我尝试的方法(rf,nnet,adabag,svmPoly),即使对我的数据进行10%的训练也需要8个多小时.我正在重新采样3次,我的tuneLength是5.我能做些什么来加速这个令人痛苦的缓慢过程?有人建议使用底层库可以加快我的过程10倍,但在我走下去之前我想确保没有其他选择.
/home/foo/mydir我有一个由 (uid=1040) 拥有的目录foo:foo,我将其绑定安装在 alpine docker 映像中,如下所示:
docker run -it --rm -v /home/foo/mydir:/tmp/mydir --user 1040 alpine
但是当我检查容器中的目录时,它属于root:root. 我疯了吗?我认为 docker 在安装到容器中时会传递文件所有权?无论如何,是否可以保留权限(即在容器中mydir拥有的权限)而不将其放入容器中?foo:foo
我有两个感兴趣的矩阵,第一个是“词袋”矩阵,有两列:文档 ID 和术语 ID。例如:
bow[0:10]
Out[1]:
array([[ 0, 10],
[ 0, 12],
[ 0, 19],
[ 0, 20],
[ 1, 9],
[ 1, 24],
[ 2, 33],
[ 2, 34],
[ 2, 35],
[ 3, 2]])
Run Code Online (Sandbox Code Playgroud)
此外,我有一个“索引”矩阵,其中矩阵中的每一行都包含词袋矩阵中给定文档 ID 的第一行和最后一行的索引。例如:第 0 行是 doc id 0 的第一个和最后一个索引。例如:
index[0:4]
Out[2]:
array([[ 0, 4],
[ 4, 6],
[ 6, 9],
[ 9, 10]])
Run Code Online (Sandbox Code Playgroud)
我想要做的是随机抽取文档 ID 的样本并获取这些文档 ID 的所有单词行包。词袋矩阵大约有 150M 行(~1.5Gb),所以使用 numpy.in1d() 太慢了。我们需要快速返回这些以供下游任务使用。
我想出的天真解决方案如下:
def get_rows(ids):
indices = np.concatenate([np.arange(x1, x2) for x1,x2 in index[ids]])
return …Run Code Online (Sandbox Code Playgroud) I've read previous threads that cover this issue for navbars and menus but it does not seem to apply. I have a very simple example: two cards, one opened by default the other collapsed. When I try to expand the second card by pressing Card 2 Button, it opens but then immediately closes again. I am not sure what I'm doing wrong.
Example here:
<div id="accordion">
<div class="card">
<div class="card-header" id="header1">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapse1" aria-expanded="true" aria-controls="collapse1"> …Run Code Online (Sandbox Code Playgroud) 我有一个大熊猫数据框,大约有150,000,000行,格式如下:
df.head()
Out[1]:
ID TERM X
0 1 A 0
1 1 A 4
2 1 A 6
3 1 B 0
4 1 B 10
5 2 A 1
6 2 B 1
7 2 F 1
Run Code Online (Sandbox Code Playgroud)
我想通过ID和TERM聚合它,并计算行数.目前我做以下事情:
df.groupby(['ID','TERM']).count()
Out[2]:
ID TERM X
0 1 A 3
1 1 B 2
2 2 A 1
3 2 B 1
4 2 F 1
Run Code Online (Sandbox Code Playgroud)
但这大约需要两分钟.使用R data.tables的相同操作只需不到22秒.在python中有更有效的方法吗?
为了比较,R data.table:
system.time({ df[,.(.N), .(ID, TERM)] })
#user: 30.32 system: 2.45 elapsed: 22.88
Run Code Online (Sandbox Code Playgroud) 我有一个大约有1亿行的数据框(内存为1.4Gb)
给定输入:
df.head()
Out[1]:
id term x
0 1 A 3
1 1 B 2
2 2 A 1
3 2 B 1
4 2 F 1
5 2 G 1
6 2 Z 1
7 3 K 1
8 3 M 1
9 3 N 1
10 3 Q 1
11 3 R 1
12 3 Z 1
13 4 F 1
Run Code Online (Sandbox Code Playgroud)
我想为每个ID检索第一行的索引。例:
Out[1]:
id first_idx
0 1 0
1 2 2
2 3 7
2 4 13
Run Code Online (Sandbox Code Playgroud)
我当前的方法非常慢: …
我发现在调用异步方法时我的C#app UI挂起,我无法弄清楚原因.
private async void selectCSVFileButton_Click(object sender, EventArgs e)
{
...
var results = await ntz.getProductNames();
...
}
...
public async Task<List<string[]>> getProductNames()
{
string fmt = "DRIVER={{NetezzaSQL}};SERVER={0};PORT={1};DATABASE={2};UID={3};PWD={4};";
ntz = new OdbcConnection(string.Format(fmt, server, port, db, user, password));
await ntz.OpenAsync();
qry = "SELECT * FROM ak_db_1 WHERE prod_name_desc='Unknown'";
OdbcCommand cmd = ntz.CreateCommand();
cmd.CommandTimeout = 600;
cmd.CommandText = qry;
await cmd.ExecuteNonQueryAsync();
...
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序完全挂起(UI无响应),直到cmd.ExecuteNonQueryAsync完成.有任何想法吗?
numpy ×3
optimization ×3
python ×3
dataframe ×2
pandas ×2
arrays ×1
asynchronous ×1
bootstrap-4 ×1
c# ×1
docker ×1
javascript ×1
netezza ×1
performance ×1
r ×1
r-caret ×1
sql ×1