我正在尝试使用 python 中的seaborn 创建一个多面图,但我遇到了很多问题,其中一件事是旋转 x 轴标签。
我目前正在尝试使用以下代码:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
vin = pd.Series(["W1","W1","W2","W2","W1","W3","W4"])
word1 = pd.Series(['pdi','pdi','tread','adjust','fill','pdi','fill'])
word2 = pd.Series(['perform','perform','fill','measure','tire','check','tire'])
date = pd.Series(["01-07-2020","01-07-2020","01-07-2020","01-07-2020","01-08-2020","01-08-2020","01-08-2020"])
bigram_with_dates = pd.concat([vin,word1,word2,date], axis = 1)
names = ["vin", "word1","word2","date"]
bigram_with_dates.columns = names
bigram_with_dates['date'] = pd.to_datetime(bigram_with_dates['date'])
bigram_with_dates['text_concat'] = bigram_with_dates['word1'] + "," + bigram_with_dates['word2']
plot_params = sns.FacetGrid(bigram_with_dates, col="date", height=3, aspect=.5, col_wrap = 10,sharex = False, sharey = False)
plot = plot_params.map(sns.countplot, 'text_concat', color = 'c', order = bigram_with_dates['text_concat'])
plot_adjust = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 ggplot2 中的 labeller 函数来标记多面图。当我运行我的代码时,我没有收到任何错误或警告(我知道这并不总是意味着一切都像我想的那样工作),但是我没有将预定义的标签应用于绘图,而是得到“NA”作为情节标签。我的数据的一个小子样本是:
w <- structure(list(Var1 = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L), .Label = c("0", "1"), class = "factor"), Var2 = structure(c(1L,
1L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c("0", "1"), class = "factor"),
Freq = c(9L, 18L, 7L, 12L, 11L, 12L, 15L, 7L), Index = c(1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L), ComboCode = c("00", "10", "01",
"11", "00", "10", "01", "11"), Var1Name = c("hibernate",
"hibernate", "hibernate", "hibernate", "migrate", "migrate",
"migrate", …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 R 中的包“iml”从 H2O 中创建的 GBM 模型创建 SHAP 值图。
当我尝试使用该函数创建 R6 Predictor 对象时,Predictor.new()我收到一条错误,指出Error : all(feature.class %in% names(feature.types)) is not TRUE。
由此,我猜测其中一个要素类存在某些不正确的内容,但这只是基于错误消息字面意思的有根据的猜测。
这是匿名数据的示例(我无法共享真实数据,因为它是机密的):
structure(list(dlr_id_cur = c(1, 2), date_eff = structure(c(16014,
15416), class = "Date"), new_vec_ind = structure(c(1L, 1L), .Label = c("NNA",
"UNA"), class = "factor"), cntrct_term = c(9587879614862828,
19), amt_financed = c(9455359, 65561175), reg_payment = c(885288,
389371), acct_stat_cd = structure(c(3L, 3L), .Label = c("11",
"22", "33"), class = "factor"), base_rental = c(1, 626266), down_pymt = c(2,
6654661), …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 R 获取数据帧中某个字符串的分组计数,但到目前为止还没有提出解决方案。这是我尝试使用的一些示例数据和代码,以便您了解我要完成的任务,以及下面的进一步说明:
simpson <- structure(list(season = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, …Run Code Online (Sandbox Code Playgroud) r ×3
databricks ×1
dplyr ×1
facet-wrap ×1
gbm ×1
ggplot2 ×1
group-by ×1
h2o ×1
iml ×1
matplotlib ×1
plot ×1
python ×1
seaborn ×1