关于: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 ...
随机推荐
- 手机APP和微信小程序能否取代域名?
有人说现在App是主流,手机上装几个App就可以了,以后域名的重要性会越来越低,直至App完全取代域名的域名无用论.真的是这样吗? 关于这个话题已经有很多先人前辈探讨过,这次誉名网从另外一个角度给各位 ...
- HTTP 指纹识别v0.1
// Winhttp.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <Windows.h> #include ...
- windows 10系统更新失败的解决办法
最近遇到一个问题,系统总是自动下载一个更新,看样子是个补丁吧,但是每次提醒重新启动以安装更新,但每次又安装失败,回退.就这样,下载,重启,安装失败,下载......一直循环,搞得都不敢关机了,因为这样 ...
- php中浮点型变量
$d = (0.1+0.7)*10;//$d为8 //floor函数返回不大于value的最接近的整数,舍去小数部分取整 $e = floor($d);//$e为7 为什么$e为7,而不是8 因为$d ...
- 在python3.x上安装suds 并访问webservice
suds...py3很乱.. 一开始直接使用命令行:pip install suds安装,结果报错ImportError: No module named client,然后就自然的pip insta ...
- 定义类+类实例化+属性+构造函数+匿名类型var+堆与栈+GC回收机制+值类型与引用类型
为了让编程更加清晰,把程序中的功能进行模块化划分,每个模块提供特定的功能,而且每个模块都是孤立的,这种模块化编程提供了非常大的多样性,大大增加了重用代码的机会. 面向对象编程也叫做OOP编程 简单来说 ...
- python直接赋值,浅拷贝和深拷贝
本文参考自<Python 直接赋值.浅拷贝和深度拷贝解析> 定义 直接赋值:就是对象的引用(别名) 浅拷贝(copy):拷贝父对象,不拷贝对象内部的子对象 深拷贝(deepcopy):co ...
- ural 2018 The Debut Album(dp¥)
2018. The Debut Album Time limit: 2.0 secondMemory limit: 64 MB Pop-group “Pink elephant” entered on ...
- ie-9 以下ajax无法跨域的问题。只要add:jQuery.support.cors=true;即可
if (!jQuery.support.cors && window.XDomainRequest) { var httpRegEx = /^https?:\/\//i; var ge ...
- 数据库迁移到Azure SQL Database用户无法登陆的问题
业务情景:数据库是运维迁移上去的,好像使用了一个工具叫做Microsoft Data Migration Assistant,迁移之后,我的web应用无法连接数据库. 迁移之后的数据库内有User,但 ...