fetch_multidomain_sentiment#

mlquantify.datasets.fetch_multidomain_sentiment(*, data_home=None, download_if_missing=True, return_X_y=False, as_frame=False, n_retries=3, delay=1.0, protocol=None, n_samples=1000, sample_size=500, random_state=None, domain='books')[source]#

Multi-Domain (Blitzer) Amazon review sentiment (text, covariate shift).

Amazon product reviews in four domains – books, dvd, electronics, kitchen – selected with domain. Each domain has 2000 labelled reviews (1000 positive, 1000 negative) in the processed bag-of-words ‘processed_acl’ format. Training on one domain and quantifying another is the canonical covariate/domain-shift setup.

Quantification: cross-domain train/test -> the standard covariate-shift text testbed.

Documents

2000 per domain

Features

bag-of-words text

Classes

2 (balanced)

Domains

books / dvd / electronics / kitchen

Source: https://www.cs.jhu.edu/~mdredze/datasets/sentiment/

Parameters:
data_homestr or path-like, default=None

Folder used to cache the downloaded file(s); defaults to _data/ next to the package.

download_if_missingbool, default=True

If False, raise instead of downloading when the cache is empty.

return_X_ybool, default=False

Return (X, y) instead of a Bunch.

as_framebool, default=False

Return .data as a DataFrame, .target as a Series, and a combined .frame (features + a "target" column).

n_retriesint, default=3

Number of download attempts before giving up.

delayfloat, default=1.0

Seconds to wait between attempts.

protocol{None, “app”, “npp”, “upp”, “ppp”} or mlquantify protocol, default=None

If set, draw evaluation sample-bags with an mlquantify protocol; the Bunch then also has .samples (index bags into .data), .prevalences and .protocol.

n_samplesint, default=1000

Number of prevalence points (bags) generated by the protocol.

sample_sizeint, default=500

Instances per bag (the protocol batch_size).

random_stateint or None, default=None

Seed forwarded to the protocol.

domain{‘books’,’dvd’,’electronics’,’kitchen’}, default=’books’

Which product domain to load.

Returns:
dataBunch

Dictionary-like object. Attributes: data (features), target (labels), feature_names, target_names, DESCR; frame when as_frame=True; and samples / prevalences / protocol when protocol is set.

(X, y)tuple

Returned instead when return_X_y=True.

References

Blitzer, J. et al. (2007). Domain adaptation for sentiment classification. ACL 2007.

Examples

>>> b = fetch_multidomain_sentiment(domain='dvd'); len(b.data)  
2000