关于:cross_validation.scores
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 10 08:10:35 2016 @author: Administrator
"""
'''
关于:cross_validation.scores
此处cross_validation.scores并不是cross_validation的scores,
而是分类函数(本文是clf,svm)的scores
分成K部分
K-1是训练
1次是测试
共K个scores
''' import time
import numpy as np
from sklearn import cross_validation
from sklearn import datasets
from sklearn import svm start = time.time()
iris = datasets.load_iris()
print iris.data.shape, iris.target.shape
#(150L, 4L) (150L,) X_train, X_test, y_train, y_test = cross_validation.train_test_split(iris.data, iris.target, test_size=0.4, random_state=0)
print X_train.shape, y_train.shape
print X_test.shape, y_test.shape
#(90L, 4L) (90L,)
#(60L, 4L) (60L,) clf = svm.SVC(kernel='linear', C=1).fit(X_train, y_train)
print clf.score(X_test, y_test)
#0.966666666667 #模块2
clf = svm.SVC(kernel='linear', C=1)
scores = cross_validation.cross_val_score(clf, iris.data, iris.target, cv=5)
print scores
#[ 0.96666667 1. 0.96666667 0.96666667 1. ]
print("Accuracy: %0.2f (+/- %0.2f)" % (scores.mean(), scores.std() * 2))
#Accuracy: 0.98 (+/- 0.03) #模块3
from sklearn import metrics
scores = cross_validation.cross_val_score(clf, iris.data, iris.target,cv=5, scoring='f1_weighted')
print scores
#[ 0.96658312 1. 0.96658312 0.96658312 1. ] print("Took %.2f seconds for" % ((time.time() - start)))
关于:cross_validation.scores的更多相关文章
- [LeetCode] Rank Scores 分数排行
		Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ... 
- Codeforces Round #370 (Div. 2)  D. Memory and Scores DP
		D. Memory and Scores Memory and his friend Lexa are competing to get higher score in one popular c ... 
- Faster RCNN 运行自己的数据,刚开始正常,后来就报错: Index exceeds matrix dimensions.  Error in ori_demo (line 114)  boxes_cell{i} = [boxes(:, (1+(i-1)*4):(i*4)), scores(:, i)];
		function script_faster_rcnn_demo() close all; clc; clear mex; clear is_valid_handle; % to clear init ... 
- LeetCode Database: Rank Scores
		Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ... 
- LeetCode:Rank Scores
		做到这题时卡了不少时间,参考了别人的解法,觉得挺不错的,还挺巧妙. SELECT s2.Score,s1.Rank From ( SELECT S1.Score, COUNT(*) as Rank F ... 
- (Problem 22)Names scores
		Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-tho ... 
- Memory and Scores
		Memory and Scores 题目链接:http://codeforces.com/contest/712/problem/D dp 因为每轮Memory和Lexa能取的都在[-k,k],也就是 ... 
- anacoda报错No module named 'sklearn.cross_validation'
		在目前的snacoda里集成的sklearn已经不存在cross_validation模块了 使用以下模块 from sklearn.model_selection import train_te ... 
- [SQL]LeetCode178. 分数排名 | Rank Scores
		Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ... 
随机推荐
- flask--Wtform
			一.Wtform WTForms是一个支持多个web框架的form组件,主要用于对用户请求数据进行验证. 安装: pip3 install wtform 用途: 1. 用户登录注册 ... 
- MATLAB中feval与eval的区别
			feval函数有两种调用形式1.[y1, y2, ...] = feval(fhandle, x1, ..., xn)2.[y1, y2, ...] = feval(fname, x1, ..., x ... 
- JDK与JRE及其在Eclipse中的使用
			转载自:http://blog.csdn.net/gx1058742912/article/details/51033942 JDK与jRE的区别 JDK(java development kit): ... 
- OSX 10.11.1 预览照片绿屏的问题
			最新版本的El Capitan仍然会出现Finder预览多张照片时,会几率性出现绿屏或者部分绿色的照片: 这是新版“预览.app”的bug,解决方法有两个,一个是等待升级补丁,暂时一个一个文件预览,就 ... 
- Install nginx on ubuntu
			1. Install libpcre3, libpcre3-dev2. Install zlib1g-dev3. Download nginx and unzip it4. ./configure5. ... 
- 实用工具类--第三方开源--Lazy
			下载地址 :https://github.com/ddwhan0123/Lazy 工具 描述 AnimationUtils 动画工具类 AppUtils APP相关信息工具类 AssetDatabas ... 
- 201621123014《Java程序设计》第十周学习总结
			1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 2. 书面作业 本次PTA作业题集异常 1. 常用异常 结合题集题目7-1回答 1.1 自己以前编写的代码中经常出现 ... 
- 20165210 Java第一次实验报告
			20165210 第一次实验报告 实验内容 建立目录运行简单的Java程序 建立自己学号的目录 在上个目录下建立src,bin等目录 Javac,Java的执行在学号目录下 IDEA的调试与设置断点 ... 
- 11462 Age Sort(计数排序)
			内存不够用,用计数排序可以解决问题. #include<iostream> #include<cstdio> #include<cstdlib> #include& ... 
- WC2018 即时战略
			交互题 一棵树,一开始只有 1 号点是已知的,其他的都是未知的,你可以调用函数 explore(x,y) ,其中 x 必须是已知的,函数会找到 x 到 y 路径上第二个点,并把它标成已知,求最小步数使 ... 
