• Python+Spark2.0+hadoop学习笔记——Python Spark MLlib决策树回归


    机器学习领域中分类方法和回归方法是相对的,大多数的方法可以相互转换,即一般的机器学习方法如果可以分类的话,也会可以做回归预测。在本例的回归方法中,使用的评价指标是RMSE。

    第一步:导入数据库

    import sys
    from time import time
    import pandas as pd
    import matplotlib.pyplot as plt
    from pyspark import SparkConf, SparkContext
    from pyspark.mllib.tree import DecisionTree
    from pyspark.mllib.regression import LabeledPoint
    import numpy as np
    from pyspark.mllib.evaluation import RegressionMetrics
    import math

    第二步:数据准备

    def extract_label(record):
    label=(record[-1])
    return float(label)

    def convert_float(x):
    return (0 if x=="?" else float(x))

    def extract_features(record,featureEnd):
    featureSeason=[convert_float(field) for field in record[2]]
    features=[convert_float(field) for field in record[4: featureEnd-2]]
    return np.concatenate( (featureSeason, features))

    def PrepareData(sc):
    print("Data loading...")
    rawDataWithHeader = sc.textFile(Path+"data/hour.csv")
    header = rawDataWithHeader.first()
    rawData = rawDataWithHeader.filter(lambda x:x !=header)
    lines = rawData.map(lambda x: x.split(","))
    print (lines.first())
    print("The number of data:" + str(lines.count()))
    labelpointRDD = lines.map(lambda r:LabeledPoint(
    extract_label(r),
    extract_features(r,len(r) - 1)))

    print(labelpointRDD.first())
    (trainData, validationData, testData) = labelpointRDD.randomSplit([8, 1, 1])
    print("TrainData:" + str(trainData.count()) +
    "ValidationData:" + str(validationData.count()) +
    "TestData:" + str(testData.count()))
    return (trainData, validationData, testData)

    第三步:对模型进行训练

    def PredictData(sc,model):
    print("Data loading...")
    rawDataWithHeader = sc.textFile(Path+"data/hour.csv")
    header = rawDataWithHeader.first()
    rawData = rawDataWithHeader.filter(lambda x:x !=header)
    lines = rawData.map(lambda x: x.split(","))
    print("The number of data:" + str(lines.count()))
    labelpointRDD = lines.map(lambda r: LabeledPoint(
    extract_label(r),
    extract_features(r,len(r) - 1)))
    SeasonDict = { 1 : "春", 2 : "夏", 3 :"秋", 4 : "冬" }
    HoildayDict={ 0 : "非假日", 1 : "假日" }
    WeekDict = {0:"一",1:"二",2:"三",3:"四",4 :"五",5:"六",6:"日"}
    WorkDayDict={ 1 : "工作日", 0 : "非工作日" }
    WeatherDict={ 1 : "晴", 2 : "阴", 3 : "小雨", 4 : "大雨" }
    for lp in labelpointRDD.take(100):
    predict = int(model.predict(lp.features))
    label=lp.label
    features=lp.features
    result = ("True" if (label == predict) else "False")
    error = math.fabs(label - predict)
    dataDesc="Feature: "+SeasonDict[features[0]] +"季,"+
    str(features[1]) + "月," +
    str(features[2]) + "时,"+
    HoildayDict[features[3]] +","+
    "Week"+WeekDict[features[4]]+","+
    WorkDayDict[features[5]]+","+
    WeatherDict[features[6]]+","+
    str(features[7] * 41)+ "度,"+
    "Temperature" + str(features[8] * 50) + "度," +
    "Humidity" + str(features[9] * 100) + ","+
    "Wind speed" + str(features[10] * 67) +
    "Predict result:" + str(predict )+
    "Actual:" + str(label) + result +", Error:" + str(error)
    print(dataDesc)

    第四步:对模型进行评估

    def evaluateModel(model, validationData):
    score = model.predict(validationData.map(lambda p: p.features))
    scoreAndLabels=score.zip(validationData.map(lambda p: p.label))
    metrics = RegressionMetrics(scoreAndLabels)
    RMSE=metrics.rootMeanSquaredError
    return(RMSE)

    def trainEvaluateModel(trainData,validationData,
    impurityParm, maxDepthParm, maxBinsParm):
    startTime = time()
    model = DecisionTree.trainRegressor(trainData,
    categoricalFeaturesInfo={},
    impurity=impurityParm,
    maxDepth=maxDepthParm,
    maxBins=maxBinsParm)
    RMSE = evaluateModel(model, validationData)
    duration = time() - startTime
    print (" impurityParm= %s"%impurityParm+
    " maxDepthParm= %s"%maxDepthParm+
    " maxBinsParm = %d."%maxBinsParm +
    " Time=%d"%duration +
    " RMSE = %f " % RMSE )
    return (RMSE,duration, impurityParm, maxDepthParm, maxBinsParm,model)

    def evalParameter(trainData, validationData, evaparm,impurityList, maxDepthList, maxBinsList):
    metrics = [trainEvaluateModel(trainData, validationData, impurity,maxdepth, maxBins )
    for impurity in impurityList
    for maxdepth in maxDepthList
    for maxBins in maxBinsList ]
    if evaparm=="impurity":
    IndexList=impurityList[:]
    elif evaparm=="maxDepth":
    IndexList=maxDepthList[:]
    elif evaparm=="maxBins":
    IndexList=maxBinsList[:]
    df = pd.DataFrame(metrics,index=IndexList,
    columns=['RMSE', 'duration','impurityParm', 'maxDepthParm', 'maxBinsParm','model'])
    showchart(df,evaparm,'RMSE','duration',0,200 )

    def showchart(df,evalparm ,barData,lineData,yMin,yMax):
    ax = df[barData].plot(kind='bar', title =evalparm,figsize=(10,6),legend=True, fontsize=12)
    ax.set_xlabel(evalparm,fontsize=12)
    ax.set_ylim([yMin,yMax])
    ax.set_ylabel(barData,fontsize=12)
    ax2 = ax.twinx()
    ax2.plot(df[[lineData ]].values, linestyle='-', marker='o', linewidth=2.0,color='r')
    plt.show()

    def evalAllParameter(training_RDD, validation_RDD, impurityList, maxDepthList, maxBinsList):
    metrics = [trainEvaluateModel(trainData, validationData, impurity,maxdepth, maxBins )
    for impurity in impurityList
    for maxdepth in maxDepthList
    for maxBins in maxBinsList ]
    Smetrics = sorted(metrics, key=lambda k: k[0])
    bestParameter=Smetrics[0]
    print("impurity:" + str(bestParameter[2]) +
    " ,maxDepth:" + str(bestParameter[3]) +
    " ,maxBins:" + str(bestParameter[4]) +
    " ,RMSE = " + str(bestParameter[0]))
    return bestParameter[5]

    def parametersEval(training_RDD, validation_RDD):
    print("-----MaxDepth---------")
    evalParameter(training_RDD, validation_RDD,"maxDepth",
    impurityList=["variance"],
    maxDepthList =[3, 5, 10, 15, 20, 25] ,
    maxBinsList=[10])
    print("----MaxBins---------")
    evalParameter(training_RDD, validation_RDD,"maxBins",
    impurityList=["variance"],
    maxDepthList=[10],
    maxBinsList=[3, 5, 10, 50, 100, 200 ])

    第五步:Spark相关设置

    def SetLogger( sc ):
    logger = sc._jvm.org.apache.log4j
    logger.LogManager.getLogger("org"). setLevel( logger.Level.ERROR )
    logger.LogManager.getLogger("akka").setLevel( logger.Level.ERROR )
    logger.LogManager.getRootLogger().setLevel(logger.Level.ERROR)

    def SetPath(sc):
    global Path
    if sc.master[0:5]=="local" :
    Path="file:/home/jorlinlee/pythonsparkexample/PythonProject/"
    else:
    Path="hdfs://master:9000/user/jorlinlee/"

    def CreateSparkContext():
    sparkConf = SparkConf()
    .setAppName("RunDecisionTreeRegression")
    .set("spark.ui.showConsoleProgress", "false")
    sc = SparkContext(conf = sparkConf)
    print ("master="+sc.master)
    SetLogger(sc)
    SetPath(sc)
    return (sc)

    sc.stop()

    第六步:运行主程序

    if __name__ == "__main__":
    print("RunDecisionTreeRegression")
    sc=CreateSparkContext()
    print("Preparing")
    (trainData, validationData, testData) =PrepareData(sc)
    trainData.persist(); validationData.persist(); testData.persist()
    print("Testing")
    (AUC,duration, impurityParm, maxDepthParm, maxBinsParm,model)=
    trainEvaluateModel(trainData, validationData, "variance", 10, 100)
    if (len(sys.argv) == 2) and (sys.argv[1]=="-e"):
    parametersEval(trainData, validationData)
    elif (len(sys.argv) == 2) and (sys.argv[1]=="-a"):
    print("Best parameters")
    model=evalAllParameter(trainData, validationData,
    ["variance"],
    [3, 5, 10, 15, 20, 25],
    [3, 5, 10, 50, 100, 200 ])
    print("Testing")
    RMSE = evaluateModel(model, testData)
    print("RMSE:" + str(RMSE))
    print("Predict")
    PredictData(sc, model)

    结果:

    Feature: 春季,1.0月,0.0时,非假日,Week日,非工作日,晴,9.84度,Temperature14.395度,Humidity81.0,Wind speed0.0Predict result:41Actual:16.0False, Error:25.0
    Feature: 春季,1.0月,1.0时,非假日,Week日,非工作日,晴,9.02度,Temperature13.635度,Humidity80.0,Wind speed0.0Predict result:26Actual:40.0False, Error:14.0
    Feature: 春季,1.0月,2.0时,非假日,Week日,非工作日,晴,9.02度,Temperature13.635度,Humidity80.0,Wind speed0.0Predict result:25Actual:32.0False, Error:7.0
    Feature: 春季,1.0月,3.0时,非假日,Week日,非工作日,晴,9.84度,Temperature14.395度,Humidity75.0,Wind speed0.0Predict result:12Actual:13.0False, Error:1.0
    Feature: 春季,1.0月,4.0时,非假日,Week日,非工作日,晴,9.84度,Temperature14.395度,Humidity75.0,Wind speed0.0Predict result:3Actual:1.0False, Error:2.0
    Feature: 春季,1.0月,5.0时,非假日,Week日,非工作日,阴,9.84度,Temperature12.879999999999999度,Humidity75.0,Wind speed6.0032Predict result:3Actual:1.0False, Error:2.0
    Feature: 春季,1.0月,6.0时,非假日,Week日,非工作日,晴,9.02度,Temperature13.635度,Humidity80.0,Wind speed0.0Predict result:2Actual:2.0True, Error:0.0
    Feature: 春季,1.0月,7.0时,非假日,Week日,非工作日,晴,8.200000000000001度,Temperature12.879999999999999度,Humidity86.0,Wind speed0.0Predict result:15Actual:3.0False, Error:12.0
    Feature: 春季,1.0月,8.0时,非假日,Week日,非工作日,晴,9.84度,Temperature14.395度,Humidity75.0,Wind speed0.0Predict result:64Actual:8.0False, Error:56.0
    Feature: 春季,1.0月,9.0时,非假日,Week日,非工作日,晴,13.120000000000001度,Temperature17.424999999999997度,Humidity76.0,Wind speed0.0Predict result:156Actual:14.0False, Error:142.0
    Feature: 春季,1.0月,10.0时,非假日,Week日,非工作日,晴,15.58度,Temperature19.695度,Humidity76.0,Wind speed16.997899999999998Predict result:197Actual:36.0False, Error:161.0
    Feature: 春季,1.0月,11.0时,非假日,Week日,非工作日,晴,14.76度,Temperature16.665度,Humidity81.0,Wind speed19.0012Predict result:197Actual:56.0False, Error:141.0
    Feature: 春季,1.0月,12.0时,非假日,Week日,非工作日,晴,17.22度,Temperature21.21度,Humidity77.0,Wind speed19.0012Predict result:124Actual:84.0False, Error:40.0
    Feature: 春季,1.0月,13.0时,非假日,Week日,非工作日,阴,18.86度,Temperature22.725度,Humidity72.0,Wind speed19.999499999999998Predict result:205Actual:94.0False, Error:111.0
    Feature: 春季,1.0月,14.0时,非假日,Week日,非工作日,阴,18.86度,Temperature22.725度,Humidity72.0,Wind speed19.0012Predict result:205Actual:106.0False, Error:99.0
    Feature: 春季,1.0月,15.0时,非假日,Week日,非工作日,阴,18.04度,Temperature21.97度,Humidity77.0,Wind speed19.999499999999998Predict result:205Actual:110.0False, Error:95.0
    Feature: 春季,1.0月,16.0时,非假日,Week日,非工作日,阴,17.22度,Temperature21.21度,Humidity82.0,Wind speed19.999499999999998Predict result:205Actual:93.0False, Error:112.0
    Feature: 春季,1.0月,17.0时,非假日,Week日,非工作日,阴,18.04度,Temperature21.97度,Humidity82.0,Wind speed19.0012Predict result:55Actual:67.0False, Error:12.0
    Feature: 春季,1.0月,18.0时,非假日,Week日,非工作日,小雨,17.22度,Temperature21.21度,Humidity88.0,Wind speed16.997899999999998Predict result:98Actual:35.0False, Error:63.0
    Feature: 春季,1.0月,19.0时,非假日,Week日,非工作日,小雨,17.22度,Temperature21.21度,Humidity88.0,Wind speed16.997899999999998Predict result:98Actual:37.0False, Error:61.0
    Feature: 春季,1.0月,20.0时,非假日,Week日,非工作日,阴,16.400000000000002度,Temperature20.455000000000002度,Humidity87.0,Wind speed16.997899999999998Predict result:70Actual:36.0False, Error:34.0
    Feature: 春季,1.0月,21.0时,非假日,Week日,非工作日,阴,16.400000000000002度,Temperature20.455000000000002度,Humidity87.0,Wind speed12.998000000000001Predict result:70Actual:34.0False, Error:36.0
    Feature: 春季,1.0月,22.0时,非假日,Week日,非工作日,阴,16.400000000000002度,Temperature20.455000000000002度,Humidity94.0,Wind speed15.001299999999999Predict result:96Actual:28.0False, Error:68.0
    Feature: 春季,1.0月,23.0时,非假日,Week日,非工作日,阴,18.86度,Temperature22.725度,Humidity88.0,Wind speed19.999499999999998Predict result:96Actual:39.0False, Error:57.0
    Feature: 春季,1.0月,0.0时,非假日,Week一,非工作日,阴,18.86度,Temperature22.725度,Humidity88.0,Wind speed19.999499999999998Predict result:17Actual:17.0True, Error:0.0
    Feature: 春季,1.0月,1.0时,非假日,Week一,非工作日,阴,18.04度,Temperature21.97度,Humidity94.0,Wind speed16.997899999999998Predict result:17Actual:17.0True, Error:0.0
    Feature: 春季,1.0月,2.0时,非假日,Week一,非工作日,阴,17.22度,Temperature21.21度,Humidity100.0,Wind speed19.0012Predict result:9Actual:9.0True, Error:0.0
    Feature: 春季,1.0月,3.0时,非假日,Week一,非工作日,阴,18.86度,Temperature22.725度,Humidity94.0,Wind speed12.998000000000001Predict result:25Actual:6.0False, Error:19.0
    Feature: 春季,1.0月,4.0时,非假日,Week一,非工作日,阴,18.86度,Temperature22.725度,Humidity94.0,Wind speed12.998000000000001Predict result:7Actual:3.0False, Error:4.0
    Feature: 春季,1.0月,6.0时,非假日,Week一,非工作日,小雨,17.22度,Temperature21.21度,Humidity77.0,Wind speed19.999499999999998Predict result:2Actual:2.0True, Error:0.0
    Feature: 春季,1.0月,7.0时,非假日,Week一,非工作日,阴,16.400000000000002度,Temperature20.455000000000002度,Humidity76.0,Wind speed12.998000000000001Predict result:100Actual:1.0False, Error:99.0
    Feature: 春季,1.0月,8.0时,非假日,Week一,非工作日,小雨,16.400000000000002度,Temperature20.455000000000002度,Humidity71.0,Wind speed15.001299999999999Predict result:45Actual:8.0False, Error:37.0
    Feature: 春季,1.0月,9.0时,非假日,Week一,非工作日,阴,15.58度,Temperature19.695度,Humidity76.0,Wind speed15.001299999999999Predict result:100Actual:20.0False, Error:80.0
    Feature: 春季,1.0月,10.0时,非假日,Week一,非工作日,阴,14.76度,Temperature17.424999999999997度,Humidity81.0,Wind speed15.001299999999999Predict result:100Actual:53.0False, Error:47.0
    Feature: 春季,1.0月,11.0时,非假日,Week一,非工作日,阴,14.76度,Temperature16.665度,Humidity71.0,Wind speed16.997899999999998Predict result:100Actual:70.0False, Error:30.0
    Feature: 春季,1.0月,12.0时,非假日,Week一,非工作日,阴,14.76度,Temperature16.665度,Humidity66.0,Wind speed19.999499999999998Predict result:100Actual:93.0False, Error:7.0
    Feature: 春季,1.0月,13.0时,非假日,Week一,非工作日,阴,14.76度,Temperature17.424999999999997度,Humidity66.0,Wind speed8.9981Predict result:100Actual:75.0False, Error:25.0
    Feature: 春季,1.0月,14.0时,非假日,Week一,非工作日,小雨,14.76度,Temperature17.424999999999997度,Humidity76.0,Wind speed12.998000000000001Predict result:45Actual:59.0False, Error:14.0
    Feature: 春季,1.0月,15.0时,非假日,Week一,非工作日,小雨,13.940000000000001度,Temperature16.665度,Humidity81.0,Wind speed11.0014Predict result:45Actual:74.0False, Error:29.0
    Feature: 春季,1.0月,16.0时,非假日,Week一,非工作日,小雨,13.940000000000001度,Temperature16.665度,Humidity71.0,Wind speed11.0014Predict result:45Actual:76.0False, Error:31.0
    Feature: 春季,1.0月,17.0时,非假日,Week一,非工作日,晴,13.940000000000001度,Temperature16.665度,Humidity56.99999999999999,Wind speed12.998000000000001Predict result:116Actual:65.0False, Error:51.0
    Feature: 春季,1.0月,18.0时,非假日,Week一,非工作日,阴,14.76度,Temperature16.665度,Humidity46.0,Wind speed22.0028Predict result:116Actual:53.0False, Error:63.0
    Feature: 春季,1.0月,19.0时,非假日,Week一,非工作日,晴,13.120000000000001度,Temperature14.395度,Humidity42.0,Wind speed30.002599999999997Predict result:111Actual:30.0False, Error:81.0
    Feature: 春季,1.0月,20.0时,非假日,Week一,非工作日,晴,12.299999999999999度,Temperature13.635度,Humidity39.0,Wind speed23.9994Predict result:87Actual:22.0False, Error:65.0
    Feature: 春季,1.0月,21.0时,非假日,Week一,非工作日,晴,10.66度,Temperature11.365度,Humidity44.0,Wind speed22.0028Predict result:49Actual:31.0False, Error:18.0
    Feature: 春季,1.0月,22.0时,非假日,Week一,非工作日,晴,9.84度,Temperature10.605度,Humidity44.0,Wind speed19.999499999999998Predict result:34Actual:9.0False, Error:25.0
    Feature: 春季,1.0月,23.0时,非假日,Week一,非工作日,晴,9.02度,Temperature11.365度,Humidity47.0,Wind speed11.0014Predict result:22Actual:8.0False, Error:14.0
    Feature: 春季,1.0月,0.0时,非假日,Week二,工作日,晴,9.02度,Temperature9.85度,Humidity44.0,Wind speed23.9994Predict result:9Actual:5.0False, Error:4.0
    Feature: 春季,1.0月,1.0时,非假日,Week二,工作日,晴,8.200000000000001度,Temperature8.334999999999999度,Humidity44.0,Wind speed27.999299999999998Predict result:1Actual:2.0False, Error:1.0
    Feature: 春季,1.0月,4.0时,非假日,Week二,工作日,晴,6.5600000000000005度,Temperature6.819999999999999度,Humidity47.0,Wind speed26.0027Predict result:2Actual:1.0False, Error:1.0
    Feature: 春季,1.0月,5.0时,非假日,Week二,工作日,晴,6.5600000000000005度,Temperature6.819999999999999度,Humidity47.0,Wind speed19.0012Predict result:5Actual:3.0False, Error:2.0

    Feature: 春季,1.0月,6.0时,非假日,Week二,工作日,晴,5.74度,Temperature5.305度,Humidity50.0,Wind speed26.0027Predict result:30Actual:30.0True, Error:0.0
    Feature: 春季,1.0月,7.0时,非假日,Week二,工作日,晴,5.74度,Temperature6.819999999999999度,Humidity50.0,Wind speed12.998000000000001Predict result:88Actual:64.0False, Error:24.0
    Feature: 春季,1.0月,8.0时,非假日,Week二,工作日,晴,5.74度,Temperature6.0600000000000005度,Humidity50.0,Wind speed19.0012Predict result:279Actual:154.0False, Error:125.0
    Feature: 春季,1.0月,9.0时,非假日,Week二,工作日,晴,6.5600000000000005度,Temperature6.819999999999999度,Humidity43.0,Wind speed26.0027Predict result:152Actual:88.0False, Error:64.0
    Feature: 春季,1.0月,10.0时,非假日,Week二,工作日,晴,7.38度,Temperature8.334999999999999度,Humidity43.0,Wind speed16.997899999999998Predict result:71Actual:44.0False, Error:27.0
    Feature: 春季,1.0月,11.0时,非假日,Week二,工作日,晴,8.200000000000001度,Temperature9.09度,Humidity40.0,Wind speed22.0028Predict result:71Actual:51.0False, Error:20.0
    Feature: 春季,1.0月,12.0时,非假日,Week二,工作日,晴,9.02度,Temperature10.605度,Humidity35.0,Wind speed19.999499999999998Predict result:71Actual:61.0False, Error:10.0
    Feature: 春季,1.0月,13.0时,非假日,Week二,工作日,晴,9.84度,Temperature10.605度,Humidity35.0,Wind speed19.0012Predict result:71Actual:61.0False, Error:10.0
    Feature: 春季,1.0月,14.0时,非假日,Week二,工作日,晴,10.66度,Temperature12.120000000000001度,Humidity30.0,Wind speed19.0012Predict result:158Actual:77.0False, Error:81.0
    Feature: 春季,1.0月,15.0时,非假日,Week二,工作日,晴,10.66度,Temperature12.120000000000001度,Humidity30.0,Wind speed16.997899999999998Predict result:158Actual:72.0False, Error:86.0
    Feature: 春季,1.0月,16.0时,非假日,Week二,工作日,晴,10.66度,Temperature12.120000000000001度,Humidity30.0,Wind speed16.997899999999998Predict result:158Actual:76.0False, Error:82.0
    Feature: 春季,1.0月,17.0时,非假日,Week二,工作日,晴,9.84度,Temperature11.365度,Humidity30.0,Wind speed15.001299999999999Predict result:190Actual:157.0False, Error:33.0
    Feature: 春季,1.0月,18.0时,非假日,Week二,工作日,晴,9.84度,Temperature12.879999999999999度,Humidity32.0,Wind speed7.0015Predict result:190Actual:157.0False, Error:33.0
    Feature: 春季,1.0月,19.0时,非假日,Week二,工作日,晴,8.200000000000001度,Temperature12.879999999999999度,Humidity47.0,Wind speed0.0Predict result:134Actual:110.0False, Error:24.0
    Feature: 春季,1.0月,20.0时,非假日,Week二,工作日,晴,8.200000000000001度,Temperature11.365度,Humidity47.0,Wind speed7.0015Predict result:95Actual:52.0False, Error:43.0
    Feature: 春季,1.0月,21.0时,非假日,Week二,工作日,晴,7.38度,Temperature9.85度,Humidity64.0,Wind speed8.9981Predict result:48Actual:52.0False, Error:4.0
    Feature: 春季,1.0月,22.0时,非假日,Week二,工作日,晴,5.74度,Temperature7.575度,Humidity69.0,Wind speed8.9981Predict result:48Actual:20.0False, Error:28.0
    Feature: 春季,1.0月,23.0时,非假日,Week二,工作日,晴,7.38度,Temperature10.605度,Humidity55.00000000000001,Wind speed7.0015Predict result:21Actual:12.0False, Error:9.0
    Feature: 春季,1.0月,0.0时,非假日,Week三,工作日,晴,6.5600000000000005度,Temperature9.09度,Humidity55.00000000000001,Wind speed7.0015Predict result:9Actual:5.0False, Error:4.0
    Feature: 春季,1.0月,1.0时,非假日,Week三,工作日,晴,6.5600000000000005度,Temperature9.09度,Humidity59.0,Wind speed7.0015Predict result:5Actual:2.0False, Error:3.0
    Feature: 春季,1.0月,2.0时,非假日,Week三,工作日,晴,5.74度,Temperature7.575度,Humidity63.0,Wind speed8.9981Predict result:2Actual:1.0False, Error:1.0
    Feature: 春季,1.0月,4.0时,非假日,Week三,工作日,晴,5.74度,Temperature9.09度,Humidity63.0,Wind speed6.0032Predict result:2Actual:2.0True, Error:0.0
    Feature: 春季,1.0月,5.0时,非假日,Week三,工作日,晴,4.92度,Temperature7.575度,Humidity68.0,Wind speed7.0015Predict result:7Actual:4.0False, Error:3.0
    Feature: 春季,1.0月,6.0时,非假日,Week三,工作日,晴,4.92度,Temperature7.575度,Humidity74.0,Wind speed7.0015Predict result:53Actual:36.0False, Error:17.0
    Feature: 春季,1.0月,7.0时,非假日,Week三,工作日,晴,4.92度,Temperature7.575度,Humidity74.0,Wind speed8.9981Predict result:88Actual:94.0False, Error:6.0
    Feature: 春季,1.0月,8.0时,非假日,Week三,工作日,晴,5.74度,Temperature7.575度,Humidity69.0,Wind speed11.0014Predict result:279Actual:179.0False, Error:100.0
    Feature: 春季,1.0月,9.0时,非假日,Week三,工作日,晴,6.5600000000000005度,Temperature7.575度,Humidity64.0,Wind speed15.001299999999999Predict result:152Actual:100.0False, Error:52.0
    Feature: 春季,1.0月,10.0时,非假日,Week三,工作日,阴,6.5600000000000005度,Temperature6.819999999999999度,Humidity69.0,Wind speed22.0028Predict result:71Actual:42.0False, Error:29.0
    Feature: 春季,1.0月,11.0时,非假日,Week三,工作日,晴,9.02度,Temperature10.605度,Humidity51.0,Wind speed19.999499999999998Predict result:71Actual:57.0False, Error:14.0
    Feature: 春季,1.0月,12.0时,非假日,Week三,工作日,晴,9.02度,Temperature11.365度,Humidity51.0,Wind speed11.0014Predict result:71Actual:78.0False, Error:7.0
    Feature: 春季,1.0月,13.0时,非假日,Week三,工作日,晴,9.84度,Temperature11.365度,Humidity56.00000000000001,Wind speed12.998000000000001Predict result:71Actual:97.0False, Error:26.0
    Feature: 春季,1.0月,14.0时,非假日,Week三,工作日,晴,10.66度,Temperature12.879999999999999度,Humidity52.0,Wind speed15.001299999999999Predict result:158Actual:63.0False, Error:95.0
    Feature: 春季,1.0月,15.0时,非假日,Week三,工作日,晴,11.48度,Temperature13.635度,Humidity52.0,Wind speed16.997899999999998Predict result:158Actual:65.0False, Error:93.0
    Feature: 春季,1.0月,16.0时,非假日,Week三,工作日,晴,12.299999999999999度,Temperature14.395度,Humidity49.0,Wind speed16.997899999999998Predict result:158Actual:83.0False, Error:75.0
    Feature: 春季,1.0月,17.0时,非假日,Week三,工作日,晴,11.48度,Temperature13.635度,Humidity48.0,Wind speed15.001299999999999Predict result:158Actual:212.0False, Error:54.0
    Feature: 春季,1.0月,18.0时,非假日,Week三,工作日,晴,10.66度,Temperature12.879999999999999度,Humidity48.0,Wind speed12.998000000000001Predict result:158Actual:182.0False, Error:24.0
    Feature: 春季,1.0月,19.0时,非假日,Week三,工作日,晴,9.84度,Temperature12.879999999999999度,Humidity48.0,Wind speed7.0015Predict result:134Actual:112.0False, Error:22.0
    Feature: 春季,1.0月,20.0时,非假日,Week三,工作日,晴,9.84度,Temperature12.879999999999999度,Humidity48.0,Wind speed7.0015Predict result:95Actual:54.0False, Error:41.0
    Feature: 春季,1.0月,21.0时,非假日,Week三,工作日,晴,9.02度,Temperature13.635度,Humidity64.0,Wind speed0.0Predict result:95Actual:48.0False, Error:47.0
    Feature: 春季,1.0月,22.0时,非假日,Week三,工作日,晴,9.02度,Temperature12.879999999999999度,Humidity64.0,Wind speed6.0032Predict result:48Actual:35.0False, Error:13.0
    Feature: 春季,1.0月,23.0时,非假日,Week三,工作日,晴,8.200000000000001度,Temperature11.365度,Humidity69.0,Wind speed6.0032Predict result:35Actual:11.0False, Error:24.0
    Feature: 春季,1.0月,0.0时,非假日,Week四,工作日,晴,8.200000000000001度,Temperature12.879999999999999度,Humidity64.0,Wind speed0.0Predict result:17Actual:6.0False, Error:11.0
    Feature: 春季,1.0月,1.0时,非假日,Week四,工作日,晴,6.5600000000000005度,Temperature9.85度,Humidity74.0,Wind speed6.0032Predict result:5Actual:6.0False, Error:1.0
    Feature: 春季,1.0月,2.0时,非假日,Week四,工作日,晴,6.5600000000000005度,Temperature9.85度,Humidity74.0,Wind speed6.0032Predict result:2Actual:2.0True, Error:0.0
    Feature: 春季,1.0月,4.0时,非假日,Week四,工作日,晴,9.84度,Temperature11.365度,Humidity48.0,Wind speed15.001299999999999Predict result:2Actual:2.0True, Error:0.0
    Feature: 春季,1.0月,5.0时,非假日,Week四,工作日,晴,9.02度,Temperature11.365度,Humidity47.0,Wind speed11.0014Predict result:16Actual:3.0False, Error:13.0
    Feature: 春季,1.0月,6.0时,非假日,Week四,工作日,晴,8.200000000000001度,Temperature9.85度,Humidity47.0,Wind speed15.001299999999999Predict result:53Actual:33.0False, Error:20.0
    Feature: 春季,1.0月,7.0时,非假日,Week四,工作日,晴,7.38度,Temperature9.09度,Humidity43.0,Wind speed12.998000000000001Predict result:147Actual:88.0False, Error:59.0
    Feature: 春季,1.0月,8.0时,非假日,Week四,工作日,晴,8.200000000000001度,Temperature9.09度,Humidity40.0,Wind speed19.999499999999998Predict result:279Actual:195.0False, Error:84.0

  • 相关阅读:
    hdu2860 并查集模拟
    hdu 3938 Portal离线并查集
    hdu 2489 Minimal Ratio Tree (DFS枚举+MST)
    hdu 3172 并查集+map
    hdu 1829 A Bug's Life 并查集系列
    hdu 1598 find the most comfortable road
    HDU1198
    【Oracle】【17】表创建后,对表进行操作(添加字段,删除主键约束等)
    【JS】【19】使用Jquery判断是电脑或手机或微信浏览器访问
    【JS】【18】当前时间加减一天和格式化时间格式
  • 原文地址:https://www.cnblogs.com/zhuozige/p/12642314.html
Copyright © 2020-2023  润新知