ionic_liquids/visualization/plots.py
def error_values(X_train,X_test,Y_train,Y_test):
    """
    Creates the two predicted values

    Input
    -----
    X_train : numpy array, the 10% of the training set data values
    X_test : numpy array, the molecular descriptors for the testing set data values 

    Y_train: numpy array, the 10% of the training set of electronic conductivity values
    Y_test: numpy array, 'true' (actual) electronic conductivity values
    
    Output
    ------
    yh : numpy array, the prediction output for training data set
    yh2 : numpy array, the prediction output for the testing data set 
    """
    #setting up parameters and variables for plotting 
    n_train = X_train.shape[0]
    n_test = X_test.shape[0]
    d = X_train.shape[1]
    hdnode = 100
    w1 = np.random.normal(0,0.001,d*hdnode).reshape((d,hdnode))
    d1 = np.zeros((d,hdnode))
    w2 = np.random.normal(0,0.001,hdnode).reshape((hdnode,1))
    d2 = np.zeros(hdnode)
    h  = np.zeros(hdnode)
    mb = 100 #minibatch size
    m = int(n_train/mb)
    batch = np.arange(m) 
    lr = 0.00020
    EP = 20000 #needed for initializing 
    ep = 0
    yh = np.zeros((n_train,1))
    yh2 = np.zeros((n_test,1))
    L_train= np.zeros(EP+1)
    L_test = np.zeros(EP+1)
    Y_train = Y_train.reshape(len(Y_train),1)
    #activation function for the hidden layer is tanh
    
    def g(A):
        return (np.tanh(A))

    def gd(A):
        return (1-np.square(np.tanh(A)))
        
    #setting up how long the epoch will run
    EP = 200
    ep = 0
    while ep < EP:
        ep += 1
        yh = g(X_train.dot(w1)).dot(w2)
        yh2 = g(X_test.dot(w1)).dot(w2)
        L_train[ep] = LA.norm(yh-Y_train.reshape(len(Y_train),1))/n_train
        L_test[ep]  = LA.norm(yh2-Y_test.reshape(len(Y_test),1))/n_test
        
        np.random.shuffle(batch)
        for i in range(m):
            st = batch[i]*mb
            ed = (batch[i]+1)*mb
            h  = g(X_train[st:ed].dot(w1))
            y = h.dot(w2)
            d2 = h.T.dot(Y_train[st:ed]-y)
            d1 = X_train[st:ed].T.dot(np.multiply((Y_train[st:ed]-y).dot(w2.T),gd(X_train[st:ed].dot(w1))))
            w2 += lr*d2
            w1 += lr*d1
    return yh, yh2

    Creates the two predicted values

    Input
    -----
    X_train : numpy array, the 10% of the training set data values
    X_test : numpy array, the molecular descriptors for the testing set data values 

    Y_train: numpy array, the 10% of the training set of electronic conductivity values
    Y_test: numpy array, 'true' (actual) electronic conductivity values
    
    Output
    ------
    yh : numpy array, the prediction output for training data set
    yh2 : numpy array, the prediction output for the testing data set 
    
Creates the two predicted values
Input

X_train : numpy array, the 10% of the training set data values
X_test : numpy array, the molecular descriptors for the testing set data values

numpy array, the 10% of the training set of electronic conductivity values
Y_test: numpy array, 'true' (actual) electronic conductivity values

Output

