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: object

Analyze 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]}")
load_dataset()[source]

Load and return the WikiArt dataset.

This is a public alias for _load_dataset().

Returns:

The loaded WikiArt dataset.

Raises:

RuntimeError – If dataset loading fails

list_artists(limit=None)[source]

List artist names available in the WikiArt dataset.

Parameters:

limit (Optional[int]) – Optional maximum number of artist names to return

Return type:

List[str]

Returns:

List of artist names as they appear in the dataset

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. The current live huggan/wikiart dataset provides keys image, artist, genre and style. Additional keys such as title or date may be present in augmented or user-provided datasets.

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(sorted(monet_works[0].keys()))
['artist', 'genre', 'image', 'style']
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), show=True)[source]

Plot genre distribution for a specific artist as a bar chart.

Parameters:
  • artist_name (str) – Artist name as it appears in WikiArt

  • limit (Optional[int]) – Optional limit on number of works to analyze

  • save_path (Optional[str]) – Optional path to save the figure

  • figsize (tuple) – Figure size as (width, height)

  • show (bool) – If True, display the figure with plt.show()

Return type:

Any

Example

>>> analyzer = ArtistAnalyzer()
>>> fig = analyzer.plot_genre_distribution('pierre-auguste-renoir')
plot_style_distribution(artist_name, limit=None, save_path=None, figsize=(10, 6), show=True)[source]

Plot style distribution for a specific artist as a bar chart.

Parameters:
  • artist_name (str) – Artist name as it appears in WikiArt

  • limit (Optional[int]) – Optional limit on number of works to analyze

  • save_path (Optional[str]) – Optional path to save the figure

  • figsize (tuple) – Figure size as (width, height)

  • show (bool) – If True, display the figure with plt.show()

Return type:

Any

Example

>>> analyzer = ArtistAnalyzer()
>>> fig = analyzer.plot_style_distribution('pablo-picasso')
compare_artists_genres(artist_names, limit=None, save_path=None, figsize=(12, 8), show=True)[source]

Compare genre distributions across multiple artists.

Parameters:
  • artist_names (List[str]) – List of artist names to compare

  • limit (Optional[int]) – Optional limit on number of works per artist

  • save_path (Optional[str]) – Optional path to save the figure

  • figsize (tuple) – Figure size as (width, height)

  • show (bool) – If True, display the figure with plt.show()

Return type:

Any

Example

>>> analyzer = ArtistAnalyzer()
>>> fig = analyzer.compare_artists_genres(['claude-monet', 'pierre-auguste-renoir', 'edgar-degas'])
create_artist_overview(artist_name, limit=None, save_path=None, figsize=(14, 10), show=True)[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 WikiArt

  • limit (Optional[int]) – Optional limit on number of works to analyze

  • save_path (Optional[str]) – Optional path to save the figure

  • figsize (tuple) – Figure size as (width, height)

  • show (bool) – If True, display the figure with plt.show()

Return type:

Any

Example

>>> analyzer = ArtistAnalyzer()
>>> fig = analyzer.create_artist_overview('vincent-van-gogh')
analyze_works_color_signature(works, n_colors=5, group_by_period=True, include_figure=False, save_path=None, random_state=42, verbose=True)[source]

Compute a color signature from a provided list of artwork dictionaries.

This lower-level method lets callers supply their own dated works, enabling full temporal analysis when the dataset includes date metadata.

Parameters:
  • works (List[Dict[str, Any]]) – List of artwork dictionaries. Each should contain an image key (PIL Image or ndarray) and optionally a date key.

  • n_colors (int) – Number of dominant colors to extract per artwork and to return in the aggregated signature palette.

  • group_by_period (bool) – If True and dates are available, also compute per-decade signatures.

  • include_figure (bool) – If True, generate and return a matplotlib figure.

  • save_path (Optional[str]) – Optional path to save the figure instead of displaying it.

  • random_state (int) – Random seed for reproducible extraction and sampling.

  • verbose (bool) – If True, print progress messages.

Return type:

Dict[str, Any]

Returns:

Dictionary with aggregated palette, metrics, optional per-period breakdown, and optional figure.

artist_color_signature(artist_name, limit=10, n_colors=5, strategy='temporal', include_figure=False, save_path=None, random_state=42, verbose=True)[source]

Compute a color signature for an artist from WikiArt.

By default, extracts up to 10 works sampled to maximize temporal coverage. If no parseable dates are available in the dataset, the method falls back to random sampling and reports the effective strategy in the result.

Parameters:
  • artist_name (str) – Artist name as it appears in WikiArt.

  • limit (int) – Maximum number of works to analyze (default: 10).

  • n_colors (int) – Number of colors in the signature palette.

  • strategy (str) – Sampling strategy — 'temporal' (default), 'random', or 'first'.

  • include_figure (bool) – If True, generate a visualization.

  • save_path (Optional[str]) – Optional path to save the figure.

  • random_state (int) – Seed for reproducible sampling and extraction.

  • verbose (bool) – If True, print progress messages.

Return type:

Dict[str, Any]

Returns:

Dictionary with artist color signature, metrics, optional per-period breakdown, and optional figure.

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 WikiArt

  • limit (Optional[int]) – Optional maximum number of works to retrieve

  • show_summary (bool) – If True, print a summary of the results

  • show_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