Skip to main content

A Python package for measuring marketing emphasis in text data using Hugging Face transformers and multiple marketing constructs.

Project description

Marketing Measures

A Python package for scoring texts on 19 marketing dimensions using Hugging Face transformers.

  • Market Orientation (8 dimensions): customer orientation, competitor orientation, interfunctional coordination, longterm focus, profit focus, intelligence generation, intelligence dissemination, responsiveness

  • Marketing Capabilities (8 dimensions): information management, planning, implementation, pricing capabilities, product development, channel management, communication, selling capabilities

  • Marketing Excellence (3 dimensions): marketing ecosystem, end user, marketing agility

If you use this package in your research, please cite:

  • Damavandi, Hoorsana, Mai, Feng, and Astvansh, Vivek (2025). A New Technique for Measuring a Firm's Marketing Emphasis. Marketing Letters.

Installation

pip install marketing_measures

Usage

Open In Colab

import pandas as pd
from marketing_measures import MarketingEmphasisScorer

# Initialize the scorer
scorer = MarketingEmphasisScorer()

# Example texts covering various marketing aspects
texts = [
    "The firm uses AI to understand customer needs and preferences.",
    "We continuously scan the market to gather insights about competitors.",
    "Accurate customer analysis helps refine our marketing strategies.",
    "Market research revealed a gap in services that we can exploit.",
    "Collecting smart data enables more precise targeting.",
    "Our marketing strategy incorporates both traditional and digital channels.",
    "The team designed a creative campaign to boost brand awareness.",
    "We follow a structured marketing planning process each quarter.",
    "Segmentation allows us to tailor messages for different customer groups.",
    "The campaign exemplified out-of-the-box thinking to reach Gen Z consumers.",
    "Marketing KPIs are monitored weekly to ensure implementation is on track.",
    "Fast execution of campaigns helps us stay ahead of competitors.",
    "The team was highly responsive to market changes during the rollout.",
    "Resources were reallocated flexibly to maximize performance.",
    "Speed and adaptability are essential for successful marketing implementation.",
    "Our pricing strategy reflects deep knowledge of competitor price points.",
    "Dynamic pricing tools support our price setting capabilities.",
    "The team reviewed pricing insights before launching the new service.",
    "We adjusted prices based on customer feedback and pricing analytics.",
    "A strong pricing capability ensures we capture value without losing volume.",
    "R&D investment led to a novel solution for customer pain points.",
    "The product development team worked closely with users to refine features.",
    "Test marketing revealed high acceptance for the innovation.",
    "Commercialization of the new product was accelerated by effective planning.",
    "Innovation management is central to our long-term competitiveness.",
    "Strong distributor relationships enhance our reach in remote markets.",
    "We provide ongoing retailer support to improve product visibility.",
    "Retailer cooperation was key in launching the new product line.",
    "Channel management focuses on adding value across the supply chain.",
    "Partnering with intermediaries allowed faster market penetration.",
    "The advertising campaign increased brand awareness significantly.",
    "Our marketing communication strategy emphasizes consistent messaging.",
    "Public relations helped manage reputation during the crisis.",
    "Image and branding efforts are supported by coordinated promotion.",
    "We rely on integrated marketing communication for maximum impact.",
    "Salespeople are trained regularly to improve selling skills.",
    "Sales support tools help enable more effective customer interactions.",
    "The sales strategy focuses on value-based selling.",
    "Sales management ensures quotas are aligned with overall goals.",
    "Sales controlling enables better forecasting and performance evaluation.",
]

# Score texts using pre-trained ZCA transformers
results = scorer.score_texts(
    texts=texts,
    zca_transform="pre-trained",
    batch_size=32,
)

# Convert results to DataFrame for analysis
df = pd.DataFrame(results)
df["text"] = texts

# Focus on marketing capabilities dimensions
marketing_capability_dimensions = [
    "marketing information management",
    "marketing planning capabilities", 
    "marketing implementation capabilities",
    "pricing capabilities",
    "product development capabilities",
    "channel management",
    "marketing communication capabilities",
    "selling capabilities",
]

# Find top 3 sentences for each marketing capability dimension
for dimension in marketing_capability_dimensions:
    print(f"Top 3 sentences for {dimension}:")
    top_indices = df[dimension].nlargest(3).index
    for idx in top_indices:
        print(f"- {df['text'][idx]}")
    print()

# Get information about all available dimensions
print("All available dimensions:", model_info["all_dimension_names_in_order"])

Additional Examples

Example with DataFrame containing a text column:

import pandas as pd
from marketing_measures import MarketingEmphasisScorer

# Load or create a DataFrame with text data
df = pd.read_csv("data/example_data.csv")

# Initialize the scorer
scorer = MarketingEmphasisScorer()

# Score the text column
scores = scorer.score_texts(
    texts=df['text'].tolist(),
    zca_transform="pre-trained",
    batch_size=32,
)

# Add scores to the original DataFrame
scores_df = pd.DataFrame(scores)
result_df = pd.concat([df, scores_df], axis=1)

# Display results
print(result_df[['marketing ecosystem', 'end user', 'marketing agility']])

Use a different embedding model (from Hugging Face):

scorer = MarketingEmphasisScorer(model_name="mixedbread-ai/mxbai-embed-large-v1")

Raw score without ZCA transformation

Note: The Zero Component Analysis (ZCA) transformation is used to whiten the measures within each of the three constructs (Market Orientation, Marketing Capabilities, Marketing Excellence), which helps decorrelate and normalize the data. The pre-trained ZCA models were trained on executive presentations from earnings call transcripts spanning from 2003Q1 to 2023Q1.

scores_raw = scorer.score_texts(texts, zca_transform='none')

Score and estimate ZCA from input data (need larger dataset for better estimation)

scores_zca_estimated, zca_models = scorer.score_texts(
    texts, 
    zca_transform='estimate', 
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marketing_measures-0.1.5.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marketing_measures-0.1.5-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file marketing_measures-0.1.5.tar.gz.

File metadata

  • Download URL: marketing_measures-0.1.5.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for marketing_measures-0.1.5.tar.gz
Algorithm Hash digest
SHA256 1b7401616b22762f119ccef491c993c3f5e4332fd058198dd7c8b5aad4566beb
MD5 16841a08405a9303d83f6b4341f8fda3
BLAKE2b-256 9dc6bab9965502c1d4abf1520c5b854797d1e78bdd2347bcfa7b3eed5e52fbd6

See more details on using hashes here.

File details

Details for the file marketing_measures-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for marketing_measures-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 59981403b7dfb5d398af172e6ddaeb4c50f1ea604e6bd04240e43a734f77e382
MD5 2634cb2dae39492e8c645d7feea5c205
BLAKE2b-256 8537eab629ae48fd0c773e7d2eb942f2313b202457a468a5355e2bd25cb1adba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page