def do_POST(self):
        """Handle a post request"""
        length = int(self.headers.getheader('content-length'))
        data_string = self.rfile.read(length)
        print(data_string)
        if data_string == 'predict':
            try:
                result = pd.read_csv("prediction.csv")
                result = getdata.select_columns(
                    result,
                    columns=['Date', 'HomeTeam', 'AwayTeam', 'Prediction'])
                result = result.to_html()
                result = "<div style = 'display: inline-block;'>" + result + "</div><br>"

            except:
                result = 'error'
        else:
            try:
                result = getdata.last_six(data_string)
                result = result.to_html()
                result = "<h3>" + data_string + " Last Six Games</h3><div style = 'display: inline-block;'>" + result + "</div><br><h4> WDL: Team gets +1 for win, -1 for loss</h4>"
                #result = unicode(result)
            except:
                result = 'error'
        self.wfile.write(result)
 def do_GET(self):
     """Handle a get request"""
     length = int(self.headers.getheader("content-length"))
     data_string = self.rfile.read(length)
     try:
         result = pd.read_csv("prediction.csv")
         result = getdata.select_columns(result, columns=["Date", "HomeTeam", "AwayTeam", "Prediction"])
         result = result.to_html()
     except:
         result = "error"
     self.wfile.write(result)
 def do_GET(self):
     """Handle a get request"""
     length = int(self.headers.getheader('content-length'))
     data_string = self.rfile.read(length)
     try:
         result = pd.read_csv("prediction.csv")
         result = getdata.select_columns(
             result, columns=['Date', 'HomeTeam', 'AwayTeam', 'Prediction'])
         result = result.to_html()
     except:
         result = 'error'
     self.wfile.write(result)
 def do_POST(self):
     """Handle a post request"""
     length = int(self.headers.getheader('content-length'))        
     data_string = self.rfile.read(length)
     print(data_string)
     if data_string == 'predict':
         try:
             result = pd.read_csv("prediction.csv")
             result = getdata.select_columns(result, columns=['Date','HomeTeam','AwayTeam','Prediction'])
             result = result.to_html()
             result = "<div style = 'display: inline-block;'>"+result+"</div><br>"
             
         except:
             result = 'error'
     else:
         try:
             result = getdata.last_six(data_string)
             result = result.to_html()
             result = "<h3>"+data_string+" Last Six Games</h3><div style = 'display: inline-block;'>"+result+"</div><br><h4> WDL: Team gets +1 for win, -1 for loss</h4>"
             #result = unicode(result)
         except:
             result = 'error'
     self.wfile.write(result)
from sklearn.ensemble import AdaBoostClassifier

import getdata

def encode_target(df, target_column):
    df_mod = df.copy()
    targets = df_mod[target_column].unique()
    map_to_int = {name: n for n, name in enumerate(targets)}
    df_mod["Target"] = df_mod[target_column].replace(map_to_int)
    return (df_mod, targets)


df = pd.read_csv("last6model.csv", index_col=0)
testdf = pd.read_csv("futuretestmodel.csv")

testdf1 = getdata.select_columns(testdf, ['HWDL', 'HGS', 'HGA', 'HRC', 'AWDL', 'AGS', 'AGA', 'ARC', 
            'H2hWDL', 'H2hGS', 'H2hGA', 'H2hRC'])
            
testbigdf = getdata.select_columns(df, ['HWDL', 'HGS', 'HGA', 'HRC', 'AWDL', 'AGS', 'AGA', 'ARC', 
            'H2hWDL', 'H2hGS', 'H2hGA', 'H2hRC'])

features = ['HWDL', 'HGS', 'HGA', 'HRC', 'AWDL', 'AGS', 'AGA', 'ARC', 
            'H2hWDL', 'H2hGS', 'H2hGA', 'H2hRC']
df, targets = encode_target(df, "FTR")
y = df["Target"]
X = df[features]


dt = AdaBoostClassifier(algorithm='SAMME.R', base_estimator=None,
          learning_rate=0.5, n_estimators=50, random_state=None)
dt.fit(X, y)
Beispiel #6
0
features = ['HWDL', 'HGS', 'HGA', 'HRC', 'AWDL', 'AGS', 'AGA', 'ARC', 
            'H2hWDL', 'H2hGS', 'H2hGA', 'H2hRC']
df, targets = encode_target(df, "FTR")
y = df["Target"]
X = df[features]


dt = AdaBoostClassifier(algorithm='SAMME.R', base_estimator=None,
          learning_rate=0.5, n_estimators=50, random_state=None)
dt.fit(X, y)

scores = cross_val_score(dt, X, y, cv=10)


testdf1 = getdata.select_columns(modeldf, ['HWDL', 'HGS', 'HGA', 'HRC', 'AWDL', 
                                          'AGS', 'AGA', 'ARC', 'H2hWDL', 
                                          'H2hGS', 'H2hGA', 'H2hRC'])

pred = dt.predict(testdf1)

pred1 = pd.DataFrame(data=pred, columns=["Pred"])

#newrow = pd.concat([modeldf, pred1], axis=1)

#newrow = decode_target(newrow)





Beispiel #7
0
import getdata


def encode_target(df, target_column):
    df_mod = df.copy()
    targets = df_mod[target_column].unique()
    map_to_int = {name: n for n, name in enumerate(targets)}
    df_mod["Target"] = df_mod[target_column].replace(map_to_int)
    return (df_mod, targets)


df = pd.read_csv("last6model.csv", index_col=0)
testdf = pd.read_csv("futuretestmodel.csv")

testdf1 = getdata.select_columns(testdf, [
    'HWDL', 'HGS', 'HGA', 'HRC', 'AWDL', 'AGS', 'AGA', 'ARC', 'H2hWDL',
    'H2hGS', 'H2hGA', 'H2hRC'
])

testbigdf = getdata.select_columns(df, [
    'HWDL', 'HGS', 'HGA', 'HRC', 'AWDL', 'AGS', 'AGA', 'ARC', 'H2hWDL',
    'H2hGS', 'H2hGA', 'H2hRC'
])

features = [
    'HWDL', 'HGS', 'HGA', 'HRC', 'AWDL', 'AGS', 'AGA', 'ARC', 'H2hWDL',
    'H2hGS', 'H2hGA', 'H2hRC'
]
df, targets = encode_target(df, "FTR")
y = df["Target"]
X = df[features]