import pandas as pd import numpy as np import getpass import joblib from sklearn.feature_extraction.text import CountVectorizer from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier def word(password): character=[] for i in password: character.append(i) return character def new(): x = np.array(data["password"]) y = np.array(data["strength"]) tdif = TfidfVectorizer(tokenizer=word) x = tdif.fit_transform(x) xtrain, xtest, ytrain, ytest = train_test_split(x, y, test_size=0.05, random_state=42) x = np.array(data["password"]) y = np.array(data["strength"]) tdif = TfidfVectorizer(tokenizer=word) x = tdif.fit_transform(x) joblib.dump(tdif,"tdif.joblib") model = RandomForestClassifier() model.fit(xtrain, ytrain) joblib.dump(model, "passmodel.joblib") def load(): m=joblib.load("passmodel.joblib") td=joblib.load("tdif.joblib") return m,td def test(i,m,td): data = td.transform([str(i)]) output = m.predict(data) return output