代码拉取完成,页面将自动刷新
#!/usr/bin/env python3
# Author: Armit
# Create Time: 2022/11/22
from argparse import ArgumentParser
from sklearnex import patch_sklearn ; patch_sklearn()
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from data import get_data, FEATURE_NUM
from utils import show_clf_metrics
def lr(args):
X, y = get_data(args.limit, FEATURE_NUM)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.7, random_state=42)
print(f'dataset: {len(X_train)} for train. {len(X_test)} samples for test')
model = LogisticRegression(solver=args.solver, max_iter=233,
tol=1e-3, C=args.C, penalty='l2',
verbose=1, n_jobs=4, random_state=42)
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
show_clf_metrics(y_test, y_pred)
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('-M', '--solver', default='lbfgs', choices=['newton-cg', 'lbfgs', 'liblinear', 'sag', 'saga'])
parser.add_argument('-C', default=0.8, type=float, help='smaller values specify stronger regularization')
parser.add_argument('-N', '--limit', default=20000, type=int, help='limit dataset size')
args = parser.parse_args()
lr(args)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。