Ejemplo n.º 1
0
def predict():
    print("Enter Team A Id")
    teamId = input()
    while (len(teamsDF[teamsDF["Team_Id"] == int(teamId)]) == 0):
        print("Please Enter valid Team Id")
        teamId = input()
    print("Enter Team B Id")
    opponentId = input()
    while (len(teamsDF[teamsDF["Team_Id"] == int(opponentId)]) == 0):
        print("Please Enter valid Team Id")
        opponentId = input()
    print("Which team won the toss?Enter Id")
    tossWon = input()
    while ((tossWon != teamId) & (tossWon != opponentId)):
        print("Please Enter valid Team Id. %s or %s" % (teamId, opponentId))
        tossWon = input()
    print("Which team bat first?Enter Id")
    batFirst = input()
    while ((batFirst != teamId) & (batFirst != opponentId)):
        print("Please Enter valid Team Id. %s or %s" % (teamId, opponentId))
        batFirst = input()
    px = d.generatePredictData(int(teamId), int(opponentId), int(tossWon),
                               int(batFirst))
    px = px.drop(['Match_Id'], 1)
    px = px.drop(['Match_Won'], 1)

    px = preprocessing.scale(px)

    lin_svm = svm.LinearSVC()
    lin_svm.fit(X_train, y_train)
    pred = lin_svm.predict(px)
    if (pred[0] == 1):
        print("Team A Wins")
    else:
        print("Team B Wins")
Ejemplo n.º 2
0
def predict(aa, bb, cc, dd):
    teamsDF = pd.read_csv('../data/Team.csv')
    matchesTeamsDF = pd.read_csv("../data/gen/match_team.csv")
    data = matchesTeamsDF.drop(['Match_Id'], 1)
    data = data.drop(['Unnamed: 0'], 1)
    X = data.drop(['Match_Won'], 1)
    Y = data['Match_Won']
    # print(X)
    # print(Y)
    X = preprocessing.scale(X)
    #print(X)
    X_train, X_test, y_train, y_test = model_selection.train_test_split(X, Y, test_size=0.25)

    print(aa, bb, cc, dd)
    # print("Enter Team A Id")
    '''teamId = aa
    while(len(teamsDF[teamsDF["Team_Id"] == int(teamId)]) == 0):
        print("Please Enter valid Team Id")
        teamId = aa
    #print("Enter Team B Id")
    opponentId = bb
    while(len(teamsDF[teamsDF["Team_Id"] == int(opponentId)]) == 0):
        print("Please Enter valid Team Id")
        opponentId = bb
    #print("Which team won the toss?Enter Id")
    tossWon = cc
    while((tossWon != teamId) & (tossWon != opponentId)):
        print("Please Enter valid Team Id. %s or %s" % (teamId, opponentId))
        tossWon = cc
    #print("Which team bat first?Enter Id")
    batFirst = dd
    while((batFirst != teamId) & (batFirst != opponentId)):
        print("Please Enter valid Team Id. %s or %s" % (teamId, opponentId))
        batFirst = dd'''
    teamId = aa
    opponentId = bb
    tossWon = cc
    batFirst = dd
    px = d.generatePredictData(int(teamId),int(opponentId), int(tossWon), int(batFirst))
    #print(px)
    px = px.drop(['Match_Id'], 1)
    px = px.drop(['Match_Won'], 1)
    #print(px)
    px = preprocessing.scale(px)
    #print(px)
    lin_svm = svm.LinearSVC()
    lin_svm=lin_svm.fit(X_train, y_train)
    #print(lin_svm)
    pred = lin_svm.predict(px)
    print(pred[0])
    print(pred)
    x=pred
    # return A, B
    if (x == 1):
        print("A")
        return "A wins"
    else:
        print("B")
        return "B wins"
