Exemple #1
0
            sigma = possible_values[j]
            svm = SVC(kernel='rbf', C=C_value, gamma=(1 / (2 * sigma**2)))
            svm.fit(X, y.ravel())
            current_score = true_score(
                Xval, yval, svm
            )  #calcula el score con los ejemplos de validacion (mayor score, mejor es el svm)
            if current_score > max_score:
                max_score = current_score
                best_svm = svm
                selected_C = C_value
                selected_Sigma = sigma

    return best_svm, selected_C, selected_Sigma


X, y = Data_Management.load_csv_svm("pokemon.csv", [feature1, feature2])
X, mu, sigma = Normalization.normalize_data_matrix(X)
X, y, trainX, trainY, validationX, validationY, testingX, testingY = Data_Management.divide_legendary_groups(
    X, y)

max_score = float("-inf")
best_svm = None

for i in range(NUM_TRIES):
    #THIS IS GIVING THE SAME RESULT, ALWAYS (MAYBE SELECT C AND SIGMA RANDOMLY)
    seed = np.random.seed()
    current_svm, C, s = eleccion_parametros_C_y_Sigma(trainX, trainY,
                                                      validationX, validationY,
                                                      mu, sigma)
    current_score = true_score(testingX, testingY, current_svm)
    draw_decisition_boundary(testingX, testingY, current_svm, current_score,
    #set the labels to non-normalized values
    figure.canvas.draw()
    labels = [item for item in plt.xticks()[0]]
    for i in range(len(labels)):
        labels[i] = int(round((labels[i] * sigma[0, 0]) + mu[0, 0], -1))
    ax.xaxis.set_ticklabels(labels)

    labels = [item for item in plt.yticks()[0]]
    for i in range(len(labels)):
        labels[i] = int(round((labels[i] * sigma[0, 1]) + mu[0, 1], -1))
    ax.yaxis.set_ticklabels(labels)
    
    plt.show()
        
        
X, y = Data_Management.load_csv_svm("pokemon.csv", ["base_egg_steps", "base_happiness"])
nX, ny, ntrainX, ntrainY, nvalidationX, nvalidationY, ntestingX, ntestingY = Data_Management.divide_legendary_groups(X, y)

#normalize
p, X = polinomial_features(X, 5)
X, mu, sigma = Normalization.normalize_data_matrix(X[:, 1:])
#ssX = Data_Management.add_column_left_of_matrix(X)

X, y, trainX, trainY, validationX, validationY, testingX, testingY = Data_Management.divide_legendary_groups(X, y)


num_entradas = np.shape(X)[1]
num_ocultas = 25
num_etiquetas = 1
true_score_max = float("-inf")
            falsePositives += 1
        elif checker[i] == 0 and y[i] == 1:
            falseNegatives += 1

    if truePositives == 0:
        return 0

    recall = (truePositives / (truePositives + falseNegatives))
    precision = (truePositives / (truePositives + falsePositives))
    score = 2 * (precision * recall / (precision + recall))

    return score


graphic_attr_names = ["capture_rate", "base_egg_steps"]
X, y = Data_Management.load_csv_svm("pokemon.csv", graphic_attr_names)
X, mu, sigma = Normalization.normalize_data_matrix(X)

X, y, trainX, trainY, validationX, validationY, testingX, testingY = Data_Management.divide_legendary_groups(
    X, y)

#-------------------------------------------------------------------------------------------------

allMaxPercent = []
allMaxElev = []
allMaxPoly = []
allMaxThetas = []

Xused = validationX
Yused = validationY
Exemple #4
0
            plot_decision_boundary(X,
                                   y,
                                   model,
                                   self.epoch_count,
                                   self.count,
                                   cmap='RdBu')
            score, acc = model.evaluate(X, y, verbose=0)
            print("error " + str(score) + ", accuracy " + str(acc))
            self.count = self.count + 1
        self.epoch_count = self.epoch_count + 1
        return self.epoch_count


if __name__ == "__main__":
    X, y = datasets.make_moons(n_samples=1000, noise=0.1, random_state=0)
    X, y = Data_Management.load_csv_svm("pokemon.csv",
                                        ['weight_kg', 'height_m'])

    X, y, trainX, trainY, validationX, validationY, testingX, testingY = Data_Management.divide_legendary_groups(
        X, y)

    y = y.ravel()
    trainY = trainY.ravel()
    # Create a directory where image will be saved
    os.makedirs("images_new", exist_ok=True)

    # Define our model object
    model = Sequential()
    # Add layers to our model
    model.add(
        Dense(units=25,
              input_shape=(2, ),