<jupyter_start><jupyter_text>cm.shape()<jupyter_code>cm
list(predictions)
#Bayes
from sklearn.naive_bayes import GaussianNB
gb = GaussianNB(priors=None, var_smoothing=1e-09)
gb.fit(x_train, y_train)
y_pred_g = rf.predict(x_test)
accuracy_score(y_test, y_pred_g)
#Neural network It didn't work
np.random.seed(42)  
weights = np.random.rand(19,1)  
bias = np.random.rand(1)  
lr = 0.05  
def sigmoid(a):  
    return 1/(1+np.exp(-a))
#Derivative
def sigmoid_der(a):  
    return sigmoid(a)*(1-sigmoid(a))
for epoch in range(20000):  
    inputs = x
    XW = np.dot(x, weights) + bias
    z = sigmoid(XW)
    err = z - y
    print(err.sum())
    dcost_dpred = err
    dpred_dz = sigmoid_der(z)
    z_delta = dcost_dpred * dpred_dz
    inputs = x.T
    weights -= lr * np.dot(inputs, z_delta)
    for num in z_delta:
        bias -= lr * num
#sklearn


from sklearn.metrics import mean_squared_error,confusion_matrix, precision_score, recall_score, auc,roc_curve
from sklearn import ensemble, linear_model, neighbors, svm, tree, neural_network
from sklearn.pipeline import make_pipeline
from sklearn.linear_model import Ridge
from sklearn.preprocessing import PolynomialFeatures
from sklearn import svm,model_selection, tree, linear_model, neighbors, naive_bayes, ensemble, discriminant_analysis, gaussian_process
#Machine Learning Algorithms
MLA = [
    #Ensemble Methods
    ensemble.AdaBoostClassifier(),
    ensemble.BaggingClassifier(),
    ensemble.ExtraTreesClassifier(),
    ensemble.GradientBoostingClassifier(),
    ensemble.RandomForestClassifier(),
]
MLA_columns = []
MLA_compare = pd.DataFrame(columns = MLA_columns)
row_index = 0
for alg in MLA:
    
    
    predicted = alg.fit(x_train, y_train).predict(x_test)
    MLA_name = alg.__class__.__name__
    MLA_compare.loc[row_index,'MLA Name'] = MLA_name
    MLA_compare.loc[row_index, 'MLA Train Accuracy'] = round(alg.score(x_train, y_train), 4)
    MLA_compare.loc[row_index, 'MLA Test Accuracy'] = round(alg.score(x_test, y_test), 4)
    





    row_index+=1
    
MLA_compare.sort_values(by = ['MLA Test Accuracy'], ascending = False, inplace = True)    
MLA_compare<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup