资源简介
该例程是针对阿里天气大数据预测,并进行无人机航路规划。使用了sklearn的决策树方法
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Fri Jan 12 17:05:46 2018
@author: Administrator
“““
import pyodbc
import sys
import csv
import numpy
import pandas as pd
import time
import sklearn.neural_network as nn
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.tree import DecisionTreeRegressor
#from sklearn.ensemble import AdaBoostRegressor
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestRegressor
from sklearn.decomposition import PCA
from sklearn.feature_selection import SelectFromModel
from sklearn.svm import LinearSVC
from sklearn.feature_selection import SelectKBest
from sklearn.feature_selection import chi2
import xgboost as xgb
from sklearn.metrics import confusion_matrix mean_squared_error r2_score
import xgboost as xgb
def CSVDataRead(dhm):
Data = numpy.zeros((548421));
date_id = d;
hour = h;
model = m;
str_date_id = str(date_id);
str_hour = str(hour);
str_model = str(model);
filename = r‘\training_d‘+str_date_id+‘_h‘+str_hour+‘_m‘+str_model+‘.csv‘;
path = r‘C:\Users\Administrator\Desktop\OptimalPath\Training_d‘ + str_date_id + r‘\Training_d‘ + \
str_date_id + ‘_h‘ + str_hour + filename;
ff = open(path“r“encoding=“utf-8“);
reader = csv.reader(ffdelimiter=‘‘)
i=0;
for row in reader:
r = i//421;
c = i%421;
Data[r][c] = float(row[5]);
i = i+1;
#print(row)
print(‘Done‘);
return Data;
def CSVTrainingSetRead(dh):
date_id = d;
hour = h;
str_date_id = str(date_id);
str_hour = str(hour);
datalist = [[0 for i in range(10)] for j in range(230708)];
for m in range(10):
model = m+1;
str_model = str(model);
if d<=3:
filename = r‘\training_d‘+str_date_id+‘_h‘+str_hour+‘_m‘+str_model+‘.csv‘;
path = r‘C:\Users\Administrator\Desktop\OptimalPath\training_d‘ + str_date_id + r‘\training_d‘ + \
str_date_id + ‘_h‘ + str_hour + filename;
ff = open(path“r“encoding=“utf-8“);
reader = csv.reader(ffdelimiter=‘‘)
else:
filename = r‘\training_d‘+str_date_id+‘_h‘+str_hour+‘_m‘+str_model+‘.csv‘;
path = r‘G:\TrainingData\training_d‘ + str_date_id + r‘\training_d‘ + \
str_date_id + ‘_h‘ + str_hour + filename;
ff = open(path“r“encoding=“utf-8“);
reader = csv.reader(ffdelimiter=‘‘)
i=0;
#datalist = numpy.array([[0 for i in range(13)] for j in range(230708)]);
for row in reader:
#r = i//421;
#c = i%421;
#datalist[i][0] = float(d);
#datalist[i][0] = float(h);
#datalist[i][2] = float(r+1);
#datalist[i][3] = float(c+1);
#datalist[i][1] = float(r+1)/548;
- 上一篇:python实现图像的混沌加密解密
- 下一篇:Xie-Beni评价m=2
相关资源
- python实现SGBM图像匹配算法
- python实现灰度直方图均衡化
- scrapy_qunar_one
- Python学习全系列教程永久可用
- python简明教程.chm
- 抽奖大转盘python的图形化界面
- 双边滤波器实验报告及代码python
- python +MYSQL+HTML实现21蛋糕网上商城
- Python-直播答题助手自动检测出题搜索
- OpenCV入门教程+OpenCV官方教程中文版
- Python 串口工具源码+.exe文件
- Python开发的全栈股票系统.zip
- Python操作Excel表格并将其中部分数据写
- python书籍 PDF
- 利用python绘制散点图
- python+labview+No1.vi
- 老男孩python项目实战
- python源码制作whl文件.rar
- python3.5可用的scipy
- PYTHON3 经典50案例.pptx
- 计算机科学导论-python.pdf
- python模拟鼠标点击屏幕
- windows鼠标自动点击py脚本
- 鱼c小甲鱼零基础学python全套课后题和
- Python 练习题100道
- Practical Programming 2nd Edition
- wxPython Application Development Cookbook
- python 3.6
- Python 3.5.2 中文文档 互联网唯一CHM版本
- python3.5.2.chm官方文档
评论
共有 条评论