Skip to Content
Java数据科学实战
book

Java数据科学实战

by Michael R. Brzustowicz, PhD
January 2020
Intermediate to advanced
202 pages
5h 41m
Chinese
Posts & Telecom Press
Content preview from Java数据科学实战
2
|
第
1
章
单得多的分析工具就足以得到所需的输出。
本章将探究从各种数据源读取数据以及写入数据的具体细节。重要的是,需要问自己:对
于后续每个步骤,需要什么样的数据模型?也许,为了容纳这些数据,建立一系列的数值
数组类型(例如
double[][]
、
int[]
、
String[]
)就足够了。这样做可能是有益处的:创建
容器类以保存每条数据记录,然后把这些对象添加到
List
或
Map
中。还有另外一种有用的
数据模型,即在
JavaScript
对象表示法(
JSON
)文档中,把每条记录都表示为键
–
值对的
集合。具体应该采用哪种数据模型,很大程度上取决于后续数据消费过程的输入需求。
1.2
 数据模型
数据采用哪种形式,需要转换成什么形式,才能继续往下进行?假设文件
somefile.txt
包含
数行数据,每一行都有
id
、
year
以及
city
数据。
1.2.1
 一维数组
对于这个示例而言,最简单的数据模型是为
id
、
year
以及
city
这
3
个变量创建一系列的
数组:
int
[] id =
new int
[1024];
int
[] year =
new int
[1024];
String[] city =
new
String[1024];
由于
BufferedReader
循环遍历该文件的每一行,因此借助于增量计数器,可以把变量的值
放置到各个数组的相应位置中。对于已知维度的洁净数据,这种数据模型可能就足够了,
此时所有代码都放入同一个可执行类中。可以直接把这个数据提供给任何数量的统计分析
算法或者学习算法。然而,有时可能需要将代码模块化 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

云安全实用指南

云安全实用指南

Chris Dotson
Kafka权威指南

Kafka权威指南

Neha Narkhede, Gwen Shapira, Todd Palino

Publisher Resources

ISBN: 9787115533302