Professional Python project: linear regression and predictive analytics.
This project introduces linear regression, the process of fitting a model to data and using it to make predictions.
Think about two variables that might be related:
- Does study time predict exam scores?
- Does temperature predict energy usage?
- Does advertising spend predict revenue?
Your goal: run the example, read the code, and apply the same approach to a dataset and question of your own choosing.
For data suggestions, please see data/raw/README.md.
OBSERVE
DECLARE
PREPARE
SPLIT
BASELINE
TRAIN
PREDICT
EVALUATE
VISUALIZE
ASSESS
Example:
TRAIN LinearRegression
PREDICT on X_test
EVALUATE baseline vs model on y_test
- data/raw - raw data
- docs/ - project narrative and documentation\
- src/datafun - supporting Python code
- pyproject.toml - project configuration
- zensical.toml - documentation configuration
Follow the step-by-step workflow guide carefully.
After completing Phase 1. Start & Run, you'll have the example project,
running on your machine.
A new file project.log will appear in the root project folder
and running the example script will print out:
===================================
END main() - Executed successfully!
===================================The commands below are used in the workflow guide above. They are provided here for convenience.
Follow the guide for the full instructions.
Show command reference
Open a machine terminal in your Repos folder:
git clone https://github.com/denisecase/datafun-06-ml
cd datafun-06-ml
code .These are listed for convenience. For best results, follow the detailed instructions in pro-analytics-02 guide.
Use VS Code menu option Terminal / New Terminal to open a VS Code terminal
in the root project folder.
Copy each command, paste into your terminal, and hit ENTER,
to run each command one at a time.
uv self update
uv python pin 3.14
uv python install
uv lock --upgrade
uv sync
uv run pre-commit install
uv run pre-commit autoupdate
git add -A
uv run pre-commit run --all-files
# repeat if changes were made by pre-commit tasks
git add -A
uv run pre-commit run --all-files
# run the penguin example: is there a linear relationship?
uv run python -m datafun.app
# do chores
uv run ruff format .
uv run ruff check . --fix
uv run ty check
uv run python -m pytest
uv run python -m zensical build
# save progress as you work
git add -A
git commit -m "your message here"
# repeat if changes were made (try the UP ARROW)
git add -A
git commit -m "your message here"
git push -u origin main- Use the UP ARROW and DOWN ARROW in the terminal to scroll through past commands.
- Use
CTRL+fto find (and replace) text within a file.
- You do not need to add to or modify
tests/. Tests are recommended and provided for example only. - Many files are silent helpers. Explore as you like, but most files are never touched.
- You do NOT need to understand everything; let understanding build over time.
If VS Code does not automatically use the new .venv environment:
- Open the Command Palette (
Ctrl+Shift+P). - Run Python: Select Interpreter.
- Select the interpreter from this project's
.venvfolder.
If VS Code still does not recognize the environment or newly installed tools:
- Open the Command Palette (
Ctrl+Shift+P). - Run Developer: Reload Window.
If you see something like this in your terminal: >>> or ...
You accidentally started Python interactive mode.
It happens.
Press Ctrl c (both keys together) or Ctrl+Z then Enter on Windows.
This project is licensed under the MIT License.