yh : numpy array, the prediction output for training data set
yh2 : numpy array, the prediction output for the testing data set
Creates the two predicted values Input X_train : numpy array the 10% of the training set data values X_test : numpy array the molecular descriptors for the testing set data values numpy array the 10% of the training set of electronic conductivity values Y_test : numpy array ' true ' ( actual ) electronic conductivity values Output yh : numpy array the prediction output for training data set yh2 : numpy array the prediction output for the testing data set
def error_values(X_train,X_test,Y_train,Y_test):
    n_train = X_train.shape[0]
    n_test = X_test.shape[0]
    d = X_train.shape[1]
    hdnode = 100
    w1 = np.random.normal(0,0.001,d*hdnode).reshape((d,hdnode))
    d1 = np.zeros((d,hdnode))
    w2 = np.random.normal(0,0.001,hdnode).reshape((hdnode,1))
    d2 = np.zeros(hdnode)
    h  = np.zeros(hdnode)
    mb = 100 
    m = int(n_train/mb)
    batch = np.arange(m) 
    lr = 0.00020
    EP = 20000 
    ep = 0
    yh = np.zeros((n_train,1))
    yh2 = np.zeros((n_test,1))
    L_train= np.zeros(EP+1)
    L_test = np.zeros(EP+1)
    Y_train = Y_train.reshape(len(Y_train),1)
    def g(A):
        return (np.tanh(A))
    def gd(A):
        return (1-np.square(np.tanh(A)))
    EP = 200
    ep = 0
    while ep < EP:
        ep += 1
        yh = g(X_train.dot(w1)).dot(w2)
        yh2 = g(X_test.dot(w1)).dot(w2)
        L_train[ep] = LA.norm(yh-Y_train.reshape(len(Y_train),1))/n_train
        L_test[ep]  = LA.norm(yh2-Y_test.reshape(len(Y_test),1))/n_test
        np.random.shuffle(batch)
        for i in range(m):
            st = batch[i]*mb
            ed = (batch[i]+1)*mb
            h  = g(X_train[st:ed].dot(w1))
            y = h.dot(w2)
            d2 = h.T.dot(Y_train[st:ed]-y)
            d1 = X_train[st:ed].T.dot(np.multiply((Y_train[st:ed]-y).dot(w2.T),gd(X_train[st:ed].dot(w1))))
            w2 += lr*d2
            w1 += lr*d1
    return yh, yh2
def error_values ( X_train , X_test , Y_train , Y_test ) : n_train = X_train . shape [ 0 ] n_test = X_test . shape [ 0 ] d = X_train . shape [ 1 ] hdnode = 100 w1 = np . random . normal ( 0 , 0.001 , d * hdnode ) . reshape ( ( d , hdnode ) ) d1 = np . zeros ( ( d , hdnode ) ) w2 = np . random . normal ( 0 , 0.001 , hdnode ) . reshape ( ( hdnode , 1 ) ) d2 = np . zeros ( hdnode ) h = np . zeros ( hdnode ) mb = 100 m = int ( n_train / mb ) batch = np . arange ( m ) lr = 0.00020 EP = 20000 ep = 0 yh = np . zeros ( ( n_train , 1 ) ) yh2 = np . zeros ( ( n_test , 1 ) ) L_train = np . zeros ( EP + 1 ) L_test = np . zeros ( EP + 1 ) Y_train = Y_train . reshape ( len ( Y_train ) , 1 ) def g ( A ) : return ( np . tanh ( A ) ) def gd ( A ) : return ( 1 - np . square ( np . tanh ( A ) ) ) EP = 200 ep = 0 while ep < EP : ep += 1 yh = g ( X_train . dot ( w1 ) ) . dot ( w2 ) yh2 = g ( X_test . dot ( w1 ) ) . dot ( w2 ) L_train [ ep ] = LA . norm ( yh - Y_train . reshape ( len ( Y_train ) , 1 ) ) / n_train L_test [ ep ] = LA . norm ( yh2 - Y_test . reshape ( len ( Y_test ) , 1 ) ) / n_test np . random . shuffle ( batch ) for i in range ( m ) : st = batch [ i ] * mb ed = ( batch [ i ] + 1 ) * mb h = g ( X_train [ st : ed ] . dot ( w1 ) ) y = h . dot ( w2 ) d2 = h . T . dot ( Y_train [ st : ed ] - y ) d1 = X_train [ st : ed ] . T . dot ( np . multiply ( ( Y_train [ st : ed ] - y ) . dot ( w2 . T ) , gd ( X_train [ st : ed ] . dot ( w1 ) ) ) ) w2 += lr * d2 w1 += lr * d1 return yh , yh2
Creates the two predicted values
Input
Creates the two predicted values Input
"""
    Creates the two predicted values

    Input
    -----
    X_train : numpy array, the 10% of the training set data values
    X_test : numpy array, the molecular descriptors for the testing set data values 

    Y_train: numpy array, the 10% of the training set of electronic conductivity values
    Y_test: numpy array, 'true' (actual) electronic conductivity values
    
    Output
    ------
    yh : numpy array, the prediction output for training data set
    yh2 : numpy array, the prediction output for the testing data set 
    """ #setting up parameters and variables for plotting  #minibatch size #needed for initializing  #activation function for the hidden layer is tanh #setting up how long the epoch will run
X_train
X_test
Y_train
Y_test