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.4.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.4-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: marketing_measures-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 5e2ea19efcfd1c4ff608debc3e2f4b5558a98d5efc79f38c3e53aa7f3e901680
MD5 302e77201def69659130834044fa5b3c
BLAKE2b-256 c7d1f43e1132abc121fe50eb87a0c5ee1db3216b48d710320052f566e1f28561

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for marketing_measures-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d8fed5a7e6d0cf7410a4c3f97aefb703cdd0c9fbb6796c217d8043a0844352df
MD5 48d195f5c5802787d38b9f3aa7e84af5
BLAKE2b-256 e06da780e129d5218ef54170a7d9f8e0adc3588a16297c0911420c3d1cbaed9b

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