- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 50288 个
- 通用积分
- 83.6306
- 学术水平
- 253 点
- 热心指数
- 300 点
- 信用等级
- 208 点
- 经验
- 41518 点
- 帖子
- 3256
- 精华
- 14
- 在线时间
- 766 小时
- 注册时间
- 2006-5-4
- 最后登录
- 2022-11-6
已卖:4194份资源
院士
还不是VIP/贵宾
TA的文库 其他... Bayesian NewOccidental
Spatial Data Analysis
东西方数据挖掘
- 威望
- 0 级
- 论坛币
 - 50288 个
- 通用积分
- 83.6306
- 学术水平
- 253 点
- 热心指数
- 300 点
- 信用等级
- 208 点
- 经验
- 41518 点
- 帖子
- 3256
- 精华
- 14
- 在线时间
- 766 小时
- 注册时间
- 2006-5-4
- 最后登录
- 2022-11-6
|
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
Python
- points = spark.textFile(...).map(parsePoint).cache()
- w = numpy.random.ranf(size = D) # current separating plane
- for i in range(ITERATIONS):
- gradient = points.map(
- lambda p: (1 / (1 + exp(-p.y*(w.dot(p.x)))) - 1) * p.y * p.x
- ).reduce(lambda a, b: a + b)
- w -= gradient
- print "Final separating plane: %s" % w
复制代码Scala
- val points = spark.textFile(...).map(parsePoint).cache()
- var w = Vector.random(D) // current separating plane
- for (i <- 1 to ITERATIONS) {
- val gradient = points.map(p =>
- (1 / (1 + exp(-p.y*(w dot p.x))) - 1) * p.y * p.x
- ).reduce(_ + _)
- w -= gradient
- }
- println("Final separating plane: " + w)
复制代码Java
- class ComputeGradient extends Function<DataPoint, Vector> {
- private Vector w;
- ComputeGradient(Vector w) { this.w = w; }
- public Vector call(DataPoint p) {
- return p.x.times(p.y * (1 / (1 + Math.exp(w.dot(p.x))) - 1));
- }
- }
- JavaRDD<DataPoint> points = spark.textFile(...).map(new ParsePoint()).cache();
- Vector w = Vector.random(D); // current separating plane
- for (int i = 0; i < ITERATIONS; i++) {
- Vector gradient = points.map(new ComputeGradient(w)).reduce(new AddVectors());
- w = w.subtract(gradient);
- }
- System.out.println("Final separating plane: " + w);
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|
|
|