Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 24,
- "metadata": {
- "collapsed": true
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- "<Figure size 432x288 with 0 Axes>"
- ]
- },
- "execution_count": 0,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# <editor-fold desc=\"import libraries\">\n",
- "import copy\n",
- "from IPython.display import display, HTML\n",
- "from pprint import pprint\n",
- "from joblib import dump, load\n",
- "import tensorflow as tf\n",
- "from keras.backend.tensorflow_backend import set_session\n",
- "from sklearn.ensemble import RandomForestClassifier\n",
- "from sklearn.model_selection import train_test_split, GridSearchCV, cross_validate, cross_val_score\n",
- "from sklearn.pipeline import make_pipeline\n",
- "from sklearn.preprocessing import StandardScaler\n",
- "from sklearn.metrics import auc\n",
- "from sklearn.feature_selection import SelectFromModel\n",
- "config = tf.ConfigProto()\n",
- "config.gpu_options.allow_growth = True\n",
- "set_session(tf.Session(config=config))\n",
- "import pickle\n",
- "from keras.layers import Dense, Conv2D, BatchNormalization, Activation\n",
- "from keras.layers import AveragePooling2D, Input, Flatten\n",
- "from keras.optimizers import Adam\n",
- "from keras.callbacks import ModelCheckpoint, LearningRateScheduler\n",
- "from keras.callbacks import ReduceLROnPlateau\n",
- "from keras.preprocessing.image import ImageDataGenerator\n",
- "from keras.regularizers import l2\n",
- "from keras.models import Model\n",
- "import warnings\n",
- "warnings.simplefilter(action='ignore', category=FutureWarning)\n",
- "import time\n",
- "start_time = time.time()\n",
- "import numpy as np\n",
- "\n",
- "from keras.callbacks import Callback\n",
- "from keras import Sequential, metrics\n",
- "from idlelib import history\n",
- "from keras.utils import np_utils\n",
- "from keras.utils.vis_utils import plot_model\n",
- "from keras.datasets import mnist\n",
- "from keras.preprocessing.image import ImageDataGenerator\n",
- "from keras import initializers\n",
- "import keras\n",
- "from keras.layers import Dense, Conv2D, MaxPooling2D, Dropout, Flatten\n",
- "from keras import backend as K\n",
- "K.set_image_dim_ordering('th')\n",
- "from keras.models import load_model\n",
- "\n",
- "from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt\n",
- "import matplotlib.pyplot as plt\n",
- "np.set_printoptions(threshold=np.inf)\n",
- "import h5py\n",
- "import scipy.misc\n",
- "from sklearn.metrics import confusion_matrix, accuracy_score, make_scorer, average_precision_score, f1_score, \\\n",
- " precision_score, recall_score, precision_recall_curve\n",
- "import os,sys\n",
- "import pandas as pd\n",
- "# import seaborn as sns\n",
- "# sns.set_style(\"darkgrid\")\n",
- "from imblearn.under_sampling import RandomUnderSampler\n",
- "plt.gray()\n",
- "# </editor-fold>"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 25,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "CWD = C:\\Users\\302566153\\PycharmProjects\\dan\\fd/\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " Time V1 V2 V3 V4 V5 V6 V7 \\\n0 0.0 -1.359807 -0.072781 2.536347 1.378155 -0.338321 0.462388 0.239599 \n1 0.0 1.191857 0.266151 0.166480 0.448154 0.060018 -0.082361 -0.078803 \n2 0.0 -1.358354 -1.340163 1.773209 0.379780 -0.503198 1.800499 0.791461 \n3 0.0 -0.966272 -0.185226 1.792993 -0.863291 -0.010309 1.247203 0.237609 \n4 0.0 -1.158233 0.877737 1.548718 0.403034 -0.407193 0.095921 0.592941 \n\n V8 V9 ... V21 V22 V23 V24 V25 \\\n0 0.098698 0.363787 ... -0.018307 0.277838 -0.110474 0.066928 0.128539 \n1 0.085102 -0.255425 ... -0.225775 -0.638672 0.101288 -0.339846 0.167170 \n2 0.247676 -1.514654 ... 0.247998 0.771679 0.909412 -0.689281 -0.327642 \n3 0.377436 -1.387024 ... -0.108300 0.005274 -0.190321 -1.175575 0.647376 \n4 -0.270533 0.817739 ... -0.009431 0.798278 -0.137458 0.141267 -0.206010 \n\n V26 V27 V28 Amount Class \n0 -0.189115 0.133558 -0.021053 0.244964 0 \n1 0.125895 -0.008983 0.014724 -0.342475 0 \n2 -0.139097 -0.055353 -0.059752 1.160686 0 \n3 -0.221929 0.062723 0.061458 0.140534 0 \n4 0.502292 0.219422 0.215153 -0.073403 0 \n\n[5 rows x 31 columns]\n"
- ]
- }
- ],
- "source": [
- "CWD=(os.getcwd()+'/')\n",
- "CWD=r'C:\\Users\\302566153\\PycharmProjects\\dan\\fd/'\n",
- "print('CWD = ',CWD)\n",
- "df = pd.read_csv(CWD + \"creditcard.csv\")\n",
- "df.Time=np.floor(df.Time/3600)\n",
- "df['Amount'] = StandardScaler().fit_transform(df['Amount'].values.reshape((-1,1)))\n",
- "\n",
- "\n",
- "# print(df.dtypes)\n",
- "display((df.head()))\n",
- "# print (df.head().to_html())\n",
- "# print(df.columns)\n",
- "# print(df.columns.values)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 26,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 2",
- "language": "python",
- "name": "python2"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 2
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython2",
- "version": "2.7.6"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement