资源简介
LightBGM_Online1_87397.py
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Tue Nov 6 16:45:27 2018
cross-validation train scores:
[2.17668319 2.12016617 2.08356488 2.15369368 2.25858748]
2.1585390802643025
cross-validation test scores:
[2.40620658 2.39603569 2.47640417 2.46036761 2.57701327]
2.4632054634713403
@author: wzy
“““
import pandas as pd
import copy
import numpy as np
from math import isnan
import lightgbm as lgb
from sklearn.model_selection import KFold cross_val_score train_test_split
# from sklearn.model_selection import StratifiedKFold
from scipy import stats
# 数据导入 train:196539 test:56279
train = pd.read_csv(‘../data/train.csv‘)
test = pd.read_csv(‘../data/test.csv‘)
# 房屋朝向的汉字编码处理
train_vec = copy.deepcopy(train[‘房屋朝向‘])
train_vec_dic = list(set(train_vec))
num_train_vec_dic = len(train_vec_dic)
encode_train_vec_dic = list(np.arange(num_train_vec_dic))
dic_enc_train_vec = dict(map(lambda x y: [x y] train_vec_dic encode_train_vec_dic))
encode_train_vec = []
for i in train_vec:
temp = dic_enc_train_vec[i]
encode_train_vec.append(temp)
test_vec = copy.deepcopy(test[‘房屋朝向‘])
test_vec_dic = list(set(test_vec))
te_vec_new = []
for i in test_vec_dic:
if i not in train_vec_dic:
te_vec_new.append(i)
num_te_vec_new = len(te_vec_new)
enc_te_vec_new = list(np.arange(num_train_vec_dic num_train_vec_dic+num_te_vec_new))
dic_te_vec_new = dict(map(lambda x y: [x y] te_vec_new enc_te_vec_new))
dic_te_vec = dict(dic_enc_train_vec **dic_te_vec_new)
encode_test_vec = []
for i in test_vec:
temp = dic_te_vec[i]
encode_test_vec.append(temp)
# train.drop(‘房屋朝向‘axis=1 inplace=True)
train[‘房屋朝向1‘] = encode_train_vec
# test.drop(‘房屋朝向‘axis=1 inplace=True)
test[‘房屋朝向1‘] = encode_test_vec
del dic_enc_train_vec dic_te_vec dic_te_vec_new enc_te_vec_new encode_test_vec
del encode_train_vec encode_train_vec_dic i num_te_vec_new num_train_vec_dic
del te_vec_new temp test_vec test_vec_dic train_vec train_vec_dic
train_vec = list(copy.deepcopy(train[‘房屋朝向‘]))
diract = []
for i in train_vec:
temp = i.split()
temp = temp[0]
diract.append(temp)
Diract = []
for i in diract:
if i == ‘南‘:
temp = 0
elif i == ‘东南‘:
temp = 1
elif i == ‘东‘:
temp = 2
elif i == ‘西南‘:
temp = 3
elif i == ‘北‘:
temp = 4
elif i == ‘西‘:
temp = 5
elif i == ‘东北‘:
temp = 6
elif i == ‘西北‘:
temp = 7
Diract.append(temp)
train.drop(‘房屋朝向‘axis=1 inplace=True)
train[‘房屋朝向2‘] = Diract
del train_vec diract i temp Diract
test_vec = list(copy.deepcopy(test[‘房屋朝向‘]))
diract = []
for i in test_vec:
temp = i.split()
temp = temp[0]
diract.append(temp)
Diract = []
for i in diract:
if i == ‘南‘:
temp = 0
elif i == ‘东南‘:
temp = 1
elif i == ‘东‘:
temp = 2
elif i == ‘西南‘:
temp = 3
elif i == ‘北‘:
temp = 4
相关资源
- 9b8dee39408392b66c4a776e4e7e05ce.py
- zw_基于python的网络爬虫设计.zip
- 将文件字母小写变大写并复制到其他
- python标准库中文版.tar
- dish_recognition_SDK.py
- python电子书大全.txt
- 鱼C小甲鱼零基础入门学习Python视频课
- 小甲鱼教程Python全部源码软件包课件
- EmailBoomFinal.py
- nude.py
- wenku_test.py
- 《Python3网络爬虫开发实战》中文PDF
-
unti
tled2.py - 疯狂Python讲义习题答案.rar
- 传智播客Python就业班2018.zip
- prepro.py
- python视频教程.txt
- python网盘.txt
- Python学习路线Python课程大纲Python视频
- 实现火车票查询python.zip
- python.txt
- Violent-Python-Source.zip
- Python学习教程哈工大、嵩天.txt
- python视频资料.zip
- python从入门到精通视频全60集百度云链
- 小甲鱼零基础入门学习Python全套源码
- vgg_easy.py
- scel2txt.py
- 小甲鱼Python零基础免费全套视频教学
- 传智播客python最新视频.txt
评论
共有 条评论