Opening unit · Part 2 of 3
Working with Data: Tools, AI, Reliability, and Databases
Choosing tools, understanding what AI can and cannot do, checking whether a pattern is real, and the first steps with databases and SQL.
Choosing tools
Choose tools for the work the information needs to do
Storage and management
Files, databases, or shared storage services hold information, access rules, and documentation.
Retrieval and preparation
SQL (Structured Query Language) and code tools filter, join, correct, and reshape data for analysis.
Analysis and modeling
Statistics, Python, machine learning (methods that learn rules from examples), and specialized tools answer different questions.
Data types
Text, images, networks, and locations may need different representations and methods.
Computing and sharing
A local computer or cloud provides resources; a notebook records steps and helps repeat them.
Communication and decisions
A chart, map, or report presents results to people who need to understand or act.
For a text-processing example, see the Sockpuppet Detection in Hebrew Wikipedia: NLP & Authorship Analysis project (NLP: natural language processing), which combines word patterns, writing-style measures, and Hebrew text similarity to study suspected sockpuppet account pairs.
A selection of tools: not all are taught in this course
| Logo | Tool | What does it do? | Typical use |
|---|---|---|---|
| Python | A programming language for analysis, cleaning, and automation. | Analyze a file and build a process that can be rerun. | |
| NumPy | A Python library for arrays and numerical computing. Its name is short for Numerical Python. | Represent numerical data and calculate across arrays. | |
| pandas | A Python library for working with tabular data. Its name is partly derived from “panel data.” | Read CSV files, clean tables, and calculate summaries. | |
| Dask | A Python library that extends pandas-like workflows with parallel and distributed computing, including data larger than memory. | Partition a large table and process it across multiple cores or a cluster. | |
| Polars | A fast DataFrame library (tables held in memory) for tabular data, with parallel execution, lazy query optimization, and a streaming engine for batch processing. | Transform and summarize larger CSV or Parquet (a compact, column-based file format) files efficiently, processing data in batches when useful. | |
| R | A language and environment for statistics and data visualization. | Explore data and create charts. | |
| Jupyter | A notebook combining code, explanations, and results. The name draws on Julia, Python, and R. | Document an analysis and share it step by step. | |
| SQLite | A relational database (data in linked tables) that is easy to use locally. | Store tables and query them with SQL. | |
| Matplotlib · seaborn · Plotly | Python visualization libraries: Matplotlib is flexible; seaborn builds on it for statistical plots; Plotly creates interactive charts. | Choose based on the chart and the level of interactivity you need. | |
| Grafana | A platform for data visualization and dashboards (screens that gather charts and measures). | Monitor measures and present them to a team. | |
| TensorFlow · PyTorch | Two open-source machine-learning frameworks for building and training models. TensorFlow was originally developed by Google; PyTorch originated at Meta and is now developed under the PyTorch Foundation. | Build and train models from examples; each framework has its own tools and conventions. | |
| Hadoop | A system for distributed work across many computers. | Store and process a large dataset on a computer cluster. | |
| Cassandra | A distributed, non-relational (NoSQL) database for data at very large scale, with a flexible structure. | Serve applications that read and write across many servers. | |
| D3.js | A JavaScript library for interactive browser visualizations. D3 stands for Data-Driven Documents. | Build an interactive chart or map. |
Name origins: NumPy (Numerical Python) · pandas (partly from “panel data”) · Jupyter (Julia, Python, R) · D3 (Data-Driven Documents)
The logos identify tools alongside their names; each trademark belongs to its owner.
Before choosing, ask about data size and speed, structure, access needs, what may be stored in the cloud, run costs, and whether the process can be reproduced. There are many tools; at this stage, understanding their roles matters more than memorizing product names.
Computing and infrastructure
When is a personal computer enough, and when might we use the cloud?
A small file and a practice notebook usually fit on a personal computer. When a team needs shared processes, central storage, or a heavy computation, a server or cloud service may help.
The choice depends on runtime, cost, convenience, privacy, and reproducibility. More computing power does not guarantee a better answer: first check that the question and data justify it.
Data and artificial intelligence (AI)
AI learns from examples, so we need to validate the data and results
An AI system receives input, produces a prediction or recommendation, and is evaluated against examples it did not use for learning. To check whether its results are reliable, we examine data quality, how well the data represent reality, and the system’s performance on new examples.
For instance, we might predict which stations are likely to run short of bicycles. Before using the prediction, check whether it works on new weeks and different stations, and what happens on holidays or during unusual weather.
Data work often happens in a team: a domain expert explains the context, people who collect or maintain data take care of its source and structure, and analysts or data scientists check patterns and explain results. Roles vary across organizations; the common thread is connecting a question, data, and a decision.
Machine learning and deep learning
Deep learning is a family of methods, not a magic fix
Machine learning includes methods that derive rules or predictions from examples. Deep learning is one part of it and uses neural networks with many layers. It can suit images, audio, and text, but often needs many examples, computing resources, and careful evaluation.
Choose for the task
To count trips by station, a simple SQL query may be enough. To identify bicycles in an image, a computer-vision model may fit. Start with the task and the data, not with a fashionable method’s name.
Reliability check
An interesting pattern is not automatically a discovery
Missing measurement
If some stations do not report, “no rides” may mean “no record.” If missing reports cluster at certain stations or times, we may underestimate demand there and make poor decisions about moving bikes between stations.
Related example: NavSight combined camera and motion sensors when GPS (the satellite positioning system) was unavailable or unreliable.
Too many searches
When we test many slices, time windows, and hypotheses, the chance of finding an unusual result by coincidence increases. Even without a real effect, one comparison may look compelling. Define the questions in advance, check the finding on separate data, or account for multiple comparisons.
Underfitting
An overly simple model, missing important variables, too little training, or overly strong constraints can prevent it from capturing the pattern. It performs poorly even on training data.
Overfitting
Two common routes to overfitting are using more variables than the available data can support and training for too long until the model starts fitting noise. The model may fit its training examples well but perform poorly on new ones; a separate validation set helps reveal the gap.
Survivorship bias: In the well-known World War II aircraft example, damage data came from planes that returned. Statistician Abraham Wald’s analysis accounted for aircraft missing from the sample: few recorded hits in an area did not prove it was safe, since planes hit there may have been less likely to return. Before interpreting a pattern, ask who is missing from the data. See Wald’s analysis of aircraft vulnerability.
Before telling a story: check the data source, measurement process, number of comparisons, and whether the result can be repeated. See a visual example in the scikit-learn guide.
Reliability includes ethical responsibility
Even a statistically sound result can cause harm if it violates privacy, reflects underrepresentation, or informs a decision with no explanation or way to appeal. Minimize sensitive data, check who is missing, state limitations, and keep human oversight for consequential decisions.
Structured data and databases
A useful table starts with a clear definition of each row and column
In structured data, a row represents an observation and a column describes an attribute. A unique identifier distinguishes records; a shared key can connect tables. For example, a trips table can store station IDs, while a stations table stores station names and locations. A database whose tables are connected in this way is called a relational database, and the operation that combines the rows of two tables by matching their keys is called a JOIN (the practical SQL guide, part 2, teaches it).
A database management system (DBMS) stores tables and lets us retrieve, filter, change, and connect them. Databases work especially well for tabular information and questions over recurring subsets. No single size threshold decides: the computation, structure, update rate, and infrastructure also matter.
SQL is a language for working with information in databases. Most of the time, we describe what result we want or what information to change, and the database system determines how to do the work. It helps to distinguish command families from individual commands or clauses used inside a query.
SQL command families
DDL: define structure
(Data Definition Language). Commands such as CREATE TABLE and ALTER TABLE create tables and change their structure.
DML: change data
(Data Manipulation Language). Commands such as INSERT, UPDATE, and DELETE add, change, or remove rows.
DQL: retrieve data
(Data Query Language). SELECT requests data without changing it. Some sources include it under DML; here we separate it to make its role clear.
In the practical SQL guide, we use SQLite and helper tools such as DB Browser or Python’s sqlite3 library. SQLite is useful for local practice; syntax and features vary across database systems.
From CSV to a query
Import is the beginning of checking, not the end
A CSV (comma-separated values) file is a table written as text, one row on each line; the lesson on values, variables and collections in Python shows what one looks like.
- Inspect column names, value types, text encoding (how characters are stored, for example UTF-8), and date format.
- Count rows, missing values, and unique identifiers; look for duplicates and unusual values.
- Ask a question that the available fields can answer.
- Compare the result with a simple check or a small sample before drawing a conclusion.
Practice can start with basic questions: How many records are there? How many distinct stations appear? Which station has the most departures? Next, connect tables and see whether the answer changes by day or hour. The practical SQL guide develops these operations with complete examples and common mistakes: part 1 for retrieving and counting, part 2 for combining tables.
Key points
- Choose tools for the work the information needs to do. At this stage the roles of the tools matter more than their names.
- An AI system produces estimates, not facts. Validate it on new cases before relying on it.
- An interesting pattern is not automatically a discovery: check for missing measurements, many comparisons, overfitting and underfitting, and who is missing from the data.
- Reliability includes ethical responsibility: privacy, representation, explanation, and human oversight of consequential decisions.
- A useful table starts with a clear definition of a row and a column; a shared key connects tables.
Check yourself
A model fits its training data almost perfectly but does poorly on next week’s data. What is this called, and how can you catch it earlier?
Show a possible answer
This is the typical sign of overfitting: the model matches the training data more closely than the real pattern. Keep a validation set that the model never learned from and compare the results on both. A drop on the new week can also come from a change in the world, such as a holiday or a season, so check what differs between the weeks before you decide.
You tested 200 time windows and one of them looks unusual. Why be careful?
Show a possible answer
With many comparisons, something will look unusual by coincidence. Define the questions in advance, check on separate data, or account for the number of tests.
Two tables, trips and stations, both contain a station ID. What can you do with it, and what can go wrong?
Show a possible answer
Use it as a shared key to join the tables. If the key does not match properly, rows can be lost or multiplied.