我想从Python脚本中获取当前目录的父级.例如,我/home/kristina/desire-directory/scripts在这种情况下从欲望路径启动脚本/home/kristina/desire-directory
我知道sys.path[0]从sys.但我不想解析sys.path[0]结果字符串.有没有其他方法可以在Python中获取当前目录的父级?
我有一个pandas DataFrame,里面有很多NAN值.
我怎样才能删除这样的列number_of_na_values > 2000?
我试着这样做:
toRemove = set()
naNumbersPerColumn = df.isnull().sum()
for i in naNumbersPerColumn.index:
if(naNumbersPerColumn[i]>2000):
toRemove.add(i)
for i in toRemove:
df.drop(i, axis=1, inplace=True)
Run Code Online (Sandbox Code Playgroud)
有更优雅的方式吗?
我正在尝试使用cforest功能(R,派对包).
这就是我建造森林的方法:
library("party")
set.seed(42)
readingSkills.cf <- cforest(score ~ ., data = readingSkills,
control = cforest_unbiased(mtry = 2, ntree = 50))
Run Code Online (Sandbox Code Playgroud)
然后我想打印第一棵树然后我做了
party:::prettytree(readingSkills.cf@ensemble[[1]],names(readingSkills.cf@data@get("input")))
Run Code Online (Sandbox Code Playgroud)
结果看起来像这样
1) shoeSize <= 28.29018; criterion = 1, statistic = 89.711
2) age <= 6; criterion = 1, statistic = 48.324
3) age <= 5; criterion = 0.997, statistic = 8.917
4)* weights = 0
3) age > 5
5)* weights = 0
2) age > 6
6) age <= 7; criterion = 1, statistic = 13.387
7) …Run Code Online (Sandbox Code Playgroud) 我想h2o.kmeans从h2o包中使用函数.这是我的代码
clust <- h2o.kmeans(data = waterM, centers = 30, key = "kmeansKey", iter.max = 1000, normalize = T, init = "none", dropNACols = F );
summary(clust@model);
Run Code Online (Sandbox Code Playgroud)
输出是
Length Class Mode
params 6 -none- list
centers 25560 -none- numeric
withinss 30 -none- numeric
tot.withinss 1 -none- numeric
size 30 -none- numeric
iter 1 -none- numeric
Run Code Online (Sandbox Code Playgroud)
为什么没有cluster包含整数向量的对象(从1:k),它表示每个点被分配到的簇?