FluentCleanPrompt#
- class scikitplot.cleanprompt.FluentCleanPrompt(plan=None)[source]#
Build a
CleanPlanone decision at a time.- Parameters:
- planCleanPlan, optional
Start from an existing plan. Defaults to
packs('auto')over every format, placeholders, core patterns on, no entity engine.
- Parameters:
plan (CleanPlan | None)
Notes
User notes. Every method returns a new builder. Each domain may be set once; set it again with
conflict='replace'to overwrite orconflict='extend'to add to it.Examples
>>> plan = FluentCleanPrompt().packs("patient").formats("csv").plan() >>> plan.packs, plan.formats (('patient',), ('csv',)) >>> FluentCleanPrompt().packs("patient").packs("finance") Traceback (most recent call last): ... scikitplot.cleanprompt._exceptions.CleanPromptError: packs is already set to ('patient',); pass conflict='replace' or conflict='extend' >>> sorted( ... FluentCleanPrompt() ... .packs("patient") ... .packs("finance", conflict="extend") ... .plan() ... .packs ... ) ['finance', 'patient']
- build()[source]#
Return the plan, or raise listing every problem with it.
- Returns:
- CleanPlan
Validated.
- Raises:
- CleanPromptError
With one line per problem.
- Return type:
- core(enabled=True, conflict='error')[source]#
Turn the built-in structural patterns on or off.
- Parameters:
- Return type:
- custom(*paths, conflict='error', replace_builtins=False)[source]#
Add custom pack or format definitions from YAML or JSON files.
- Parameters:
- *pathsstr
Definition files.
- conflict{‘error’, ‘replace’, ‘extend’}, default=’error’
What to do if custom files were already given.
- replace_builtinsbool, default=False
Let a custom definition replace a built-in of the same name.
- Returns:
- FluentCleanPrompt
A new builder.
- Parameters:
- Return type:
- formats(*names, conflict='error')[source]#
Choose which formats are read: names, extensions, or
'all'.- Parameters:
- *namesstr
Format names (
'csv'), extensions ('.env') or'all'.- conflict{‘error’, ‘replace’, ‘extend’}, default=’error’
What to do if formats were already chosen.
- Returns:
- FluentCleanPrompt
A new builder.
- Parameters:
- Return type:
- hide(*terms, conflict='error')[source]#
Hide these exact strings wherever they appear.
- Parameters:
- Return type:
- infer_roles(enabled=True, conflict='error')[source]#
Guess column roles from their names; reported as inferred.
- Parameters:
- Return type:
- keep(*parts, conflict='error')[source]#
Send artefact parts removed by default:
outputs,figures,paths.- Parameters:
- Return type:
- materialize()[source]#
Return a
Cleanerfor this plan.- Returns:
- Cleaner
Ready to encode text, files, directories and archives.
- Raises:
- CleanPromptError
If the plan does not validate, or an entity engine it asks for is not usable.
- ner(engine='auto', language='en', conflict='error')[source]#
Turn on entity detection with
auto,spacy,nltkorboth.- Parameters:
- Return type:
- packs(*names, conflict='error')[source]#
Choose packs: names, or
'all','auto'or'none'.- Parameters:
- *namesstr
One or more pack names, or a single mode keyword.
- conflict{‘error’, ‘replace’, ‘extend’}, default=’error’
What to do if packs were already chosen.
- Returns:
- FluentCleanPrompt
A new builder.
- Parameters:
- Return type:
- pattern_risk(mode, conflict='error')[source]#
Choose what a risky custom pattern does:
warn,ignoreorrefuse.- Parameters:
- mode{‘warn’, ‘ignore’, ‘refuse’}
warnloads the pattern and says what was found and how to fix or accept it;ignoreloads it silently;refusemakes the plan invalid until the pattern is rewritten or accepted in its pack (risk: acceptedwith arisk_reason).- conflict{‘error’, ‘replace’}, default=’error’
What to do if a mode was already chosen.
- Returns:
- FluentCleanPrompt
A new builder.
- Raises:
- CleanPromptError
If
modeis not one of the three.
- Parameters:
- Return type:
- profile(name, conflict='error')[source]#
Choose the core-pattern profile:
minimal,balancedorstrict.- Parameters:
- Return type:
- remember(enabled=True, conflict='error')[source]#
Hide a value everywhere once it has been hidden anywhere (default on).
Notes
User notes. A patient’s name found in the
namecolumn of a CSV is then also hidden in the free-text note encoded after it, where no field rule could see it. Turn it off only when you need each file’s output to be independent of what was encoded before.- Parameters:
- Return type:
- roles(mapping=None, conflict='error', **named)[source]#
Declare column roles, e.g.
roles(churned="target").
- style(name, conflict='error')[source]#
Choose
placeholder([EMAIL-1]) orsurrogatestand-ins.- Parameters:
- Return type:
- surrogates(path, conflict='error')[source]#
Use a custom surrogate set’s names (needs
style('surrogate')).- Parameters:
- pathstr
A
.yaml,.ymlor.jsonsurrogate set.- conflict{‘error’, ‘replace’}, default=’error’
What to do if a set was already chosen.
- Returns:
- FluentCleanPrompt
A new builder. The set is loaded and checked by
validate.
- Parameters:
- Return type:
Gallery examples#
Cleanprompt as a Gate: Any Model, Any Agent, Nothing Private Leaves
Cleanprompt Packs and Formats: Records, Configs and Whole Folders