LeafClassification程序注释

代码地址:https://www.kaggle.com/abhmul/keras-convnet-lb-0-0052-w-visualization

sklearn.preprocessing.LabelEncoder:将标签纸统一转换至[0,n_class-1]范围内。

    LabelEncoder().fit(data):将标签fit至LabelEncoder()中

    LabelEncoder().fit(data).transform(data):转换标签

sklearn.preprocessing.StandardScaler: 标准化,均值去除,按方差比例缩放。

    StandardScaler().fit(data).transform(data)

sklearn.model_selecion.StratifiedShuffleSplit:sss=StratifiedShuffleSplit(n_splits=10,test_size=None,train_size=None, random_state=None)

    参数 n_splits是将训练数据分成train/test对的组数,可根据需要进行设置,默认为10

    参数test_size和train_size是用来设置train/test对中train和test所占的比例。例如: 
    1.提供10个数据num进行训练和测试集划分 
    2.设置train_size=0.8 test_size=0.2 
    3.train_num=num*train_size=8 test_num=num*test_size=2 
    4.即10个数据,进行划分以后8个是训练数据,2个是测试数据

     函数作用描述 
    1.其产生指定数量的独立的train/test数据集划分数据集划分成n组。 
    2.首先将样本随机打乱,然后根据设置参数划分出train/test对。 

    3.其创建的每一组划分将保证每组类比比例相同。即第一组训练数据类别比例为2:1,则后面每组类别都满足这个比例

keras.utils.to_categorical(y, num_classes=None):Converts a class vector (integers) to binary class matrix。

    eg:to_categorical(y), y由[1 2 3]→[[1 0 0],[0 1 0],[0 0 1]]

keras.preprocessing.image.py代码链接:https://github.com/keras-team/keras/blob/master/keras/preprocessing/image.py

keras.preprocessing.image.img_to_array(img, data_format=None):将图像转为三维矩阵的形式

    eg: img_to_array(x)

keras.preprocessing.image.load_img(path, grayscale=False, target_size=None, interpolation='nearest')

os.path.join('str','str',...):返回字符串相接组成的路径,自动添加路径分隔符

max_ax = max((0, 1), key=lambda i: img.size[i]):返回较大的维数,(0,1)中的一个

keras.preprocessing.image.ImageDataGenerator: a class,Generate batches of tensor image data with real-time data augmentation,the data will be looped over(in batches).

    __init__

    def flow(self, x, y=None, batch_size=32, shuffle=True, seed=None, save_to_dir=None, save_prefix='', save_format='png', subset=None):

        """Takes numpy data & label arrays, and generates batches of augmented/normalized data."""

     

class Iterator: (index_array,索引组成的indices),(batch_index:批次的索引,eg:将数据分成了5个batch,则batch_index范围是[0,4])),(_flow_index方法:按照索引生成batch的indices),

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值