renoir.analyzer¶
Artist analysis module for renoir.
This module provides functions for extracting and analyzing artist-specific works from the WikiArt dataset, designed for educational use in computational design and digital humanities courses.
- class renoir.analyzer.ArtistAnalyzer(cache_dir=None)[source]¶
Bases:
objectAnalyze artist-specific works from the WikiArt dataset.
This class provides methods to extract works by specific artists and analyze their metadata (genres, styles, periods). Designed for teaching data analysis to art and design students.
Examples
>>> analyzer = ArtistAnalyzer() >>> works = analyzer.extract_artist_works('claude-monet') >>> print(f"Found {len(works)} works by Monet") >>> genres = analyzer.analyze_genres(works) >>> print(f"Main genre: {genres[0]}")
- extract_artist_works(artist_name, limit=None)[source]¶
Extract all works by a specific artist from WikiArt.
- Parameters:
artist_name (
str) – Artist name as it appears in WikiArt (e.g., ‘claude-monet’)limit (
Optional[int]) – Optional maximum number of works to return
- Return type:
List[Dict[str,Any]]- Returns:
List of dictionaries containing artwork data (image, metadata)
- Raises:
ValueError – If artist_name is empty or invalid
ValueError – If limit is negative
Examples
>>> analyzer = ArtistAnalyzer() >>> monet_works = analyzer.extract_artist_works('claude-monet', limit=10) >>> print(monet_works[0].keys()) dict_keys(['image', 'artist', 'title', 'style', 'genre', 'date'])
- analyze_genres(works)[source]¶
Analyze genre distribution in a collection of works.
- Parameters:
works (
List[Dict[str,Any]]) – List of artwork dictionaries- Return type:
List[tuple]- Returns:
List of (genre, count) tuples, sorted by frequency
- Raises:
ValueError – If works is not a list
TypeError – If works contains non-dict elements
Examples
>>> works = analyzer.extract_artist_works('claude-monet') >>> genres = analyzer.analyze_genres(works) >>> print(f"Most common genre: {genres[0][0]} ({genres[0][1]} works)")
- analyze_styles(works)[source]¶
Analyze style distribution in a collection of works.
- Parameters:
works (
List[Dict[str,Any]]) – List of artwork dictionaries- Return type:
List[tuple]- Returns:
List of (style, count) tuples, sorted by frequency
- Raises:
ValueError – If works is not a list
TypeError – If works contains non-dict elements
Examples
>>> works = analyzer.extract_artist_works('pablo-picasso') >>> styles = analyzer.analyze_styles(works) >>> for style, count in styles[:3]: ... print(f"{style}: {count} works")
- analyze_temporal_distribution(works)[source]¶
Analyze the temporal distribution of works by decade.
- Parameters:
works (
List[Dict[str,Any]]) – List of artwork dictionaries- Return type:
Dict[str,int]- Returns:
Dictionary mapping decades to work counts
Examples
>>> works = analyzer.extract_artist_works('vincent-van-gogh') >>> decades = analyzer.analyze_temporal_distribution(works) >>> for decade, count in sorted(decades.items()): ... print(f"{decade}s: {count} works")
- get_work_summary(works)[source]¶
Generate a comprehensive summary of a collection of works.
- Parameters:
works (
List[Dict[str,Any]]) – List of artwork dictionaries- Return type:
Dict[str,Any]- Returns:
Dictionary with summary statistics
Examples
>>> works = analyzer.extract_artist_works('edvard-munch') >>> summary = analyzer.get_work_summary(works) >>> print(f"Total works: {summary['total_works']}") >>> print(f"Main style: {summary['primary_style']}")
- plot_genre_distribution(artist_name, limit=None, save_path=None, figsize=(10, 6))[source]¶
Plot genre distribution for a specific artist as a bar chart.
- Parameters:
artist_name (
str) – Artist name as it appears in WikiArtlimit (
Optional[int]) – Optional limit on number of works to analyzesave_path (
Optional[str]) – Optional path to save the figurefigsize (
tuple) – Figure size as (width, height)
- Return type:
None
Example
>>> analyzer = ArtistAnalyzer() >>> analyzer.plot_genre_distribution('pierre-auguste-renoir')
- plot_style_distribution(artist_name, limit=None, save_path=None, figsize=(10, 6))[source]¶
Plot style distribution for a specific artist as a bar chart.
- Parameters:
artist_name (
str) – Artist name as it appears in WikiArtlimit (
Optional[int]) – Optional limit on number of works to analyzesave_path (
Optional[str]) – Optional path to save the figurefigsize (
tuple) – Figure size as (width, height)
- Return type:
None
Example
>>> analyzer = ArtistAnalyzer() >>> analyzer.plot_style_distribution('pablo-picasso')
- compare_artists_genres(artist_names, limit=None, save_path=None, figsize=(12, 8))[source]¶
Compare genre distributions across multiple artists.
- Parameters:
artist_names (
List[str]) – List of artist names to comparelimit (
Optional[int]) – Optional limit on number of works per artistsave_path (
Optional[str]) – Optional path to save the figurefigsize (
tuple) – Figure size as (width, height)
- Return type:
None
Example
>>> analyzer = ArtistAnalyzer() >>> analyzer.compare_artists_genres(['claude-monet', 'pierre-auguste-renoir', 'edgar-degas'])
- create_artist_overview(artist_name, limit=None, save_path=None, figsize=(14, 10))[source]¶
Create a comprehensive overview visualization for an artist.
Includes genre distribution, style distribution, and temporal analysis in a multi-panel figure.
- Parameters:
artist_name (
str) – Artist name as it appears in WikiArtlimit (
Optional[int]) – Optional limit on number of works to analyzesave_path (
Optional[str]) – Optional path to save the figurefigsize (
tuple) – Figure size as (width, height)
- Return type:
None
Example
>>> analyzer = ArtistAnalyzer() >>> analyzer.create_artist_overview('vincent-van-gogh')
- renoir.analyzer.quick_analysis(artist_name, limit=None, show_summary=True, show_plots=False)[source]¶
Quick function to analyze an artist’s works with minimal setup.
This is a convenience function for beginners, combining extraction and analysis in a single call.
- Parameters:
artist_name (
str) – Artist name as it appears in WikiArtlimit (
Optional[int]) – Optional maximum number of works to retrieveshow_summary (
bool) – If True, print a summary of the resultsshow_plots (
bool) – If True, display visualization plots (requires matplotlib)
- Return type:
List[Dict[str,Any]]- Returns:
List of artwork dictionaries
Examples
>>> works = quick_analysis('claude-monet', limit=20) Loading WikiArt dataset... ✓ Loaded 103250 artworks ✓ Found 20 works by claude-monet
Artist Summary: - Total works: 20 - Primary style: Impressionism - Primary genre: landscape - Date range: 1865-1926
>>> works = quick_analysis('claude-monet', limit=20, show_plots=True) # Displays visualization plots