Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
af386ef
log features that are not yet tested
xehu May 29, 2025
a60720c
Drop unhashable columns from orig_data; Use print instead of warnings…
sundy1994 Jun 6, 2025
3cadd01
Fixes #359
sundy1994 Jun 9, 2025
995c78b
Enhance emoji detection by utilizing a predefined emoji list and upda…
sundy1994 Jun 12, 2025
c65727d
use original message column for emoji counting to include edge cases …
sundy1994 Jun 13, 2025
227931a
Add politeness-related test cases
sundy1994 Jun 17, 2025
0ec1043
Add receptiveness-yeomans related test cases
sundy1994 Jun 17, 2025
859f0e1
Add missing column "num_line_breaks"; Improve feature counting method…
sundy1994 Jun 17, 2025
a0ccdcc
Refactor bert generation to optimize RAM usage
sundy1994 Jun 23, 2025
7222a36
Add GPU support for embeddings
sundy1994 Jun 24, 2025
43a3351
update function signatures and ensure device compatibility
sundy1994 Jun 24, 2025
c71951e
Fix tensor device handling in sentiment analysis to ensure compatibil…
sundy1994 Jun 24, 2025
810a2c0
bump pyproject.toml
xehu Jun 25, 2025
e013560
fix file overwritten issue
sundy1994 Jun 25, 2025
f6ee3c1
Clean up and update test data
sundy1994 Jun 25, 2025
9235309
update documentation with new gpu parameter
xehu Jun 26, 2025
1df76ce
Merge pull request #361 from Watts-Lab/testing_100
xehu Jun 26, 2025
c3b4422
sync politeness updates
sundy1994 Dec 16, 2025
b388a32
add new WH/yesno questions to yeomans_test dataset
sundy1994 Dec 16, 2025
2f79bf8
Enhance logging functionality
sundy1994 Jan 7, 2026
14dc294
Refactor Yes/No question detection and improve WH question handling i…
sundy1994 Jan 8, 2026
125d821
add 'am' to WH followers
xehu Jan 9, 2026
a6e99a7
remove commented-out thank you
xehu Jan 9, 2026
183d1e6
add am everywhere
xehu Jan 9, 2026
bafe275
update to question detection
xehu Jan 9, 2026
40aee79
an expanded and more robust version of the question function (with a …
xehu Jan 10, 2026
8e15934
fixing more edge cases
xehu Jan 10, 2026
a011781
update robustness of question detector and update tests
xehu Jan 11, 2026
4b2b0ed
Merge pull request #367 from Watts-Lab/update_politeness_v2
xehu Jan 12, 2026
e4ded18
Enhance logging and feature processing in FeatureBuilder and utility …
sundy1994 Apr 6, 2026
c944c74
update docstrings
sundy1994 May 7, 2026
d42b4c1
two small changes: (1) ensure that we only run the column groupings o…
xehu Jun 1, 2026
2e7214a
update docs
xehu Jun 1, 2026
044f8e2
Merge branch 'dev' into log_file
xehu Jun 1, 2026
93b074e
fix copilot review suggestions and add tests
xehu Jun 1, 2026
161cfa6
Merge remote-tracking branch 'refs/remotes/origin/log_file' into log_…
xehu Jun 1, 2026
1949a58
Add missing test fixture for drop_redundant_columns tests
xehu Jun 1, 2026
8bea13e
Stop ignoring test fixture CSVs in tests/data/cleaned_data
xehu Jun 1, 2026
baa3a43
Run drop_redundant_columns tests in CI
xehu Jun 1, 2026
5eb99c0
Merge pull request #370 from Watts-Lab/log_file
xehu Jun 1, 2026
c6c78e5
Pin numpy<2 in RTD pre_install to fix spacy model download
xehu Jun 1, 2026
2135951
Install en_core_web_sm wheel directly instead of spacy download
xehu Jun 1, 2026
887e730
fixed ID score formula, updated docstring, removed unused imports
sundy1994 Jun 29, 2026
054da82
Merge pull request #371 from Watts-Lab/ID_score_fix
xehu Jul 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/github-actions-test-simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
cd tests
pytest test_feature_metrics.py
pytest test_package.py
pytest test_drop_redundant_columns.py

- name: Upload test results
uses: actions/upload-artifact@v4
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ share/python-wheels/
*.egg
MANIFEST

# Claude Code
.claude/

# IntelliJ
.idea/

Expand Down Expand Up @@ -54,8 +57,13 @@ src/features/lexicons/certainty.txt
examples/vector_data/*
examples/output/*
node_modules/
*.csv
# but always track test fixture CSVs so they aren't silently dropped
!tests/data/cleaned_data/*.csv
*.log

# testing
/output
/vector_data
test.py
test.py
test.ipynb
8 changes: 6 additions & 2 deletions docs/.readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ build:
# golang: "1.19"
jobs:
pre_install: # Stuff in src/requirements.txt depends on en_core_web_sm, which in turn depends on spacy
- pip install spacy==3.7.2
- bash -c "python3 -m spacy download en_core_web_sm"
- pip install "numpy<2.0.0" "spacy==3.7.2"
# Install the model wheel directly instead of `spacy download`, which
# resolves the model version via a runtime compatibility lookup that
# can fail and build a malformed (404) URL. en_core_web_sm-3.7.1 is the
# release compatible with spacy 3.7.2.
- pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1-py3-none-any.whl
post_install: # Install NLTK resources after the install step
- python3 -m nltk.downloader nps_chat
- python3 -m nltk.downloader punkt
Expand Down
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/examples.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/feature_builder.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/features/temporal_features.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/utils/calculate_chat_level_features.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/utils/check_embeddings.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/utils/preprocess.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: d7678f479036f3220c73480ec4f2c467
config: 9a01a2cd3d4384710101b4a99edd7683
tags: 645f666f9bcd5a90fca523b33c5a78b7
61 changes: 49 additions & 12 deletions docs/build/html/_sources/examples.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ Now we are ready to call the FeatureBuilder on our data. All we need to do is de
speaker_id_col = "speaker_nickname",
message_col = "message",
timestamp_col = "timestamp",
grouping_keys = ["batch_num", "round_num"],
grouping_keys = ["batch_num", "round_num"], # NOTE: This example demonstrates grouping. Use conversation_id_col if you have a single conversation identifier.
vector_directory = "./vector_data/",
output_file_base = "jury_output",
turns = True
turns = True, # NOTE: This defaults to False. Decide whether you want to combine successive 'utterances' by the same person as a 'turn.'
drop_redundant_columns = True # NOTE: This defaults to False. When True, highly correlated and sparse feature columns are dropped from the output.
)
jury_feature_builder.featurize()

Expand Down Expand Up @@ -219,6 +220,12 @@ Regenerating Vector Cache

* By default, **we assume that, if your output file is named the same, that the underlying vectors are the same**. If this isn't true, you should set **regenerate_vectors = True** in order to clear out the cache and re-generate the RoBERTa and SBERT outputs.


Generating Vectors using GPU
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
By default, we use the CPU to generate sentence vectors and cached RoBERTa sentimets. To override this feature and use a GPU when available (which will speed up the computation of the vectors), turn ``use_gpu`` to True.


Custom Features
~~~~~~~~~~~~~~~~~

Expand All @@ -235,18 +242,12 @@ Custom Features

* You can chose to add any of these features depending on your preference.

Analyzing First Percentage (%)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* The **analyze_first_pct** parameter allows you to "cut off" and separately analyze the first X% of a conversation, in case you wish to separately study different sections of a conversation as it progresses. For example, you may be interested in knowing how the attributes of the first 50% of a conversation differ from the attributes of the entire conversation. Then you can sepcify the following:

.. code-block:: python
Analyzing First Percentage (%) [Deprecated]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

analyze_first_pct: [0.5, 1.0]
.. warning::

* This will first analyze the first 50% of each conversation, and then analyze the full conversation.

* By default, we will simply analyze 100% of each conversation.
**Deprecated as of v.0.1.8.** The **analyze_first_pct** parameter (and its underlying ``get_first_pct_of_chat`` method) has been removed. To analyze only a portion of a conversation, subset your input dataframe before passing it to the FeatureBuilder.

Named Entity Recognition
~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -344,6 +345,42 @@ Important Notes and Caveats
- **[NOTE 2]** Be careful when choosing the "sum" aggregation method, as it is not always appropriate to use the "sum" as an aggregation function. While it is a sensible choice for utterance-level attributes that are *countable* (for example, the total number of words, or other lexical wordcounts), it is a less sensible choice for others (for example, it does not make sense to sum sentiment scores for each utterance in a conversation). Consequently, using the "sum" feature will come with an associated warning.
- **[NOTE 3]** In addition to aggregating from the utterance (chat) level to the conversation level, we also aggregate from the speaker (user) level to the conversation level, using the same methods specified in ``convo_methods`` to do so.

.. _reducing_redundant_features:

Reducing Redundant Features
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* **New in v.0.1.8.** The FeatureBuilder generates a large number of features, and many of them are highly correlated with one another or are sparsely populated (containing mostly missing or zero values). The following parameters allow the FeatureBuilder to automatically detect groups of redundant features and retain only one representative per group, as well as drop columns that are dominated by missing (NA) or zero values.

* The **drop_redundant_columns** parameter is the main "switch" controlling this behavior. It defaults to **False**, meaning that no columns are dropped; instead, the FeatureBuilder simply *logs* which columns it identified as redundant. When set to **True**, the redundant columns are actually removed from the chat-, user-, and conversation-level outputs.

* Note that only features generated by the FeatureBuilder are considered. Your original input columns (metadata, outcome variables, and other non-numeric columns) are always preserved untouched.

* The remaining parameters control *how* redundancy is detected:

* **corr_thresh** (default ``0.9``): the minimum absolute Spearman correlation at which two numeric features are treated as redundant. Features whose correlations meet this threshold are clustered into groups, and one representative (the column with the most valid data and highest variance) is kept from each group.

* **min_group_size** (default ``2``): the minimum number of correlated columns required to form a redundancy group.

* **min_na_ratio** (default ``0.3``): numeric columns whose fraction of missing (NA) values exceeds this threshold are flagged (and dropped, if **drop_redundant_columns** is **True**).

* **min_zero_ratio** (default ``0.9``): numeric columns whose fraction of zero values exceeds this threshold are flagged (and dropped, if **drop_redundant_columns** is **True**).

* **treat_zero_as_na** (default ``True``): if **True**, zeros are treated as missing values when computing redundancy metrics and selecting the representative column for each group.

* **Example: dropping correlated features.** To actually drop redundant columns (rather than just logging them), set **drop_redundant_columns = True**. Recall that this parameter **defaults to False**, so you must opt in. The example below keeps only one representative from each group of features correlated at an absolute Spearman correlation of 0.9 or higher:

.. code-block:: python

jury_feature_builder = FeatureBuilder(
input_df = juries_df,
grouping_keys = ["batch_num", "round_num"],
output_file_base = "jury_output",
drop_redundant_columns = True, # Defaults to False; set to True to drop redundant columns rather than only logging them.
corr_thresh = 0.9 # Cluster features correlated at >= 0.9 (absolute Spearman) and keep one representative per group.
)
jury_feature_builder.featurize()

Cumulative Grouping
~~~~~~~~~~~~~~~~~~~~

Expand Down
36 changes: 18 additions & 18 deletions docs/build/html/_static/pygments.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .hll { background-color: #ffffcc }
.highlight { background: #f8f8f8; }
.highlight .c { color: #3D7B7B; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .err { border: 1px solid #F00 } /* Error */
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .o { color: #666 } /* Operator */
.highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #9C6500 } /* Comment.Preproc */
Expand All @@ -25,34 +25,34 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .gt { color: #04D } /* Generic.Traceback */
.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008000 } /* Keyword.Pseudo */
.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #B00040 } /* Keyword.Type */
.highlight .m { color: #666666 } /* Literal.Number */
.highlight .m { color: #666 } /* Literal.Number */
.highlight .s { color: #BA2121 } /* Literal.String */
.highlight .na { color: #687822 } /* Name.Attribute */
.highlight .nb { color: #008000 } /* Name.Builtin */
.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.highlight .no { color: #880000 } /* Name.Constant */
.highlight .nd { color: #AA22FF } /* Name.Decorator */
.highlight .nc { color: #00F; font-weight: bold } /* Name.Class */
.highlight .no { color: #800 } /* Name.Constant */
.highlight .nd { color: #A2F } /* Name.Decorator */
.highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0000FF } /* Name.Function */
.highlight .nf { color: #00F } /* Name.Function */
.highlight .nl { color: #767600 } /* Name.Label */
.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.highlight .nn { color: #00F; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #19177C } /* Name.Variable */
.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #666666 } /* Literal.Number.Bin */
.highlight .mf { color: #666666 } /* Literal.Number.Float */
.highlight .mh { color: #666666 } /* Literal.Number.Hex */
.highlight .mi { color: #666666 } /* Literal.Number.Integer */
.highlight .mo { color: #666666 } /* Literal.Number.Oct */
.highlight .ow { color: #A2F; font-weight: bold } /* Operator.Word */
.highlight .w { color: #BBB } /* Text.Whitespace */
.highlight .mb { color: #666 } /* Literal.Number.Bin */
.highlight .mf { color: #666 } /* Literal.Number.Float */
.highlight .mh { color: #666 } /* Literal.Number.Hex */
.highlight .mi { color: #666 } /* Literal.Number.Integer */
.highlight .mo { color: #666 } /* Literal.Number.Oct */
.highlight .sa { color: #BA2121 } /* Literal.String.Affix */
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
Expand All @@ -67,9 +67,9 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0000FF } /* Name.Function.Magic */
.highlight .fm { color: #00F } /* Name.Function.Magic */
.highlight .vc { color: #19177C } /* Name.Variable.Class */
.highlight .vg { color: #19177C } /* Name.Variable.Global */
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
.highlight .vm { color: #19177C } /* Name.Variable.Magic */
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
.highlight .il { color: #666 } /* Literal.Number.Integer.Long */
5 changes: 2 additions & 3 deletions docs/build/html/_static/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,13 @@ const Search = {
for (const [title, foundTitles] of Object.entries(allTitles)) {
if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) {
for (const [file, id] of foundTitles) {
const score = Math.round(Scorer.title * queryLower.length / title.length);
const boost = titles[file] === title ? 1 : 0; // add a boost for document titles
let score = Math.round(100 * queryLower.length / title.length)
normalResults.push([
docNames[file],
titles[file] !== title ? `${titles[file]} > ${title}` : title,
id !== null ? "#" + id : "",
null,
score + boost,
score,
filenames[file],
]);
}
Expand Down
Loading
Loading