支持向量机(SVM)算法应用——人脸识别

本文使用Python3.6.4环境,针对Python2.7版本的代码进行勘误,探讨了支持向量机(SVM)在人脸识别中的实现。在实现过程中遇到了关于RandomizedPCA的弃用警告,以及ValueError和DeprecationWarning等相关问题。
摘要由CSDN通过智能技术生成

环境简述:python3.6.4

根据python2.7版本代码进行勘误

Class RandomizedPCA is deprecated; RandomizedPCA was deprecated in
0.18 and will be removed in 0.20. Use PCA(svd_solver=’randomized’) instead. The new implementation DOES NOT store whiten Apply transform to get them.

ValueError: class_weight must be dict, ‘balanced’, or None, got:
‘auto’\

DeprecationWarning: imread is deprecated!
imread is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.

Code如下

# !/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Tanghong

# 在python2.x版本中要使用Python3.x的特性,可以使用__future__模块导入相应的接口,减少对当前低版本影响
# from __future__ import print_function

# 计时,程序运行时间
from time import time
# 打印程序进展时的一些信息
import logging
# 最后识别出来的人脸通过绘图打印出来
import matplotlib.pyplot as plt
# DeprecationWarning: `imread` is deprecated! `imread` is deprecated in SciPy
# 1.0.0,and will be removed in 1.2.0.
from PIL import Image
from scipy import ndimage

# 当import 一个模块比如如下模块cross_validation时,会有删除横线,表示该模块在当前版本可能已经被删除,在新版本中改为model_selection模块
# DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection
# module into which all the refactored classes and functions are moved.
# Also note that the interface of the new CV iterators are different from that of this module.
# This module will be removed in 0.20."This module will be removed in 0.20.", DeprecationWarning)
# from sklearn.cross_validation import train_test_split
from sklearn.model_selection import train_test_split
from sklearn.datasets import fetch_lfw_people
# grid_search已经被移除
  • 13
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值