资源简介
深入理解大数据:大数据处理与编程实践 书中所有代码

代码片段和文件信息
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.Writable;
/*
* k-means聚类算法簇信息
*/
public class Cluster implements Writable{
private int clusterID;
private long numOfPoints;
private Instance center;
public Cluster(){
this.setClusterID(-1);
this.setNumOfPoints(0);
this.setCenter(new Instance());
}
public Cluster(int clusterIDInstance center){
this.setClusterID(clusterID);
this.setNumOfPoints(0);
this.setCenter(center);
}
public Cluster(String line){
String[] value = line.split(““3);
clusterID = Integer.parseInt(value[0]);
numOfPoints = Long.parseLong(value[1]);
center = new Instance(value[2]);
}
public String toString(){
String result = String.valueOf(clusterID) + ““
+ String.valueOf(numOfPoints) + ““ + center.toString();
return result;
}
public int getClusterID() {
return clusterID;
}
public void setClusterID(int clusterID) {
this.clusterID = clusterID;
}
public long getNumOfPoints() {
return numOfPoints;
}
public void setNumOfPoints(long numOfPoints) {
this.numOfPoints = numOfPoints;
}
public Instance getCenter() {
return center;
}
public void setCenter(Instance center) {
this.center = center;
}
public void observeInstance(Instance instance){
try {
Instance sum = center.multiply(numOfPoints).add(instance);
numOfPoints++;
center = sum.divide(numOfPoints);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void write(DataOutput out) throws IOException {
// TODO Auto-generated method stub
out.writeInt(clusterID);
out.writeLong(numOfPoints);
center.write(out);
}
@Override
public void readFields(DataInput in) throws IOException {
// TODO Auto-generated method stub
clusterID = in.readInt();
numOfPoints = in.readLong();
center.readFields(in);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-09-18 19:15 Chapter 10\
目录 0 2014-09-18 19:11 Chapter 10\CH 10.1 - KMeans\
文件 388 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\Instance.txt
文件 380 2014-08-31 11:00 Chapter 10\CH 10.1 - KMeans\README.md
目录 0 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\
文件 2010 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\Cluster.java
文件 2663 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\Instance.java
目录 0 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\king\
目录 0 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\king\Utils\
文件 144 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\king\Utils\Distance.java
文件 526 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\king\Utils\EuclideanDistance.java
文件 467 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\king\Utils\HammingDistance.java
文件 878 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\king\Utils\InstanceGenerator.java
文件 1365 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\king\Utils\ListWritable.java
文件 4640 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\KMeans.java
文件 2862 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\KMeansCluster.java
文件 3632 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\KMeansDriver.java
文件 3779 2014-07-31 20:49 Chapter 10\CH 10.1 - KMeans\src\RandomClusterGenerator.java
目录 0 2014-09-18 19:11 Chapter 10\CH 10.2 - KNearestNeighbour\
文件 716 2014-08-31 11:15 Chapter 10\CH 10.2 - KNearestNeighbour\README.md
目录 0 2014-07-31 20:50 Chapter 10\CH 10.2 - KNearestNeighbour\src\
文件 636 2014-07-31 20:50 Chapter 10\CH 10.2 - KNearestNeighbour\src\Instance.java
目录 0 2014-07-31 20:50 Chapter 10\CH 10.2 - KNearestNeighbour\src\king\
目录 0 2014-07-31 20:50 Chapter 10\CH 10.2 - KNearestNeighbour\src\king\Utils\
文件 353 2014-07-31 20:50 Chapter 10\CH 10.2 - KNearestNeighbour\src\king\Utils\Distance.java
文件 1884 2014-07-31 20:50 Chapter 10\CH 10.2 - KNearestNeighbour\src\king\Utils\ListWritable.java
文件 7048 2014-07-31 20:50 Chapter 10\CH 10.2 - KNearestNeighbour\src\KNearestNeighbour.java
文件 119 2014-07-31 20:50 Chapter 10\CH 10.2 - KNearestNeighbour\src\train.txt
目录 0 2014-09-18 19:13 Chapter 10\CH 10.3 - NaiveBayes\
文件 8375 2014-08-02 18:12 Chapter 10\CH 10.3 - NaiveBayes\ReadMe-NaiveBayes.html
文件 54827 2014-08-02 18:18 Chapter 10\CH 10.3 - NaiveBayes\ReadMe-NaiveBayes.pdf
............此处省略98个文件信息
- 上一篇:软件deap2.1
- 下一篇:GY-82 GY-302资料
相关资源
- 随机森林R语言代码
- 计算机图形学 边填充算法实现代码
- 直流无刷电机方波驱动 stm32 例程代码
- 仿知乎界面小程序源代码
- 贪吃蛇源代码.fla
- 周立功开发板ProASIC3实验-syn_FIFO代码
- IMX385驱动代码.zip
- dotnet 写字板 实验 源代码 不好请要不
- 图像二维小波变换的实现源代码
- 八三编码器设计 VHDL代码 简单,包附
- linux应用层的华容道游戏源代码
- 交通咨询模拟系统完整代码
- http请求状态代码
- 数值分析所有实验代码
- 网上拍卖系统完整源代码
- 音乐代码转换软件 单片机编程时用
- CSMA/CD等动画演示加源代码
- silicon lab公司的收音IC SI47XX全套开发工
- 用51单片机实现G代码翻译
- 合同管理系统的源代码(附数据库)
- 用VC 编写的仿QQ聊天室程序源代码
- web班级网站设计代码
- 38k单片机红外发送代码、keil
- STM32F103 串口程序(完整版)
- 网络唤醒代码
- VPC3_DPV1源代码,Profibus
- PB做的托盘程序(最小化后在左下角显
- RSA算法源码
- ubuntu9.10 可加载内核模块和字符设备驱
- 操作系统 LRU算法 实验报告 及 程序代
评论
共有 条评论