1 Star 0 Fork 0

Kahsolt/PDB-analyze

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
lr.py 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
Kahsolt 提交于 2023-01-11 18:16 . merge repo
#!/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)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kahsolt/pdb-analyze.git
git@gitee.com:kahsolt/pdb-analyze.git
kahsolt
pdb-analyze
PDB-analyze
master

搜索帮助