classifiers.py
def elasticnet(X_train,X_test,y_train,y_test):
    '''
    Create multiple Elasticnet classifier models on X_train and y_train with different parameters.
    Runs the models on X_test and compare the results with y_test.
    
    Args:
        X_train: A Numpy array containing the dataset for training
        X_test: A Numpy array containing the dataset for testing
        y_train: A Numpy array consisting of the target values for training
        y_test: A Numpy array consisting of the target values for testing

    Returns:
        A DataFrame with all the paramaters used and confusion matrices of each model
    '''
    df = pd.DataFrame(columns=['Alpha','Confusion Matrix'])
    rows = []
    alphas= [0.0001,0.0005,  0.0008, 0.001,0.002,0.003,0.004,0.005, 0.01]
    for al in alphas:
        regr = SGDClassifier(loss = 'log',alpha= al,penalty = 'l1',random_state=0)
        model = regr.fit(X_train, y_train)
        predicted_labels = model.predict(X_test)
        
        tn, fp, fn, tp = confusion_matrix(y_test, predicted_labels, labels=[0,1]).ravel()
        convert_matrix = [tn,fp,fn,tp]
        rows.append([al,convert_matrix])
    for i in range(len(rows)):
        df = df.append({'Alpha':rows[i][0],'Confusion Matrix':rows[i][1]}, ignore_index=True)

    return df

    Create multiple Elasticnet classifier models on X_train and y_train with different parameters.
    Runs the models on X_test and compare the results with y_test.
    
    Args:
        X_train: A Numpy array containing the dataset for training
        X_test: A Numpy array containing the dataset for testing
        y_train: A Numpy array consisting of the target values for training
        y_test: A Numpy array consisting of the target values for testing

    Returns:
        A DataFrame with all the paramaters used and confusion matrices of each model
    
Create multiple Elasticnet classifier models on X_train and y_train with different parameters.
Runs the models on X_test and compare the results with y_test.
Create multiple Elasticnet classifier models on X_train and y_train with different parameters . Runs the models on X_test and compare the results with y_test .
def elasticnet(X_train,X_test,y_train,y_test):
    df = pd.DataFrame(columns=['Alpha','Confusion Matrix'])
    rows = []
    alphas= [0.0001,0.0005,  0.0008, 0.001,0.002,0.003,0.004,0.005, 0.01]
    for al in alphas:
        regr = SGDClassifier(loss = 'log',alpha= al,penalty = 'l1',random_state=0)
        model = regr.fit(X_train, y_train)
        predicted_labels = model.predict(X_test)
        tn, fp, fn, tp = confusion_matrix(y_test, predicted_labels, labels=[0,1]).ravel()
        convert_matrix = [tn,fp,fn,tp]
        rows.append([al,convert_matrix])
    for i in range(len(rows)):
        df = df.append({'Alpha':rows[i][0],'Confusion Matrix':rows[i][1]}, ignore_index=True)
    return df
def elasticnet ( X_train , X_test , y_train , y_test ) : df = pd . DataFrame ( columns = [ 'Alpha' , 'Confusion Matrix' ] ) rows = [ ] alphas = [ 0.0001 , 0.0005 , 0.0008 , 0.001 , 0.002 , 0.003 , 0.004 , 0.005 , 0.01 ] for al in alphas : regr = SGDClassifier ( loss = 'log' , alpha = al , penalty = 'l1' , random_state = 0 ) model = regr . fit ( X_train , y_train ) predicted_labels = model . predict ( X_test ) tn , fp , fn , tp = confusion_matrix ( y_test , predicted_labels , labels = [ 0 , 1 ] ) . ravel ( ) convert_matrix = [ tn , fp , fn , tp ] rows . append ( [ al , convert_matrix ] ) for i in range ( len ( rows ) ) : df = df . append ( { 'Alpha' : rows [ i ] [ 0 ] , 'Confusion Matrix' : rows [ i ] [ 1 ] } , ignore_index = True ) return df
Create multiple Elasticnet classifier models on X_train and y_train with different parameters.
Create multiple Elasticnet classifier models on X_train and y_train with different parameters .
'''
    Create multiple Elasticnet classifier models on X_train and y_train with different parameters.
    Runs the models on X_test and compare the results with y_test.
    
    Args:
        X_train: A Numpy array containing the dataset for training
        X_test: A Numpy array containing the dataset for testing
        y_train: A Numpy array consisting of the target values for training
        y_test: A Numpy array consisting of the target values for testing

    Returns:
        A DataFrame with all the paramaters used and confusion matrices of each model
    '''
A DataFrame with all the paramaters used and confusion matrices of each model
A DataFrame with all the paramaters used and confusion matrices of each model
X_train
A Numpy array containing the dataset for training
A Numpy array containing the dataset for training
X_test
A Numpy array containing the dataset for testing
A Numpy array containing the dataset for testing
y_train
A Numpy array consisting of the target values for training
A Numpy array consisting of the target values for training
y_test
A Numpy array consisting of the target values for testing
A Numpy array consisting of the target values for testing