PassGuard Password Strength Classifier

A notebook-based machine learning project that classifies passwords into weak, medium, and strong classes using character-level TF-IDF features and model comparison.

sample kino3434
kino34
Notebook target 0 / 1 / 2

Password text patterns as ML features

The notebook reads a two-column password dataset, cleans one missing password value, tokenizes each password into characters, and trains classifiers on TF-IDF vectors.

The project compares Logistic Regression, AdaBoost, and XGBoost using holdout evaluation plus 10-split cross-validation strategies.

Clean rows 669,639
Target classes 3
Models compared 3
Best holdout accuracy 98.05%
01 Load

Read `data.csv` with malformed lines skipped.

02 Vectorize

Represent passwords with character TF-IDF.

03 Compare

Evaluate three supervised classifiers.

04 Report

Accuracy, precision, recall, F1, and CV stability.

Two columns, three strength labels

The notebook reports `669,640` loaded rows, with `669,639` non-null password values and an integer `strength` target column.

After dropping the single null password, the dataset has no duplicate rows. The password length summary from the clean data has a mean of `9.99`, median of `9`, and max length of `220`.

Weak · 0
89,701
Medium · 1
496,801
Strong · 2
83,137
Memory usage in notebook: 10.2+ MB Clean rows: 669,639 Duplicate rows: 0

Character-level TF-IDF representation

The tokenizer in the notebook loops through each password and returns its characters. `TfidfVectorizer` then turns those character tokens into weighted sparse vectors.

A notebook sample prints `kino3434`, with non-zero TF-IDF weights for its character positions. The quick verification script reproduced the pipeline with `87` TF-IDF features on a stratified 50k-row sample.

Notebook tokenizer
def word(inputs):
    a = []
    for i in inputs:
        a.append(i)
    return a
password kino3434 tokens
kino3434
vectorizer TF-IDF

Three classifiers compared in the notebook

The notebook trains each model on the TF-IDF feature matrix after an 80/20 train/test split.

Baseline linear model Logistic Regression

`max_iter=200` for cross-validation and `max_iter=1000` for final multinomial evaluation.

Ensemble model AdaBoost

Evaluated in the notebook with cross-validation and final holdout metrics.

Gradient boosting model XGBoost

The strongest recorded model across holdout accuracy, precision, recall, and F1.

Cross-validation from the notebook

The notebook records both `ShuffleSplit(n_splits=10, test_size=0.2, random_state=42)` and `StratifiedKFold(n_splits=10, shuffle=True, random_state=42)`.

ModelShuffleSplit meanShuffleSplit stdStratifiedKFold meanStratifiedKFold std
Logistic Regression0.81960.00130.81940.0016
AdaBoost0.83290.00200.83070.0013
XGBoost0.97970.00070.98010.0006

Recorded final holdout performance

XGBoost is the strongest recorded model in the notebook, with holdout accuracy and weighted F1 both around 98%.

Logistic Regression
81.97%
AdaBoost
83.20%
XGBoost
98.05%
MetricLogRegAdaBoostXGBoost
Accuracy0.81970.83200.9805
Precision0.80280.83140.9804
Recall0.81970.83200.9805
F10.80260.79110.9804

Course project context

This project was completed as part of the Machine Learning course at UNICA, Università degli Studi di Cagliari.

The repository includes the notebook workflow, dataset, reproducibility setup, and static project showcase.

Università degli Studi di Cagliari logo Academic context Machine Learning course

UNICA · Università degli Studi di Cagliari