我有一个时间序列,我想检测值何时快速增加,并查明(可能是颜色)增加的时间范围。例如,在下图中,我想精确定位 x 轴中特定时间窗口的峰值(例如 2018-05-22)
我能够找到 20% 的最大值,但这对我没有帮助。我想把重点放在快速增长上。
d = pd.Series(df['TS'].values[1:] - df['TS].values[:-1], index=df['TS'].index[:-1]).abs()
threshold = 0.8
m = d.max()
print(d > m * threshold)
Run Code Online (Sandbox Code Playgroud)
例如,破裂在视觉上做了类似的事情。有一个示例,其生成的图中包含随机数据:
import matplotlib.pyplot as plt
import ruptures as rpt
# generate signal
n_samples, dim, sigma = 1000, 3, 4
n_bkps = 4 # number of breakpoints
#signal, bkps = rpt.pw_constant(n_samples, dim, n_bkps, noise_std=sigma)
# detection
algo = rpt.Pelt(model="rbf").fit(signal)
result = algo.predict(pen=10)
# display
rpt.display(signal, bkps, result)
plt.show()
Run Code Online (Sandbox Code Playgroud)
我通常使用RStudio进行数据科学工作。我加载数据集,然后逐行编写并尝试新代码,更改参数,探索数据,并一次执行小块。我目前正在使用PyCharm进行 Python 项目,它似乎适合软件开发,从头到尾运行和调试整个脚本,当使用 RStudio 模式时,这非常慢且令人沮丧。
是否有可能拥有与 RStudio 类似的数据科学环境,是否最好将工具更改为其他工具?
使用dcc.Upload,您可以在 Dash Plotly 仪表板中构建拖放或基于按钮的上传功能。但是,文档中对处理特定文件类型(例如.zip. 这是上传 html 的片段:
dcc.Upload(\n id=\'upload_prediction\',\n children=html.Div([\n \'Drag and Drop or \',\n html.A(\'Select Files\'),\n \' New Predictions (*.zip)\'\n ]),\n style={\n \'width\': \'100%\',\n \'height\': \'60px\',\n \'lineHeight\': \'60px\',\n \'borderWidth\': \'1px\',\n \'borderStyle\': \'dashed\',\n \'borderRadius\': \'5px\',\n \'textAlign\': \'center\',\n \'margin\': \'10px\'\n },\n accept=".zip",\n multiple=True\n)\nRun Code Online (Sandbox Code Playgroud)\n\n然后,当我尝试使用以下代码片段检查上传的文件时:
\n\n@app.callback(Output(\'output_uploaded\', \'children\'),\n [Input(\'upload_prediction\', \'contents\')],\n [State(\'upload_prediction\', \'filename\'),\n State(\'upload_prediction\', \'last_modified\')])\ndef test_callback(list_of_contents, list_of_names, list_of_dates):\n for content in list_of_contents:\n print(content)\nRun Code Online (Sandbox Code Playgroud)\n\n上传后的content-type为\xe2\x80\x98data:application/x-zip-compressed;base64\xe2\x80\x99。如何在 Dash Plotly 中处理这种类型的文件(例如将其提取到某个地方)?
\n\n在plotly论坛中提出了类似的问题,但没有答案:\n https://community.plot.ly/t/dcc-upload-zip-file/33976
\nImportError Traceback (most recent call last)
<ipython-input-13-74c9bc9e3e4a> in <module>
8 from nltk.tokenize.toktok import ToktokTokenizer
9 #import contractions
---> 10 from contractions import CONTRACTION_MAP
11 import unicodedata
12
ImportError: cannot import name 'CONTRACTION_MAP' from 'contractions' (c:\users\nikita\appdata\local\programs\python\python37-32\lib\site-packages\contractions\__init__.py)
Run Code Online (Sandbox Code Playgroud)
一个问题是:该CONTRACTION_MAP变量是否已从包中弃用contractions?
K-means 是一种随机初始化聚类中心的迭代算法。无论聚类中心如何初始化,Kmeans 算法是否都能保证收敛?为什么?
artificial-intelligence machine-learning k-means unsupervised-learning data-science
当我在pandas中尝试一些代码时,bash代码wget在colab中使用如下:
import pandas as pd
!wget abc.com/sales.csv
Run Code Online (Sandbox Code Playgroud)
如果我想使用 PyCharm 下载上述互联网文件,wget 无法识别。那么我应该使用哪个命令来下载这个文件呢?
不幸的是 anaconda 已损坏,我需要卸载并重新安装 anaconda 来解决该问题(Anconda 导航器应用程序未打开,因此我必须卸载它)。我卸载了安康达。当我重新安装它时,它没有正确安装。当我尝试运行 conda 时,它在命令提示符中显示错误。它显示错误消息“conda 未被识别为内部或外部命令”
我想使用数据科学库 NumPy、Pandas、Pytorch 和 Hugging Face 转换器创建一个 Python 环境。我用来miniconda创建环境并下载和安装库。中有一个标志conda install,--download-only用于下载所需的软件包而不安装它们,然后从本地目录安装它们。即使只是conda下载软件包而不安装它们,它也会提取它们。
是否可以下载软件包而不解压它们并在安装前解压它们?
我对 DBT 相当陌生,正在尝试探索如何暴露。我已经阅读了文档(https://docs.getdbt.com/docs/building-a-dbt-project/exposures),但我不觉得我得到了问题的答案。
我很清楚您在模型文件夹中创建曝光文件的概念,然后声明表名称及其依赖的其他表/源。
Q1 - 我应该说明表的整个下游还是仅说明它所依赖的直接表?
Q2 - 它有什么具体好处?你能想出一个具体的场景吗?
Q3 - dbt run -m Exposure:name 和 dbt test -m Exposure:name 的目的是什么?是测试模型还是曝光?
我已经完全按照文档中的说明进行操作,只是不知道如何使用它。
先感谢您 :-)
testing command-line-interface command-line-tool data-science dbt
我训练了一个 LSTM 模型,并尝试对所有测试观察结果进行预测。然而,keras 需要很长时间model.predict才能计算所有预测。有没有办法加快这个过程?假设每个预测有两个特征(x1 和 x2)。每个特征的长度(x1 & x2)都是33。如[32,1,17,.......,0]。我需要进行 100 万次预测。我的代码是
predictions = np.argmax(make.predict([x1, x2]), axis = -1)
Run Code Online (Sandbox Code Playgroud)
有什么想法可以加快速度吗?非常感谢
data-science ×10
python ×7
anaconda ×1
anaconda3 ×1
conda ×1
contractions ×1
dbt ×1
download ×1
ide ×1
k-means ×1
keras ×1
nlp ×1
pandas ×1
plotly ×1
plotly-dash ×1
pycharm ×1
tensorflow ×1
testing ×1
time-series ×1