# TF-IDF String to Vector Weka bias

For example, let's say I have a text dataset like:

"words text etc",label
"words text etc",label
"words text etc",label


If I use Weka's String to Word TFIDF transformation, the IDF would consider all the documents in the dataset for IDF.

Wouldn't that make my results biased while classifying the dataset? (since it considers the IDF of the testing portion as well because I made the transform before classifying)

If I split the dataset beforehand, i.e:

Remove Folds 1 --> 10
save as a test file
Remove Folds 1 --> 10 (inverted selection)
save each as a training file


Then if I use StringToWord vector with TF-IDF for the training set and the testing set, I will end up with different vectors in each. How to resolve this?

Am I being too paranoid about bias?
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.2959994375705719, "perplexity": 5377.218450504529}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-34/segments/1596439738858.45/warc/CC-MAIN-20200811235207-20200812025207-00400.warc.gz"}