我目前正在尝试使用openmp. 我把特拉维斯的旗帜挂'-fopenmp'在了身上。
我该如何解决这个问题?
在本地我刚刚brew install libopenmp解决了这个问题。但特拉维斯不行,有什么选择?
使用 cython 我得到以下“.travis.yml”
os: linux
dist: xenial
language: python
python:
- "3.7"
cache: pip
addons:
apt:
packages:
- patchelf
matrix:
include:
- os: osx
# No version of Python is available via virtualenv on OS X workers, see https://github.com/travis-ci/travis-ci/issues/2312
language: generic
env: TOXENV=py37
fast_finish: true
before_install:
brew install libomp
install:
- pip install --upgrade "pip < 19.1" -r CI/requirements.txt
- python setup.py develop
script:
- pytest
Run Code Online (Sandbox Code Playgroud)
Travis 在执行时失败: …
对于以下两种检查数据帧是否为空的方法:
df.isEmptydf.limit(1).count == 0我看到df.isEmpty有以下实现:
def isEmpty: Boolean = withAction("isEmpty", limit(1).groupBy().count().queryExecution) { plan =>
plan.executeCollect().head.getLong(0) == 0
}
Run Code Online (Sandbox Code Playgroud)
看起来它不只是直接计数。
其背后的想法是groupBy什么?只是为了获取数据框?
为什么要queryExecution使用该计划?
我正在做一些关于列表上的操作速度的实验。为此,我定义了两个列表:l_short = []和l_long = list(range(10**7))。
这个想法是bool(l)与len(l) != 0
在if比赛中,下面的实现是快了很多if l: pass,而不是if len(l) != 0: pass
但是没有if竞赛,我得到了以下结果:
%%timeit
len(l_long) != 0
# 59.8 ns ± 0.358 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
%%timeit
bool(l_long)
# 63.3 ns ± 0.192 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
Run Code Online (Sandbox Code Playgroud)
的时间bool稍长,为什么呢?
这是使用dis(FYI)的字节码
dis("len(l_long) != 0")
""" …Run Code Online (Sandbox Code Playgroud) 我想我没有正确地从源代码安装 pylint。这是学习包如何在 python 中工作的好机会。
我pylint从源代码安装,我可以在我的 pip 列表中看到它。
我想卸载它并从pypi安装。
但是,我的 2 点是空的,但是当我使用 pylint --version
我有一个错误
bash: /usr/local/bin/pylint: no such file or directory
有没有办法删除这个 bash 命令?Pylint 可能已安装,但我不知道在哪里,或者如何删除它?
编辑:正如评论中所建议的,我尝试了这个链接Find which version of package is installed with pip。这也给了我空洞的答案。
which pylint
pip list | grep pylint
pip2 list | grep pylint
所有这些命令都给了我空洞的答案,但在使用 pylint 时我仍然有同样的错误
我有多变量时间序列数据,想用隔离森林算法检测异常。想从 gridSearchCV 获得最佳参数,这里是 gridSearch CV 的代码片段。
输入数据集加载了以下代码片段。
df = pd.read_csv("train.csv")
df.drop(['dataTimestamp','Anomaly'], inplace=True, axis=1)
X_train = df
y_train = df1[['Anomaly']] ( Anomaly column is labelled data).
Run Code Online (Sandbox Code Playgroud)
定义隔离森林的参数。
clf = IsolationForest(random_state=47, behaviour='new', score="accuracy")
param_grid = {'n_estimators': list(range(100, 800, 5)), 'max_samples': list(range(100, 500, 5)), 'contamination': [0.1, 0.2, 0.3, 0.4, 0.5], 'max_features': [5,10,15], 'bootstrap': [True, False], 'n_jobs': [5, 10, 20, 30]}
f1sc = make_scorer(f1_score)
grid_dt_estimator = model_selection.GridSearchCV(clf, param_grid,scoring=f1sc, refit=True,cv=10, return_train_score=True)
grid_dt_estimator.fit(X_train, y_train)
Run Code Online (Sandbox Code Playgroud)
执行 fit 后,出现以下错误。
值错误:目标是多类但平均值 = 二进制。请选择其他平均设置。
有人可以指导我这是关于什么的吗,尝试了average='weight',但仍然没有运气,这里有什么地方做错了。请让我知道如何获得 F 分数。
I have a simple example here to help me understand using numba and cython. I am `new to both numba and cython. I've tried my best with to incorporate all the tricks to make numba fast and to some extent, the same for cython but my numpy code is almost 2x faster than numba (for float64), more than 2x faster if using float32. Not sure what I am missing here.
I was thinking perhaps the problem isn't coding anymore but …
我正在将 Log4j 与附加程序一起用于"com.kdgregory.log4j.aws.CloudWatchAppender"我的应用程序日志。当我在 EC2 或 Lambda 中运行 AWS Cloudwatch 时,会在 AWS Cloudwatch 中接收日志。但是,如果我运行使用具有相同类的 Spark 构建的应用程序,这些日志都不会传递到 Cloudwatch。有谁知道如何从 Spark 应用程序将 Log4j 日志发送到 AWS Cloudwatch。
log4j amazon-web-services apache-spark amazon-cloudwatchlogs
已经有很多关于删除异常值的问题,但我无法用它们解决我的问题。
我想从 中删除带有异常值的行dataframe。
说,我有以下内容dataframe:
0 1 2 3 4 5 6 7
a 1 2 3 4 100 2 1 3
b 2 1 3 4 1 2 300 123
c 100 200 300 400 200 500 200 400
Run Code Online (Sandbox Code Playgroud)
对于 row,a我们可以假设 100 是异常值,所以我想删除a.
尽管 Row 中的所有值c都很高,但它们并不是该行本身的异常值,因此,我想保留它。
所以,基本上我想删除所有带有异常值的行。
我尝试调换 DF 并做了类似的事情
df = df[(np.abs(stats.zscore(df)) < 2).all(axis=1)],但没有成功
python ×4
apache-spark ×2
cython ×2
performance ×2
python-3.x ×2
cpython ×1
data-science ×1
log4j ×1
numba ×1
numpy ×1
openmp ×1
pandas ×1
pip ×1
pylint ×1
scala ×1
scikit-learn ×1
travis-ci ×1