Ejemplo n.º 3
0
def predict(aa, bb, cc, dd):

    print(aa, bb, cc, dd)
    #print("Enter Team A Id")
    '''teamId = aa
    while(len(teamsDF[teamsDF["Team_Id"] == int(teamId)]) == 0):
        print("Please Enter valid Team Id")
        teamId = aa
    #print("Enter Team B Id")
    opponentId = bb
    while(len(teamsDF[teamsDF["Team_Id"] == int(opponentId)]) == 0):
        print("Please Enter valid Team Id")
        opponentId = bb
    #print("Which team won the toss?Enter Id")
    tossWon = cc
    while((tossWon != teamId) & (tossWon != opponentId)):
        print("Please Enter valid Team Id. %s or %s" % (teamId, opponentId))
        tossWon = cc
    #print("Which team bat first?Enter Id")
    batFirst = dd
    while((batFirst != teamId) & (batFirst != opponentId)):
        print("Please Enter valid Team Id. %s or %s" % (teamId, opponentId))
        batFirst = dd'''
    px = d.generatePredictData(int(aa), int(bb), int(cc), int(dd))
    # print(px)
    px = px.drop(['Match_Id'], 1)
    px = px.drop(['Match_Won'], 1)
    # print(px)
    px = preprocessing.scale(px)
    # print(px)
    lin_svm = svm.LinearSVC()
    lin_svm.fit(X_train, y_train)
    pred = lin_svm.predict(px)
    # return A, B
    if (pred[0] == 1):
        #print("A")
        return "A wins"
    else:
        #print("B")
        return "B wins"
Ejemplo n.º 4
0
def predict(aa, bb, cc, dd):
    import pandas as pd
    import numpy as np
    import sklearn
    from sklearn import preprocessing, model_selection, svm, neighbors
    from sklearn.linear_model import LinearRegression
    from sklearn.ensemble import RandomForestClassifier
    from sklearn.naive_bayes import GaussianNB
    import data as d

    teamsDF = pd.read_csv('../data/Team.csv')
    matchesTeamsDF = pd.read_csv("../data/gen/match_team.csv")
    data = matchesTeamsDF.drop(['Match_Id'], 1)
    data = data.drop(['Unnamed: 0'], 1)
    X = data.drop(['Match_Won'], 1)
    Y = data['Match_Won']
    # print(X)
    # print(Y)
    X = preprocessing.scale(X)
    X_train, X_test, y_train, y_test = model_selection.train_test_split(
        X, Y, test_size=0.25)

    print(aa, bb, cc, dd)
    # print("Enter Team A Id")
    '''teamId = aa
    while(len(teamsDF[teamsDF["Team_Id"] == int(teamId)]) == 0):
        print("Please Enter valid Team Id")
        teamId = aa
    #print("Enter Team B Id")
    opponentId = bb
    while(len(teamsDF[teamsDF["Team_Id"] == int(opponentId)]) == 0):
        print("Please Enter valid Team Id")
        opponentId = bb
    #print("Which team won the toss?Enter Id")
    tossWon = cc
    while((tossWon != teamId) & (tossWon != opponentId)):
        print("Please Enter valid Team Id. %s or %s" % (teamId, opponentId))
        tossWon = cc
    #print("Which team bat first?Enter Id")
    batFirst = dd
    while((batFirst != teamId) & (batFirst != opponentId)):
        print("Please Enter valid Team Id. %s or %s" % (teamId, opponentId))
        batFirst = dd'''
    px = d.generatePredictData(int(aa), int(bb), int(cc), int(dd))
    print(px)
    px = px.drop(['Match_Id'], 1)
    px = px.drop(['Match_Won'], 1)
    print(px)
    px = preprocessing.scale(px)
    print(px)
    '''svc_svm = svm.SVC()
    svc_svm.fit(X_train,y_train)
    pred=svc_svm.predict(px)
    print(pred)'''

    lin_svm = svm.LinearSVC()
    lin_svm.fit(X_train, y_train)
    pred = lin_svm.predict(px)
    print(pred)
    # return A, B
    x = pred
    if (x == 1):
        print("A")
        return "A"
    else:
        print("B")
        return "B"