我刚刚将Jupyter升级到版本4.3.1虽然我可以打开以前创建的ipynb文件,但我无法创建新的.
当我尝试创建一个新的笔记本文件时,我得到一个弹出窗口说:
创建笔记本失败
创建新笔记本时发生错误
Forbidden
在终端我注意到这个输出:
[W 12:53:23.375 NotebookApp] 403 POST /api/contents (::1): '_xsrf' argument missing from POST
[W 12:53:23.383 NotebookApp] 403 POST /api/contents (::1) 8.92ms referer=http://localhost:8888/tree?token=e7fbbb58516dc1359fcc26a1079093166a1f713ee5b94ccd
Run Code Online (Sandbox Code Playgroud)
我使用Jupyter与Python 3.5.2和IPython 5.1.0
我正在学习如何在Python上使用Imputer.
这是我的代码:
df=pd.DataFrame([["XXL", 8, "black", "class 1", 22],
["L", np.nan, "gray", "class 2", 20],
["XL", 10, "blue", "class 2", 19],
["M", np.nan, "orange", "class 1", 17],
["M", 11, "green", "class 3", np.nan],
["M", 7, "red", "class 1", 22]])
df.columns=["size", "price", "color", "class", "boh"]
from sklearn.preprocessing import Imputer
imp=Imputer(missing_values="NaN", strategy="mean" )
imp.fit(df["price"])
df["price"]=imp.transform(df["price"])
Run Code Online (Sandbox Code Playgroud)
但是,这会引发以下错误:ValueError:值的长度与索引的长度不匹配
我的代码有什么问题???
谢谢你的帮助
我正在尝试使用 Keras 函数式 API 训练 seq2seq 翻译器。以下代码工作正常:
encoder_inputs = Input(shape=(None, num_encoder_tokens))
encoder = LSTM(latent_dim, return_state=True)
encoder_outputs, state_h, state_c = encoder(encoder_inputs)
Run Code Online (Sandbox Code Playgroud)
我现在想尝试双向 LSTM。我的尝试:
encoder_inputs = Input(shape=(None, num_encoder_tokens))
encoder = Bidirectional(LSTM(latent_dim, return_state=True))
encoder_outputs, state_h, state_c = encoder(encoder_inputs)
Run Code Online (Sandbox Code Playgroud)
这将返回一个错误:
ValueError Traceback (most recent call last)
<ipython-input-25-6ae24c1319f3> in <module>()
6 encoder = Bidirectional(LSTM(latent_dim, return_state=True))
7 print(len(encoder(encoder_inputs)))
----> 8 encoder_outputs, state_h, state_c = encoder(encoder_inputs)
9
10 # We discard `encoder_outputs` and only keep the states.
ValueError: too many values to unpack (expected 3)
Run Code Online (Sandbox Code Playgroud)
如何从双向 LSTM …
我必须对 pyspark 数据框进行 2 个级别的分组。我的试探:
grouped_df=df.groupby(["A","B","C"])
grouped_df.groupby(["C"]).count()
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
'GroupedData' object has no attribute 'groupby'
Run Code Online (Sandbox Code Playgroud)
我想我应该首先将分组对象转换为 pySpark DF。但我不能那样做。
有什么建议吗?
我有一系列的花车。它是数据帧 sum() 操作的结果。我需要将其所有元素舍入为整数,但出现错误:
[in]:
A= mins.sum().iloc[1:]/60
# this line works fine. The .iloc is to get rid of a text column.
[in]:
print(A)
[out]:
Min bad 249.5
Min pr-ul 967.57
intra com diff 178.05
Intra com diff 60 184.27
dtype: object
Run Code Online (Sandbox Code Playgroud)
现在,如果我尝试四舍五入,则会收到错误:
[in]:
A.round()
[out]:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-528-685b5302b717> in <module>()
3
4 print(A)
----> 5 A.round()
//anaconda/lib/python3.5/site-packages/pandas/core/series.py in round(self,decimals, *args, **kwargs)
1303 """
1304 nv.validate_round(args, kwargs)
-> 1305 result = _values_from_object(self).round(decimals)
1306 result = self._constructor(result, …Run Code Online (Sandbox Code Playgroud) 如何在 DBSCAN 中绘制(在 python 中)给定最小点值的距离图???
我正在寻找膝盖和相应的 epsilon 值。
在 sklearn 中,我没有看到任何返回这种距离的方法......我错过了什么吗?
我正在训练一个神经网络与Keras使用EarlyStopping基于val_acc和patience=0.EarlyStopping一旦val_acc减少就停止训练.
然而,我获得的最终模型不是最好的模型,即最高模型val_acc.但我宁愿将模型对应于之后的时代,即对应于val_acc比最佳时期稍低一点的模型,并且导致早期停止!
我如何获得最好的一个?
我尝试使用回调使用保存最佳模型:
ModelCheckpoint(filepath='best_model.h5', monitor='val_loss', save_best_only=True)]
Run Code Online (Sandbox Code Playgroud)
但我得到了相同的结果.
步骤函数如何在数组的 Mapbox 填充颜色属性中工作?尽管:
R=[ 'interpolate', ['linear'],['number',['get', dim_properties.name]], -150, "#800026", -133, "#bd0026", -116, "#e31a1c", -100, "#fc4e2a", -83, "#fd8d3c", -66, "#feb24c", -50, "#fed976", -33, "#ffeda0", -16, "#ffffcc", 0, "#ffffff"]
map.addLayer({
id: 'er',
type: 'fill',
source: {
type: 'vector',
url: pixelling_url
},
'source-layer':pixelling_source_layer,
paint: {
'fill-color':R
}
Run Code Online (Sandbox Code Playgroud)
作品完美,
其他代码则没有。
R=[ 'step',['get', dim_properties.name]], -150, "#800026", -133, "#bd0026", -116, "#e31a1c", -100, "#fc4e2a", -83, "#fd8d3c", -66, "#feb24c", -50, "#fed976", -33, "#ffeda0", -16, "#ffffcc", 0, "#ffffff"]
map.addLayer({
id: 'er',
type: 'fill',
source: {
type: 'vector',
url: pixelling_url …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Tensorflow作为后端,在Keras LSTM中将Jaccard系数应用为自定义损失函数。
我知道我必须打以下电话:
model.compile(optimizer='rmsprop', loss=[jaccard_similarity])
Run Code Online (Sandbox Code Playgroud)
其中jaccard_similarity函数应为以下的keras.backend实现:
def jaccard_similarity(doc1, doc2):
intersection =set(doc1).intersection(set(doc2))
union = set(doc1).union(set(doc2))
return len(intersection)/len(union)
Run Code Online (Sandbox Code Playgroud)
问题是我找不到使用tensorflow作为后端在张量上实现交集和并集函数的方法。
有什么建议吗?
来自pySpark的新手的一个简单问题:我有一个df,我想进行条件聚合,如果分母不同于0则返回聚合结果,否则返回0。
我的尝试产生一个错误:
groupBy=["K"]
exprs=[(sum("A")+(sum("B"))/sum("C") if sum("C")!=0 else 0 ]
grouped_df=new_df.groupby(*groupBy).agg(*exprs)
Run Code Online (Sandbox Code Playgroud)
有什么提示吗?
谢谢
我正在用 Latex 写一篇文章,并为多行表的背景颜色苦苦挣扎。
这是图像。正如你所看到的,右边的最后一列只有一半颜色。我需要它全彩色。
这是我的代码的相应摘录:
\rowcolor{RedFill}
5.88\% &10.6\% & 6.74\% & \multirow{ 2}{*}{ALTA}\\
\rowcolor{RedFill}
9.01\% &14.6\% & 6.09\% \\
Run Code Online (Sandbox Code Playgroud)
我还尝试应用 Stackoverflow 中建议的不同解决方案,但它对我不起作用(我意识到,通过根据我的情况调整解决方案,我可能以错误的方式应用它)
\rowcolor{RedFill}
5.88\% &10.6\% & 6.74\% & \multirow{ 2}{*}{ALTA}\\
\rowcolor{RedFill}
9.01\% &14.6\% & 6.09\% & \rowcolor{RedFill}\\
Run Code Online (Sandbox Code Playgroud)
任何提示?
python ×4
keras ×3
pyspark-sql ×2
dbscan ×1
imputation ×1
latex ×1
mapbox-gl-js ×1
missing-data ×1
pandas ×1
rounding ×1
scikit-learn ×1
tensorflow ×1