我正在运行 jupyter 笔记本,但未显示 jupyter 小部件。相反,我收到以下消息:
Failed to display Jupyter Widget of type Button.
If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.
If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it …Run Code Online (Sandbox Code Playgroud) import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(
go.Scatter(
x = [df['x'], df['x1']],
y = df['y'],
mode='markers'
)
)
Run Code Online (Sandbox Code Playgroud)
到目前为止,我可以使用下一个代码独立制作每个图形:
import plotly.express as px
fig = px.strip(df,
x=[df["x"], df['x1']],
y="y",
stripmode='overlay')
Run Code Online (Sandbox Code Playgroud)
是否可以将抖动和多级轴组合在一个图中?
这是重现数据集的代码:
import numpy as np
import pandas as pd
import random
'''Create DataFrame'''
price = np.append(
np.random.normal(20, 5, size=(1, 50)), np.random.normal(40, 2, size=(1, 10))
)
quantity = np.append(
np.random.randint(1, 5, size=(50)), np.random.randint(8, 12, size=(10))
)
firstLayerList = ['15 in', '16 in']
secondLayerList …Run Code Online (Sandbox Code Playgroud) 在训练模型后,我尝试使用scikit获取混淆矩阵,但是由于使用flow_from_directory,我无法访问数据和标签,或者我不知道这样做的方法。由于scikit混淆矩阵方法的用法如下:
confusion_matrix(y_true, y_pred)
Run Code Online (Sandbox Code Playgroud)
并且flow_from_directory不返回真实标签。有没有办法flow_from_directory直接或其他任何方式获取它们?
我有一个包含三列的数据框
| 一个 | 乙 | C |
我计算了分位数:
df.quantile(.25)
df.quantile(.75)
Run Code Online (Sandbox Code Playgroud)
我想根据一个简单的规则添加一个新的列Q分类使用'small', 'medium', 'large'。如果值小于 1 个四分位数,则很小;如果它大于 3 个四分位数,那么大,中间的所有东西都是中等的。
我试过使用 qcut 但它只接收一维输入。
谢谢
我正在使用 scikit 管道在数据集上创建预处理。我有一个包含四个变量的数据集:['monetary', 'frequency1', 'frequency2', 'recency']我想预处理除recency. 要预处理,我首先要获取日志,然后进行标准化。但是,当我从管道中获取转换后的数据时,会得到 7 列(3 个日志、3 个标准化、新近度)。有没有办法链接转换,这样我就可以获得日志,并且在日志执行标准化后只能获得 4 个特征数据集?
def create_pipeline(df):
all_but_recency = ['monetary', 'frequency1','frequency2']
# Preprocess
preprocessor = ColumnTransformer(
transformers=[
( 'log', FunctionTransformer(np.log), all_but_recency ),
( 'standardize', preprocessing.StandardScaler(), all_but_recency ) ],
remainder='passthrough')
# Pipeline
estimators = [( 'preprocess', preprocessor )]
pipe = Pipeline(steps=estimators)
print(pipe.set_params().fit_transform(df).shape)
Run Code Online (Sandbox Code Playgroud)
提前致谢
python ×4
dataframe ×1
graph ×1
jitter ×1
jupyter ×1
keras ×1
pandas ×1
pipeline ×1
plotly ×1
quantile ×1
scatter-plot ×1
scikit-learn ×1
tensorflow ×1
widget ×1