支持向量机

基本:
http://sklearn.apachecn.org/#/docs/5

超参数设置:
参考:
https://www.cnblogs.com/nwpuxuezha/p/6618205.html
https://www.cnblogs.com/huanping/p/9330849.html

def trysvm(trainx, trainy, testx, testy):
    c_range = np.logspace(-5, 15, 11, base=2)
    gamma_range = np.logspace(-9, 3, 13, base=2)
    svc = SVC(kernel='rbf', class_weight='balanced' )
    parameters=[{'kernel': ['rbf'], 'C': c_range, 'gamma': gamma_range}]
    clf = GridSearchCV(svc, parameters, n_jobs=-1,cv=5)
    clf.fit(trainx, trainy)

	#把测试的超参数以及结果写入文件
    cv_result = pd.DataFrame.from_dict(clf.cv_results_)
    with open('cv_result.csv', 'w') as f:
        cv_result.to_csv(f)

详细:
https://www.jianshu.com/p/a9f9954355b3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值