有人可以让我知道如何使用 databricks dbutils 删除文件夹中的所有文件。我已尝试以下操作,但不幸的是,Databricks 不支持通配符。
dbutils.fs.rm('adl://azurelake.azuredatalakestore.net/landing/stageone/*')
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一个功能集与相应的categoricalFeaturesInfo:Map [Int,Int].然而,对于我的生活,我无法弄清楚我应该如何使DecisionTree类工作.它不会接受任何内容,而是LabeledPoint作为数据.但是,LabeledPoint需要(double,vector),其中向量需要双精度数.
val LP = featureSet.map(x => LabeledPoint(classMap(x(0)),Vectors.dense(x.tail)))
// Run training algorithm to build the model
val maxDepth: Int = 3
val isMulticlassWithCategoricalFeatures: Boolean = true
val numClassesForClassification: Int = countPossibilities(labelCol)
val model = DecisionTree.train(LP, Classification, Gini, isMulticlassWithCategoricalFeatures, maxDepth, numClassesForClassification,categoricalFeaturesInfo)
Run Code Online (Sandbox Code Playgroud)
我得到的错误:
scala> val LP = featureSet.map(x => LabeledPoint(classMap(x(0)),Vectors.dense(x.tail)))
<console>:32: error: overloaded method value dense with alternatives:
(values: Array[Double])org.apache.spark.mllib.linalg.Vector <and>
(firstValue: Double,otherValues: Double*)org.apache.spark.mllib.linalg.Vector
cannot be applied to (Array[String])
val LP = featureSet.map(x => LabeledPoint(classMap(x(0)),Vectors.dense(x.tail)))
Run Code Online (Sandbox Code Playgroud)
我有一个shiny
使用plotly
和渲染的情节ggplot2
.但是,我不希望显示悬停时出现的选项栏.有没有办法使用ggplotly(p)
和删除选项栏?
当我尝试运行以下命令时:
R --slave --no-save --no-restore -e "print('foo')"
我明白了:
/usr/local/bin/R: line 193: /usr/local/Library/ENV/4.3/sed: No such file or directory
ERROR: option '-e' requires a non-empty argument
显然brew
最近将ENV
文件夹移动到了新路径(请参阅此处).我知道我可以轻松地对新的sed目录进行符号链接以修复问题,但我想知道是否有更好的解决方法/修复(最终如果这将在R源代码中修复).
该文件为随机森林不包括功能重要性有关.但是,它在Jira上列为已解决并且在源代码中.HERE还说"这个API和原始MLlib合奏API之间的主要区别是:
但是,我无法找出可以调用此新功能的语法.
scala> model
res13: org.apache.spark.mllib.tree.model.RandomForestModel =
TreeEnsembleModel classifier with 10 trees
scala> model.featureImportances
<console>:60: error: value featureImportances is not a member of org.apache.spark.mllib.tree.model.RandomForestModel
model.featureImportances
Run Code Online (Sandbox Code Playgroud) 我有一个以RowMatrix形式的X分布式矩阵.我使用的是Spark 1.3.0.我需要能够计算X逆.
在Python中,我就是这样做的.
>>> x
array([10, 9, 8, 7, 6, 5, 4, 3, 2])
>>> x[np.array([3, 3, 1, 8])]
array([7, 7, 9, 2])
Run Code Online (Sandbox Code Playgroud)
这在Scala Spark shell中不起作用:
scala> val indices = Array(3,2,0)
indices: Array[Int] = Array(3, 2, 0)
scala> val A = Array(10,11,12,13,14,15)
A: Array[Int] = Array(10, 11, 12, 13, 14, 15)
scala> A(indices)
<console>:28: error: type mismatch;
found : Array[Int]
required: Int
A(indices)
Run Code Online (Sandbox Code Playgroud)
foreach方法也不起作用:
scala> indices.foreach(println(_))
3
2
0
scala> indices.foreach(A(_))
<no output>
Run Code Online (Sandbox Code Playgroud)
我想要的是B的结果:
scala> val B = Array(A(3),A(2),A(0))
B: Array[Int] = …
Run Code Online (Sandbox Code Playgroud) 我真的想将我的org.apache.spark.mllib.linalg.Matrix转换为org.apache.spark.mllib.linalg.distributed.RowMatrix
我可以这样做:
val xx = X.computeGramianMatrix() //xx is type org.apache.spark.mllib.linalg.Matrix
val xxs = xx.toString()
val xxr = xxs.split("\n").map(row => row.replace(" "," ").replace(" "," ").replace(" "," ").replace(" "," ").replace(" ",",").split(","))
val xxp = sc.parallelize(xxr)
val xxd = xxp.map(ar => Vectors.dense(ar.map(elm => elm.toDouble)))
val xxrm: RowMatrix = new RowMatrix(xxd)
Run Code Online (Sandbox Code Playgroud)
然而,这真的很糟糕,而且完全是黑客攻击.有人能告诉我一个更好的方法吗?
注意我使用的是Spark 1.3.0版
我在正在使用的计算机上使用Jython的较旧版本(2.2.1),但我需要排序的方法。我已经从未来导入了发电机,但是
from __future__ import sorted
Run Code Online (Sandbox Code Playgroud)
返回SyntaxError:未定义将来的功能。有可以导入的模块吗?
我目前通过Apache Superset中的德鲁伊连接器连接到德鲁伊集群.我听说SQL可以用来查询德鲁伊.是否有可能将我的SQL数据库连接指向德鲁伊?
安装成功。我在尝试导入时收到此错误。
TypeError: 'numpy._DTypeMeta' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)
我尝试过更高和更低版本的 numpy (1.22.0,1.23.0,1.24.0,1.25.0,1.25.2)。我通过 pypi 安装了 mediapipe 以及 mediapipe-0.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
从pypi下载的 whl ( )
版本
numpy 1.21.5
mediapipe 0.10.3
Python 3.10.6
Run Code Online (Sandbox Code Playgroud)
这些问题相似但没有答案。
我使用的是Spark 1.3.0.
我的地图说它有密钥,但是在访问密钥时我找不到密钥或没有密钥.
import scala.collection.mutable.HashMap
val labeldata = sc.textFile("/home/data/trainLabels2.csv")
val labels: Array[Array[String]] = labeldata.map(line => line.split(",")).collect()
var fn2label: HashMap[String,Int] = new HashMap()
labels.foreach{ x => fn2label += (x(0) -> x(1).toInt)}
Run Code Online (Sandbox Code Playgroud)
我的地图看起来像:
scala> fn2label
res45: scala.collection.mutable.HashMap[String,Int] = Map("k2VDmKNaUlXtnMhsuCic" -> 1, "AGzOvc4dUfw1B8nDmY2X" -> 1, "BqRPMt4QY1sHzvF6JK7j" -> 3,.....
Run Code Online (Sandbox Code Playgroud)
它甚至有钥匙:
scala> fn2label.keys
res46: Iterable[String] = Set("k2VDmKNaUlXtnMhsuCic", "AGzOvc4dUfw1B8nDmY2X", "BqRPMt4QY1sHzvF6JK7j",
Run Code Online (Sandbox Code Playgroud)
但我无法访问它们:
scala> fn2label.get("k2VDmKNaUlXtnMhsuCic")
res48: Option[Int] = None
scala> fn2label("k2VDmKNaUlXtnMhsuCic")
java.util.NoSuchElementException: key not found: k2VDmKNaUlXtnMhsuCic
Run Code Online (Sandbox Code Playgroud)
我所尝试的包括广播地图,广播标签和地图,地图而不是HashMap,并行化,如/sf/answers/1731408731/所述
val mapRdd = sc.parallelize(fn2label.toSeq)
mapRdd.lookup("k2VDmKNaUlXtnMhsuCic")
res50: Seq[Int] = WrappedArray()
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
apache-spark ×6
scala ×6
python ×2
r ×2
arrays ×1
databricks ×1
dbutils ×1
dictionary ×1
distributed ×1
druid ×1
ggplot2 ×1
homebrew ×1
jython ×1
matrix ×1
mediapipe ×1
numpy ×1
plotly ×1
python-3.x ×1
sed ×1
shiny ×1
sorted ×1
sql ×1
tree ×1
typeerror ×1