"""
Loading CSV data into TensorFlow:
https://www.tensorflow.org/tutorials/load_data/numpy
"""

import pandas as pd
import numpy as np
import os
import tensorflow as tf
from utils.handler_data_path import get_data_path
import pdb

print("TensorFlow Version: {}".format(tf.__version__))

data_dir = os.path.join(get_data_path(),
                        "santander_customer_transaction_prediction")
print('[+] data_dir={}'.format(data_dir))

train_file_path = os.path.join(data_dir, "train.csv")

df = pd.read_csv(train_file_path)

split_index = int(len(df) * 0.75)

train_df = df[:split_index]
validation_df = df[split_index:]

train_examples = train_df[['var_{}'.format(i) for i in range(200)]].to_numpy()
validation_examples = validation_df[['var_{}'.format(i)
                                     for i in range(200)]].to_numpy()
train_labels = train_df['target']
Example #2
0
import os
import sys

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from IPython.display import clear_output
from six.moves import urllib

import tensorflow.compat.v2.feature_column as fc
import tensorflow as tf

from utils.handler_data_path import get_data_path

data_dir = os.path.join(get_data_path(), 'titanic')
train_path = os.path.join(data_dir, 'train.csv')
eval_path = os.path.join(data_dir, 'test.csv')

dftrain = pd.read_csv(train_path)
dfeval = pd.read_csv(eval_path)
y_train = dftrain.pop('Survived')

print(dftrain.head())

print(dftrain.describe())

print(dftrain.shape[0], dfeval.shape[0])

CATEGORICAL_COLUMNS = [
    'sex', 'n_siblings_spouses', 'parch', 'class', 'deck', 'embark_town',
Example #3
0
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Conv2D, Flatten, Dropout, MaxPooling2D
from tensorflow.keras.preprocessing.image import ImageDataGenerator

import os
import numpy as np
import matplotlib.pyplot as plt
import pdb

from utils.handler_data_path import get_data_path

print("TensorFlow Version: {}".format(tf.__version__))

AUTOTUNE = tf.data.experimental.AUTOTUNE

data_dir = os.path.join(get_data_path(), "leaf-classification")
train_dir = os.path.join(data_dir, 'train_images')
validation_dir = os.path.join(data_dir, 'validation_images')

CLASS_NAMES = [x for x in sorted(os.listdir(str(train_dir))) if x[0] != '.']
CLASS_NAMES = np.array(CLASS_NAMES)
print("Number of classes: {}".format(len(CLASS_NAMES)))

image_count = 0
for class_ in [x for x in os.listdir(train_dir) if x[0] != '.']:
    for image_ in os.listdir(os.path.join(train_dir, class_)):
        image_count += 1
print("Image count:", image_count)

BATCH_SIZE = 32
IMG_HEIGHT = 224