Wed Jan 03 2024
California Housing Data
Data Visualization
Python
Folium
Matplotlib
A project that visualizes California housing data using Folium and Matplotlib.
Overview
This project visualizes the California housing dataset using Python libraries such as Folium and Matplotlib. The visualization includes interactive map markers representing various housing attributes across different locations in California.
Code Explanation
Importing Libraries
We start by importing the necessary libraries:
Pandas: for handling data manipulation and analysis. Matplotlib and Matplotlib.colors: for creating visualizations and managing color mappings. Scikit-learn: to fetch the California housing dataset. Folium: to create interactive maps.
Fetching and Preparing Data
We use fetch_california_housing from Scikit-learn to load the dataset into a Pandas DataFrame.
Creating the Map
A Folium map is initialized centered on the mean latitude and longitude of the data points.
Adding markers
We iterate over the data to add circle markers to the map, representing different housing attributes. The marker color and size are dynamically calculated based on the median house value and average number of rooms.
Adding a miniMap and Saving
The map is saved to an HTML file, which can be viewed in any web browser.