我正在尝试使用Spark Scala Maven项目实现隔离森林算法。它在这个链接上进行了解释:iforest example。
我的问题是:当我尝试实现建议的代码时,我收集了这个错误:object iforest is not a member of package org.apache.spark.ml
,我尝试import org.apache.spark.ml
,并将Spark-core依赖项也更改为Vesrion2.2.0。
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.0</version>
</dependency>
有什么建议吗?
发布于 2019-08-17 16:20:58
您可以尝试this Spark/Scala implementation of the isolation forest algorithm,它在公共JCenter存储库中提供了工件。
您可以在您的Maven配置中指定JCenter存储库,方法是定义~/.m2/settings.xml,如下所示(按照"SET ME UP!“按钮here):
<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>https://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<id>bintray</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>bintray</activeProfile>
</activeProfiles>
</settings>
然后,您可以在项目的pom.xml中将依赖项声明为:
<dependency>
<groupId>com.linkedin.isolation-forest</groupId>
<artifactId>isolation-forest_2.11</artifactId>
<version>0.3.0</version>
</dependency>
发布于 2018-06-19 03:30:55
这个spark-iforest
工件没有包含在官方发行版中,也没有出现在任何集中的工件发行版资源中,所以要使用它,您需要自己构建它,或者作为一个单独的库,或者在您的项目中。
这个库一开始不应该使用外部源的包名,因为它提供了一个错误的提议,即它在Spark本身中是可用的。
https://stackoverflow.com/questions/50916005
复制相似问题