# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import numpy as np
import scipy as sc
import matplotlib.pyplot as plt
import pandas as pd
from keras.layers import Dense, Dropout, Activation, Embedding, LSTM
from keras.models import Sequential
from keras.callbacks import Callback
from keras import backend as K
import tensorflow as tf

class CollectOutputAndTarget(Callback):
    def __init__(self):
        super(CollectOutputAndTarget, self).__init__()
        self.targets = []  # collect y_true batches
        self.outputs = []  # collect y_pred batches

        # the shape of these 2 variables will change according to batch shape
        # to handle the "last batch", specify `validate_shape=False`
        self.var_y_true = tf.Variable(0., validate_shape=False)
        self.var_y_pred = tf.Variable(0., validate_shape=False)

    def on_batch_end(self, batch, logs=None):
        # evaluate the variables and save them into lists
        self.targets.append(K.eval(self.var_y_true))
        self.outputs.append(K.eval(self.var_y_pred))

# build a simple model
# have to compile first for model.targets and model.outputs to be prepared
model = Sequential([Dense(5, input_shape=(10,))])
model.compile(loss='mse', optimizer='adam')

# initialize the variables and the `tf.assign` ops
cbk = CollectOutputAndTarget()
fetches = [tf.assign(cbk.var_y_true, model.targets[0], validate_shape=False),
           tf.assign(cbk.var_y_pred, model.outputs[0], validate_shape=False)]
model._function_kwargs = {'fetches': fetches}  # use `model._function_kwargs` if using `Model` instead of `Sequential`

# fit the model and check results
X = np.random.rand(10, 10)
Y = np.random.rand(10, 5)
model.fit(X, Y, batch_size=8, callbacks=[cbk])
if shuffle == 'batch':
    index_array = _batch_shuffle(index_array, batch_size)
elif shuffle:
    np.random.shuffle(index_array)

print('Index array:', repr(index_array))  # Add this line

batches = _make_batches(num_train_samples, batch_size)
# -

print(cbk)

import numpy as np
import scipy as sc
import matplotlib.pyplot as plt
import pandas as pd

data=pd.read_csv('/Users/carloswertcarvajal/Downloads/job2.csv')
#Accuracy, prec,recall, spec
acc=data.loc[:,'10']
acc=acc[acc<=1]
prec=data.loc[:,'20']
prec=prec[prec<=1]
rec=data.loc[:,'0.4']
rec=rec[rec<=1]
spe=data.loc[:,'1']
spe=spe[spe<=0.99999999999999]
print(data.loc[acc.idxmax()-1,:],acc.max())
print(data.loc[prec.idxmax()-1,:],prec.max())
print(data.loc[rec.idxmax()-1,:],rec.max())
print(data.loc[spe.idxmax()-1,:],spe.max())

print(data)



StarcoderdataJupyterScriptsDedupFiltered