{"cells":[{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\nprint(os.listdir(\"../input\"))\nfrom keras.models import Sequential\nfrom keras.models import load_model, model_from_json\nfrom keras.layers import Dense, Activation\nfrom keras.optimizers import SGD\nimport time\nfrom datetime import datetime\nfrom matplotlib import pyplot\nimport pickle\nfrom keras.models import load_model\nimport keras","execution_count":7,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"534d13c500d6a57ccc9bca7f5cb5af93bcace419"},"cell_type":"code","source":"df_train_sample = pd.read_csv(\"../input/train_sample.csv\")\ndf_train = pd.read_csv(\"../input/train.csv\", nrows=10000000) # this might take a while\n#df_test = pd.read_csv(\"../input/test.csv\")","execution_count":9,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"94c797202da65e56eeff32c1e6dbe265fb7f3c94"},"cell_type":"code","source":"df_train.head()","execution_count":10,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"afcc0527c2394d086b8d32d469615871ed1bb763"},"cell_type":"code","source":"x_train = df_train[['ip', 'app', 'os', 'channel']].values","execution_count":12,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"69ea81b735a16b4f0173e9b7ddbbf1f7e7afb860"},"cell_type":"code","source":"x_train.shape","execution_count":17,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"05f72781ac671b2d63c8f3f76efef792a0b37b82"},"cell_type":"code","source":"y_train = df_train[['is_attributed']].values","execution_count":15,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"fde5701c2a3da04d8b3e14c261f66ff48db2c67e"},"cell_type":"code","source":"y_train.shape","execution_count":18,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","collapsed":true,"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"from keras.models import Sequential\n\nmodel = Sequential()","execution_count":23,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"32b81dbbd31c151524b5ed1f26995de73695a26b"},"cell_type":"code","source":"from keras.layers import Dense\n\nmodel.add(Dense(units=64, activation='relu', input_dim=4))\nmodel.add(Dense(units=10, activation='softmax'))","execution_count":24,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"4ac8e62a188ee66356b6c06d1726e7c499983a6b"},"cell_type":"code","source":"model.compile(loss='categorical_crossentropy',\n              optimizer='sgd',\n              metrics=['accuracy'])","execution_count":25,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"fa20f8fd8fc44ddb33fda1d8213b23258c215d31"},"cell_type":"code","source":"model.compile(loss=keras.losses.categorical_crossentropy,\n              optimizer=keras.optimizers.SGD(lr=0.01, momentum=0.9, nesterov=True))","execution_count":26,"outputs":[]},{"metadata":{"trusted":true,"scrolled":true,"_uuid":"77d99e236f9b4370a9f3cd06730aa73485b8c91f"},"cell_type":"code","source":"# x_train and y_train are Numpy arrays --just like in the Scikit-Learn API.\nmodel.fit(x_train, y_train, epochs=5)","execution_count":28,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"bf312d2168c60777896fe41880ee2bbe0f67d638"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}