File size: 1,183 Bytes
23dd196 1a3c576 23dd196 1a3c576 23dd196 1a3c576 23dd196 1a3c576 23dd196 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
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
|