Data Science Asked on March 3, 2021
I am using machine learnig to measure probability for the outcome of tennis matches. If the winer is 1 that means that p1 won otherwise p2 won. in Columns LG, SVC, RF and NN there are probaiblities from the models. I am wondering why the NN probability is almost always really different. Should I substract the NN value from 100 and if yes, why?
#LOGISTIC REGRESSION
clf_A = LogisticRegression(penalty='none', random_state=420, solver='sag')
m1 = RFECV(clf_A,scoring='accuracy')
m1.fit(X_train,y_train)
df_test['accuracy'][0] = round(m1.score(X_test,y_test)*100,2)
df_output['LG'] = m1.predict_proba(X_test)
df_output['LG'] = round(df_output['LG']*100,2)
#SVC
clf_B.fit(X_train,y_train)
df_test['accuracy'][1] = round(clf_B.score(X_test,y_test)*100,2)
df_output['SVC'] = clf_B.predict_proba(X_test)
df_output['SVC'] = round(df_output['SVC']*100,2)
#RANDOM FOREST
clf_C = RandomForestClassifier(criterion='gini',min_samples_leaf=3,min_samples_split=20)
m3 = RFECV(clf_C,scoring='accuracy')
m3.fit(X_train,y_train)
df_test['accuracy'][2] = round(m3.score(X_test,y_test)*100,2)
df_output['RF'] = m3.predict_proba(X_test)
df_output['RF'] = round(df_output['RF']*100,2)
#NEURAL NETWORK
network = models.Sequential()
network.add(layers.Dense(units=64, activation='relu', input_shape=(len(X_train.columns),)))
network.add(layers.Dense(units=32, activation='relu'))
network.add(layers.Dense(units=1, activation='sigmoid'))
network.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
es = EarlyStopping(monitor='val_loss', mode='min', verbose=0, patience=500)
mc = ModelCheckpoint('/content/best_model.h5', monitor='val_loss', mode='min', verbose=0, save_best_only=True)
history = network.fit(X_train, y_train,
epochs=1000, verbose=0, batch_size=512,
validation_data=(X_test, y_test), callbacks=[es, mc])
saved_model = load_model('/content/best_model.h5')
df_output['NN'] = saved_model.predict(X_test)
df_output['NN'] = round(df_output['NN']*100,2)
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP