old_scripts/alt_learnme.py
def learning_curves(X, Y, alg1, alg2, alg3, CV, csv_name):
    """
    
    Given training data, iteratively runs some ML algorithms (currently, this
    is nearest neighbor, linear, and support vector methods), varying the
    training set size for each prediction category: reactor type, cooling
    time, enrichment, and burnup

    Parameters 
    ---------- 
    
    X : dataframe that includes all training data
    Y : series with labels for training data
    alg1 : optimized learner 1
    alg2 : optimized learner 2
    alg3 : optimized learner 3
    CV : cross-validation generator
    csv_name : string containing the train set, nuc subset, and parameter being 
               predicted for naming purposes

    Returns
    -------
    *learning_curve.csv : csv file with learning curve results for each 
                          prediction category

    """    
    
    # Note: I'm trying to avoid loops here so the code is inelegant

    trainset_frac = np.array( [0.1, 0.2, 0.3, 0.4, 0.5, 0.55, 0.6, 0.65, 
                               0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0] )
    col_names = ['AbsTrainSize', 'TrainScore', 'CV-Score']
    tsze = 'AbsTrainSize'
    tscr = 'TrainScore'
    cscr = 'CV-Score'

    # dtree
    tsize, train, cv = learning_curve(alg1, X, Y, train_sizes=trainset_frac, 
                                      cv=CV, shuffle=True)
    train_mean = np.mean(train, axis=1)
    cv_mean = np.mean(cv, axis=1)
    df1 = pd.DataFrame({tsze : tsize, tscr : train_mean, cscr : cv_mean}, 
                        index=trainset_frac)
    df1['Algorithm'] = 'dtree'

    # xtree
    tsize, train, cv = learning_curve(alg2, X, Y, train_sizes=trainset_frac, 
                                      cv=CV, shuffle=True)
    train_mean = np.mean(train, axis=1)
    cv_mean = np.mean(cv, axis=1)
    df2 = pd.DataFrame({tsze : tsize, tscr : train_mean, cscr : cv_mean}, 
                        index=trainset_frac)
    df2['Algorithm'] = 'xtree'
    
    # bayes
    tsize, train, cv = learning_curve(alg3, X, Y, train_sizes=trainset_frac, 
                                      cv=CV, shuffle=True)
    train_mean = np.mean(train, axis=1)
    cv_mean = np.mean(cv, axis=1)
    df3 = pd.DataFrame({tsze : tsize, tscr : train_mean, cscr : cv_mean}, 
                        index=trainset_frac)
    df3['Algorithm'] = 'bayes'

    lc_data = pd.concat([df1, df2, df3])
    lc_data.index.name = 'TrainSizeFrac'
    lc_data.to_csv(csv_name + '_learning_curve.csv')
    return

    
    Given training data, iteratively runs some ML algorithms (currently, this
    is nearest neighbor, linear, and support vector methods), varying the
    training set size for each prediction category: reactor type, cooling
    time, enrichment, and burnup

    Parameters 
    ---------- 
    
    X : dataframe that includes all training data
    Y : series with labels for training data
    alg1 : optimized learner 1
    alg2 : optimized learner 2
    alg3 : optimized learner 3
    CV : cross-validation generator
    csv_name : string containing the train set, nuc subset, and parameter being 
               predicted for naming purposes

    Returns
    -------
    *learning_curve.csv : csv file with learning curve results for each 
                          prediction category

    
Given training data, iteratively runs some ML algorithms (currently, this
is nearest neighbor, linear, and support vector methods), varying the
training set size for each prediction category: reactor type, cooling
time, enrichment, and burnup
Given training data iteratively runs some ML algorithms ( currently this is nearest neighbor linear and support vector methods ) varying the training set size for each prediction category : reactor type cooling time enrichment and burnup
def learning_curves(X, Y, alg1, alg2, alg3, CV, csv_name):
    trainset_frac = np.array( [0.1, 0.2, 0.3, 0.4, 0.5, 0.55, 0.6, 0.65, 
                               0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0] )
    col_names = ['AbsTrainSize', 'TrainScore', 'CV-Score']
    tsze = 'AbsTrainSize'
    tscr = 'TrainScore'
    cscr = 'CV-Score'
    tsize, train, cv = learning_curve(alg1, X, Y, train_sizes=trainset_frac, 
                                      cv=CV, shuffle=True)
    train_mean = np.mean(train, axis=1)
    cv_mean = np.mean(cv, axis=1)
    df1 = pd.DataFrame({tsze : tsize, tscr : train_mean, cscr : cv_mean}, 
                        index=trainset_frac)
    df1['Algorithm'] = 'dtree'
    tsize, train, cv = learning_curve(alg2, X, Y, train_sizes=trainset_frac, 
                                      cv=CV, shuffle=True)
    train_mean = np.mean(train, axis=1)
    cv_mean = np.mean(cv, axis=1)
    df2 = pd.DataFrame({tsze : tsize, tscr : train_mean, cscr : cv_mean}, 
                        index=trainset_frac)
    df2['Algorithm'] = 'xtree'
    tsize, train, cv = learning_curve(alg3, X, Y, train_sizes=trainset_frac, 
                                      cv=CV, shuffle=True)
    train_mean = np.mean(train, axis=1)
    cv_mean = np.mean(cv, axis=1)
    df3 = pd.DataFrame({tsze : tsize, tscr : train_mean, cscr : cv_mean}, 
                        index=trainset_frac)
    df3['Algorithm'] = 'bayes'
    lc_data = pd.concat([df1, df2, df3])
    lc_data.index.name = 'TrainSizeFrac'
    lc_data.to_csv(csv_name + '_learning_curve.csv')
    return
def learning_curves ( X , Y , alg1 , alg2 , alg3 , CV , csv_name ) : trainset_frac = np . array ( [ 0.1 , 0.2 , 0.3 , 0.4 , 0.5 , 0.55 , 0.6 , 0.65 , 0.7 , 0.75 , 0.8 , 0.85 , 0.9 , 0.95 , 1.0 ] ) col_names = [ 'AbsTrainSize' , 'TrainScore' , 'CV-Score' ] tsze = 'AbsTrainSize' tscr = 'TrainScore' cscr = 'CV-Score' tsize , train , cv = learning_curve ( alg1 , X , Y , train_sizes = trainset_frac , cv = CV , shuffle = True ) train_mean = np . mean ( train , axis = 1 ) cv_mean = np . mean ( cv , axis = 1 ) df1 = pd . DataFrame ( { tsze : tsize , tscr : train_mean , cscr : cv_mean } , index = trainset_frac ) df1 [ 'Algorithm' ] = 'dtree' tsize , train , cv = learning_curve ( alg2 , X , Y , train_sizes = trainset_frac , cv = CV , shuffle = True ) train_mean = np . mean ( train , axis = 1 ) cv_mean = np . mean ( cv , axis = 1 ) df2 = pd . DataFrame ( { tsze : tsize , tscr : train_mean , cscr : cv_mean } , index = trainset_frac ) df2 [ 'Algorithm' ] = 'xtree' tsize , train , cv = learning_curve ( alg3 , X , Y , train_sizes = trainset_frac , cv = CV , shuffle = True ) train_mean = np . mean ( train , axis = 1 ) cv_mean = np . mean ( cv , axis = 1 ) df3 = pd . DataFrame ( { tsze : tsize , tscr : train_mean , cscr : cv_mean } , index = trainset_frac ) df3 [ 'Algorithm' ] = 'bayes' lc_data = pd . concat ( [ df1 , df2 , df3 ] ) lc_data . index . name = 'TrainSizeFrac' lc_data . to_csv ( csv_name + '_learning_curve.csv' ) return
Given training data, iteratively runs some ML algorithms (currently, this
is nearest neighbor, linear, and support vector methods), varying the
training set size for each prediction category: reactor type, cooling
time, enrichment, and burnup
Given training data iteratively runs some ML algorithms ( currently this is nearest neighbor linear and support vector methods ) varying the training set size for each prediction category : reactor type cooling time enrichment and burnup
"""
    
    Given training data, iteratively runs some ML algorithms (currently, this
    is nearest neighbor, linear, and support vector methods), varying the
    training set size for each prediction category: reactor type, cooling
    time, enrichment, and burnup

    Parameters 
    ---------- 
    
    X : dataframe that includes all training data
    Y : series with labels for training data
    alg1 : optimized learner 1
    alg2 : optimized learner 2
    alg3 : optimized learner 3
    CV : cross-validation generator
    csv_name : string containing the train set, nuc subset, and parameter being 
               predicted for naming purposes

    Returns
    -------
    *learning_curve.csv : csv file with learning curve results for each 
                          prediction category

    """ # Note: I'm trying to avoid loops here so the code is inelegant # dtree # xtree # bayes
X
None
Y
None
alg1
None
alg2
None
alg3
None
CV
None
csv_name
predicted for naming purposes
predicted for naming purposes
Returns
None
*learning_curve.csv
None