コード例 #1
0
     yTrainRegistered = yRegistered[train]
     
     XTest = X[test]
     yTestCasual = yCasual[test]
     yTestRegistered = yRegistered[test]
 
     clfCasual = ExtraTreesRegressor()
     # selectorCasual = SelectKBest(score_func=f_regression,k=20)
     # print [1+zero_based_index for zero_based_index in list(selectorCasual.get_support(indices=True))]
     clfRegistered = ExtraTreesRegressor()
     modelCasualETR = clfCasual.fit(XTrain, yTrainCasual)
     modelRegisteredETR = clfRegistered.fit(XTrain, yTrainRegistered)
     
     predictionsCasual = clfCasual.predict(XTest)
     actualCasual = yCasual[test]
     scoresCasualExtraTreesRegression.append(evaluation.rmsle(actualCasual, predictionsCasual))
     
     predictionsRegistered = clfRegistered.predict(XTest)
     actualRegistered = yRegistered[test]
     scoresRegisteredExtraTreesRegression.append(evaluation.rmsle(actualRegistered, predictionsRegistered))
     
     predictionsTotal = np.sum([predictionsCasual, predictionsRegistered], axis=0)
     actualTotal = np.sum([yTestCasual, yTestRegistered], axis=0)
     
     currentScore = evaluation.rmsle(actualTotal, predictionsTotal)
     scoresTotalExtraTreesRegression.append(evaluation.rmsle(actualTotal, predictionsTotal))
     if currentScore == min(scoresTotalExtraTreesRegression):
         mdlExtraTreesRegressorCasual = modelCasualETR
         mdlExtraTreesRegressorRegistered = modelRegisteredETR
         
     clfAdaBoostCasual = RandomForestRegressor()
コード例 #2
0
        XTest = X[test]
        yTestCasual = yCasual[test]
        yTestRegistered = yRegistered[test]

        clfCasual = ExtraTreesRegressor()
        # selectorCasual = SelectKBest(score_func=f_regression,k=20)
        # print [1+zero_based_index for zero_based_index in list(selectorCasual.get_support(indices=True))]
        clfRegistered = ExtraTreesRegressor()
        modelCasualETR = clfCasual.fit(XTrain, yTrainCasual)
        modelRegisteredETR = clfRegistered.fit(XTrain, yTrainRegistered)

        predictionsCasual = clfCasual.predict(XTest)
        actualCasual = yCasual[test]
        scoresCasualExtraTreesRegression.append(
            evaluation.rmsle(actualCasual, predictionsCasual))

        predictionsRegistered = clfRegistered.predict(XTest)
        actualRegistered = yRegistered[test]
        scoresRegisteredExtraTreesRegression.append(
            evaluation.rmsle(actualRegistered, predictionsRegistered))

        predictionsTotal = np.sum([predictionsCasual, predictionsRegistered],
                                  axis=0)
        actualTotal = np.sum([yTestCasual, yTestRegistered], axis=0)

        currentScore = evaluation.rmsle(actualTotal, predictionsTotal)
        scoresTotalExtraTreesRegression.append(
            evaluation.rmsle(actualTotal, predictionsTotal))
        if currentScore == min(scoresTotalExtraTreesRegression):
            mdlExtraTreesRegressorCasual = modelCasualETR
コード例 #3
0
 kf = KFold(len(X), n_folds=10)
 for train, test in kf:
     XTrain = X[train]
     yTrainCasual = yCasual[train]
     yTrainRegistered = yRegistered[train]
     
     XTest = X[test]
     yTestCasual = yCasual[test]
     yTestRegistered = yRegistered[test]
     
     model1 = BernoulliRBM(n_components=80)
     model1.fit(XTrain)
     weights_1 = model1.components_
     XTrain_stage1 = XTrain.dot(weights_1.T)
     
     model2 = BernoulliRBM(n_components=40)
     model2.fit(XTrain_stage1)
     weights_2 = model2.components_
     XTrain_stage2 = XTrain_stage1.dot(weights_2.T)
     
     #perform linear regression
     regrCasual = linear_model.LinearRegression()
     regrCasual.fit(XTrain_stage2, yTrainCasual)
     
     regrRegistered = linear_model.LinearRegression()
     regrRegistered.fit(XTrain_stage2, yTrainRegistered)
     
     predictionsCasual = regrCasual.predict(XTrain_stage2)
     score = evaluation.rmsle(yTrainCasual, predictionsCasual)
     print score
     
コード例 #4
0
    kf = KFold(len(X), n_folds=10)
    for train, test in kf:
        XTrain = X[train]
        yTrainCasual = yCasual[train]
        yTrainRegistered = yRegistered[train]

        XTest = X[test]
        yTestCasual = yCasual[test]
        yTestRegistered = yRegistered[test]

        model1 = BernoulliRBM(n_components=80)
        model1.fit(XTrain)
        weights_1 = model1.components_
        XTrain_stage1 = XTrain.dot(weights_1.T)

        model2 = BernoulliRBM(n_components=40)
        model2.fit(XTrain_stage1)
        weights_2 = model2.components_
        XTrain_stage2 = XTrain_stage1.dot(weights_2.T)

        #perform linear regression
        regrCasual = linear_model.LinearRegression()
        regrCasual.fit(XTrain_stage2, yTrainCasual)

        regrRegistered = linear_model.LinearRegression()
        regrRegistered.fit(XTrain_stage2, yTrainRegistered)

        predictionsCasual = regrCasual.predict(XTrain_stage2)
        score = evaluation.rmsle(yTrainCasual, predictionsCasual)
        print score