环境简述: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已经被移除