{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import findspark\n", "findspark.init('/Users/ryanshin/Downloads/spark-2.3.1-bin-hadoop2.7')\n", "import pyspark\n", "sc = pyspark.SparkContext()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "root\n", " |-- PassengerId: string (nullable = true)\n", " |-- Survived: double (nullable = true)\n", " |-- Pclass: double (nullable = true)\n", " |-- Name: string (nullable = true)\n", " |-- Sex: string (nullable = true)\n", " |-- Age: integer (nullable = true)\n", " |-- SibSp: double (nullable = true)\n", " |-- Parch: double (nullable = true)\n", " |-- Ticket: string (nullable = true)\n", " |-- Fare: double (nullable = true)\n", " |-- Cabin: string (nullable = true)\n", " |-- Embarked: string (nullable = false)\n", " |-- label: double (nullable = true)\n", " |-- age_group: integer (nullable = true)\n", "\n" ] } ], "source": [ "from pyspark.sql.session import SparkSession\n", "from pyspark.sql.functions import *\n", "from pyspark.sql.types import *\n", "\n", "def age_group_func(age):\n", " return int(age / 10)\n", "age_group = udf(age_group_func, returnType=IntegerType())\n", "\n", "spark = SparkSession(sc)\n", "\n", "titanic = spark.read.option(\"header\", \"true\") \\\n", " .csv(\"/Users/ryanshin/Downloads/train.csv\") \\\n", " .withColumn(\"Survived\", col(\"Survived\").cast(\"double\")) \\\n", " .withColumn(\"label\", col(\"Survived\")) \\\n", " .withColumn(\"Pclass\", col(\"Pclass\").cast(\"double\"))\\\n", " .withColumn(\"SibSp\", col(\"SibSp\").cast(\"double\"))\\\n", " .withColumn(\"Parch\", col(\"Parch\").cast(\"double\"))\\\n", " .withColumn(\"Fare\", col(\"Fare\").cast(\"double\"))\\\n", " .withColumn(\"Age\", col(\"Age\").cast(\"int\"))\\\n", " .na.fill(\"S\", \"Embarked\") \\\n", " .na.fill(-1, \"Age\") \\\n", " .withColumn(\"age_group\", age_group(col(\"Age\")))\n", "titanic.printSchema()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+-----------+--------+------+--------------------+------+---+-----+-----+----------------+-------+-----+--------+-----+---------+\n", "|PassengerId|Survived|Pclass| Name| Sex|Age|SibSp|Parch| Ticket| Fare|Cabin|Embarked|label|age_group|\n", "+-----------+--------+------+--------------------+------+---+-----+-----+----------------+-------+-----+--------+-----+---------+\n", "| 1| 0.0| 3.0|Braund, Mr. Owen ...| male| 22| 1.0| 0.0| A/5 21171| 7.25| null| S| 0.0| 2|\n", "| 2| 1.0| 1.0|Cumings, Mrs. Joh...|female| 38| 1.0| 0.0| PC 17599|71.2833| C85| C| 1.0| 3|\n", "| 3| 1.0| 3.0|Heikkinen, Miss. ...|female| 26| 0.0| 0.0|STON/O2. 3101282| 7.925| null| S| 1.0| 2|\n", "| 4| 1.0| 1.0|Futrelle, Mrs. Ja...|female| 35| 1.0| 0.0| 113803| 53.1| C123| S| 1.0| 3|\n", "| 5| 0.0| 3.0|Allen, Mr. Willia...| male| 35| 0.0| 0.0| 373450| 8.05| null| S| 0.0| 3|\n", "| 6| 0.0| 3.0| Moran, Mr. James| male| -1| 0.0| 0.0| 330877| 8.4583| null| Q| 0.0| 0|\n", "| 7| 0.0| 1.0|McCarthy, Mr. Tim...| male| 54| 0.0| 0.0| 17463|51.8625| E46| S| 0.0| 5|\n", "| 8| 0.0| 3.0|Palsson, Master. ...| male| 2| 3.0| 1.0| 349909| 21.075| null| S| 0.0| 0|\n", "| 9| 1.0| 3.0|Johnson, Mrs. Osc...|female| 27| 0.0| 2.0| 347742|11.1333| null| S| 1.0| 2|\n", "| 10| 1.0| 2.0|Nasser, Mrs. Nich...|female| 14| 1.0| 0.0| 237736|30.0708| null| C| 1.0| 1|\n", "| 11| 1.0| 3.0|Sandstrom, Miss. ...|female| 4| 1.0| 1.0| PP 9549| 16.7| G6| S| 1.0| 0|\n", "| 12| 1.0| 1.0|Bonnell, Miss. El...|female| 58| 0.0| 0.0| 113783| 26.55| C103| S| 1.0| 5|\n", "| 13| 0.0| 3.0|Saundercock, Mr. ...| male| 20| 0.0| 0.0| A/5. 2151| 8.05| null| S| 0.0| 2|\n", "| 14| 0.0| 3.0|Andersson, Mr. An...| male| 39| 1.0| 5.0| 347082| 31.275| null| S| 0.0| 3|\n", "| 15| 0.0| 3.0|Vestrom, Miss. Hu...|female| 14| 0.0| 0.0| 350406| 7.8542| null| S| 0.0| 1|\n", "| 16| 1.0| 2.0|Hewlett, Mrs. (Ma...|female| 55| 0.0| 0.0| 248706| 16.0| null| S| 1.0| 5|\n", "| 17| 0.0| 3.0|Rice, Master. Eugene| male| 2| 4.0| 1.0| 382652| 29.125| null| Q| 0.0| 0|\n", "| 18| 1.0| 2.0|Williams, Mr. Cha...| male| -1| 0.0| 0.0| 244373| 13.0| null| S| 1.0| 0|\n", "| 19| 0.0| 3.0|Vander Planke, Mr...|female| 31| 1.0| 0.0| 345763| 18.0| null| S| 0.0| 3|\n", "| 20| 1.0| 3.0|Masselmani, Mrs. ...|female| -1| 0.0| 0.0| 2649| 7.225| null| C| 1.0| 0|\n", "+-----------+--------+------+--------------------+------+---+-----+-----+----------------+-------+-----+--------+-----+---------+\n", "only showing top 20 rows\n", "\n" ] } ], "source": [ "titanic.show()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "891" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "titanic.count()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "prediction1result areaUnderROC=0.500000\n", "prediction2result areaUnderROC=0.766873\n", "prediction1result areaUnderPR=0.383838\n", "prediction2result areaUnderPR=0.684957\n" ] } ], "source": [ "# 다 죽었다고 예측\n", "def predict1_func(dummy):\n", " return 0.0\n", "predict1 = udf(predict1_func, returnType=DoubleType())\n", " \n", "# 여자는 다 살았다고 남자는 다 죽었다고 예측\n", "def predict2_func(gender):\n", " if gender == \"female\":\n", " return 1.0\n", " else:\n", " return 0.0 \n", "predict2 = udf(predict2_func, returnType=DoubleType())\n", " \n", "# UDF 생성\n", "prediction1result = titanic.select(predict1(\"Sex\").alias(\"prediction\"), col(\"Survived\").cast(\"double\").alias(\"label\"))\n", "prediction2result = titanic.select(predict2(\"Sex\").alias(\"prediction\"), col(\"Survived\").cast(\"double\").alias(\"label\"))\n", "\n", "from pyspark.ml.evaluation import BinaryClassificationEvaluator\n", "\n", "evaluator = BinaryClassificationEvaluator()\n", "evaluator.setRawPredictionCol(\"prediction\").setLabelCol(\"label\")\n", "\n", "evaluator.setMetricName(\"areaUnderROC\")\n", "print(\"prediction1result areaUnderROC=%f\" % evaluator.evaluate(prediction1result))\n", "print(\"prediction2result areaUnderROC=%f\" % evaluator.evaluate(prediction2result))\n", "\n", "evaluator.setMetricName(\"areaUnderPR\")\n", "print(\"prediction1result areaUnderPR=%f\" % evaluator.evaluate(prediction1result))\n", "print(\"prediction2result areaUnderPR=%f\" % evaluator.evaluate(prediction2result))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* 다 죽었다고 예측시 정확도" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.6161616161616161" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "prediction1result = prediction1result.withColumn('accuracy',col('prediction')== col('label'))\n", "prediction1result = prediction1result.where(prediction1result.prediction==prediction1result.label)\n", "prediction1result.count() / float(titanic.count())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* 여자는 다 살았다고 남자는 다 죽었다고 예측시 정확도" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.7867564534231201" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "prediction2result = prediction2result.withColumn('accuracy',col('prediction')== col('label'))\n", "prediction2result = prediction2result.where(prediction2result.prediction==prediction2result.label)\n", "prediction2result.count() / float(titanic.count())" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+---------+------+-------------+---------------+---------------------------------+\n", "|age_group| Sex|sum(Survived)|count(Survived)|(sum(Survived) / count(Survived))|\n", "+---------+------+-------------+---------------+---------------------------------+\n", "| 0|female| 55.0| 83| 0.6626506024096386|\n", "| 1|female| 34.0| 45| 0.7555555555555555|\n", "| 2|female| 52.0| 72| 0.7222222222222222|\n", "| 3|female| 50.0| 60| 0.8333333333333334|\n", "| 4|female| 22.0| 32| 0.6875|\n", "| 5|female| 16.0| 18| 0.8888888888888888|\n", "| 6|female| 4.0| 4| 1.0|\n", "| 0| male| 35.0| 156| 0.22435897435897437|\n", "| 1| male| 7.0| 57| 0.12280701754385964|\n", "| 2| male| 25.0| 148| 0.16891891891891891|\n", "| 3| male| 23.0| 107| 0.21495327102803738|\n", "| 4| male| 12.0| 57| 0.21052631578947367|\n", "| 5| male| 4.0| 30| 0.13333333333333333|\n", "| 6| male| 2.0| 15| 0.13333333333333333|\n", "| 7| male| 0.0| 6| 0.0|\n", "| 8| male| 1.0| 1| 1.0|\n", "+---------+------+-------------+---------------+---------------------------------+\n", "\n" ] } ], "source": [ "titanic.withColumn(\"age_group\", age_group(col(\"Age\"))).groupBy(\"age_group\", \"Sex\") \\\n", " .agg(sum(\"Survived\"), count(\"Survived\"), sum(\"Survived\")/count(\"Survived\")) \\\n", " .orderBy(\"Sex\", \"age_group\").show()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "training_data, test_data = titanic.randomSplit([0.7, 0.3])" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "from pyspark.ml.classification import *\n", "from pyspark.ml.feature import *\n", "\n", "# Train a RandomForest model.\n", "rf = RandomForestClassifier() \\\n", " .setNumTrees(20)\n", "\n", "sex_indexer = StringIndexer().setInputCol(\"Sex\").setOutputCol(\"sex_idx\").fit(titanic)\n", "embark_indexer = StringIndexer().setInputCol(\"Embarked\").setOutputCol(\"embark_idx\").fit(titanic)\n", "\n", "assembler = VectorAssembler() \\\n", " .setInputCols([\"Pclass\", \"SibSp\", \"Parch\", \"age_group\", \"sex_idx\"]) \\\n", " .setOutputCol(\"features\")\n", "\n", "\n", "from pyspark.ml import Pipeline\n", "\n", "# Chain indexers and forest in a Pipeline.\n", "pipeline = Pipeline().setStages([sex_indexer, embark_indexer, assembler, rf])\n", "\n", "pipeline_model = pipeline.fit(training_data)\n", "\n", "prediction4result = pipeline_model.transform(test_data)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.7497701149425287\n", " \n", "0.7079536774334352\n" ] } ], "source": [ "evaluator.setMetricName(\"areaUnderROC\")\n", "print(evaluator.evaluate(prediction4result))\n", "print(\" \")\n", "evaluator.setMetricName(\"areaUnderPR\")\n", "print(evaluator.evaluate(prediction4result))" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+-----------+------+--------------------+------+---+-----+-----+----------------+-------+-----+--------+---------+\n", "|PassengerId|Pclass| Name| Sex|Age|SibSp|Parch| Ticket| Fare|Cabin|Embarked|age_group|\n", "+-----------+------+--------------------+------+---+-----+-----+----------------+-------+-----+--------+---------+\n", "| 892| 3.0| Kelly, Mr. James| male| 34| 0.0| 0.0| 330911| 7.8292| null| Q| 3|\n", "| 893| 3.0|Wilkes, Mrs. Jame...|female| 47| 1.0| 0.0| 363272| 7.0| null| S| 4|\n", "| 894| 2.0|Myles, Mr. Thomas...| male| 62| 0.0| 0.0| 240276| 9.6875| null| Q| 6|\n", "| 895| 3.0| Wirz, Mr. Albert| male| 27| 0.0| 0.0| 315154| 8.6625| null| S| 2|\n", "| 896| 3.0|Hirvonen, Mrs. Al...|female| 22| 1.0| 1.0| 3101298|12.2875| null| S| 2|\n", "| 897| 3.0|Svensson, Mr. Joh...| male| 14| 0.0| 0.0| 7538| 9.225| null| S| 1|\n", "| 898| 3.0|Connolly, Miss. Kate|female| 30| 0.0| 0.0| 330972| 7.6292| null| Q| 3|\n", "| 899| 2.0|Caldwell, Mr. Alb...| male| 26| 1.0| 1.0| 248738| 29.0| null| S| 2|\n", "| 900| 3.0|Abrahim, Mrs. Jos...|female| 18| 0.0| 0.0| 2657| 7.2292| null| C| 1|\n", "| 901| 3.0|Davies, Mr. John ...| male| 21| 2.0| 0.0| A/4 48871| 24.15| null| S| 2|\n", "| 902| 3.0| Ilieff, Mr. Ylio| male| -1| 0.0| 0.0| 349220| 7.8958| null| S| 0|\n", "| 903| 1.0|Jones, Mr. Charle...| male| 46| 0.0| 0.0| 694| 26.0| null| S| 4|\n", "| 904| 1.0|Snyder, Mrs. John...|female| 23| 1.0| 0.0| 21228|82.2667| B45| S| 2|\n", "| 905| 2.0|Howard, Mr. Benjamin| male| 63| 1.0| 0.0| 24065| 26.0| null| S| 6|\n", "| 906| 1.0|Chaffee, Mrs. Her...|female| 47| 1.0| 0.0| W.E.P. 5734| 61.175| E31| S| 4|\n", "| 907| 2.0|del Carlo, Mrs. S...|female| 24| 1.0| 0.0| SC/PARIS 2167|27.7208| null| C| 2|\n", "| 908| 2.0| Keane, Mr. Daniel| male| 35| 0.0| 0.0| 233734| 12.35| null| Q| 3|\n", "| 909| 3.0| Assaf, Mr. Gerios| male| 21| 0.0| 0.0| 2692| 7.225| null| C| 2|\n", "| 910| 3.0|Ilmakangas, Miss....|female| 27| 1.0| 0.0|STON/O2. 3101270| 7.925| null| S| 2|\n", "| 911| 3.0|\"Assaf Khalil, Mr...|female| 45| 0.0| 0.0| 2696| 7.225| null| C| 4|\n", "+-----------+------+--------------------+------+---+-----+-----+----------------+-------+-----+--------+---------+\n", "only showing top 20 rows\n", "\n" ] } ], "source": [ "titanic_test = spark.read.option(\"header\", \"true\") \\\n", " .csv(\"/Users/ryanshin/Downloads/test.csv\") \\\n", " .withColumn(\"Pclass\", col(\"Pclass\").cast(\"double\"))\\\n", " .withColumn(\"SibSp\", col(\"SibSp\").cast(\"double\"))\\\n", " .withColumn(\"Parch\", col(\"Parch\").cast(\"double\"))\\\n", " .withColumn(\"Fare\", col(\"Fare\").cast(\"double\"))\\\n", " .withColumn(\"Age\", col(\"Age\").cast(\"int\"))\\\n", " .na.fill(\"S\", \"Embarked\") \\\n", " .na.fill(-1, \"Age\") \\\n", " .withColumn(\"age_group\", age_group(col(\"Age\")))\n", "titanic_test.show()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+-----------+--------+\n", "|PassengerId|Survived|\n", "+-----------+--------+\n", "| 892| 0|\n", "| 893| 0|\n", "| 894| 0|\n", "| 895| 0|\n", "| 896| 0|\n", "| 897| 0|\n", "| 898| 0|\n", "| 899| 0|\n", "| 900| 1|\n", "| 901| 0|\n", "| 902| 0|\n", "| 903| 0|\n", "| 904| 1|\n", "| 905| 0|\n", "| 906| 1|\n", "| 907| 1|\n", "| 908| 0|\n", "| 909| 0|\n", "| 910| 1|\n", "| 911| 0|\n", "+-----------+--------+\n", "only showing top 20 rows\n", "\n" ] } ], "source": [ "result = pipeline_model.transform(titanic_test).select(col('PassengerId'), col('prediction').alias(\"Survived\").cast('int'))\n", "result.show()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "%%bash\n", "rm -rf answer" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "result.repartition(1).write.csv('answer', header='true')" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "PassengerId,Survived\n", "892,0\n", "893,0\n", "894,0\n", "895,0\n", "896,0\n", "897,0\n", "898,0\n", "899,0\n", "900,1\n", "901,0\n", "902,0\n", "903,0\n", "904,1\n", "905,0\n", "906,1\n", "907,1\n", "908,0\n", "909,0\n", "910,1\n", "911,0\n", "912,0\n", "913,1\n", "914,1\n", "915,0\n", "916,1\n", "917,0\n", "918,1\n", "919,0\n", "920,0\n", "921,0\n", "922,0\n", "923,0\n", "924,0\n", "925,0\n", "926,1\n", "927,0\n", "928,1\n", "929,0\n", "930,0\n", "931,0\n", "932,0\n", "933,0\n", "934,0\n", "935,1\n", "936,1\n", "937,0\n", "938,0\n", "939,0\n", "940,1\n", "941,0\n", "942,1\n", "943,0\n", "944,1\n", "945,1\n", "946,0\n", "947,0\n", "948,0\n", "949,0\n", "950,0\n", "951,1\n", "952,0\n", "953,0\n", "954,0\n", "955,0\n", "956,0\n", "957,1\n", "958,1\n", "959,0\n", "960,0\n", "961,1\n", "962,0\n", "963,0\n", "964,0\n", "965,0\n", "966,1\n", "967,0\n", "968,0\n", "969,1\n", "970,0\n", "971,0\n", "972,1\n", "973,0\n", "974,0\n", "975,0\n", "976,0\n", "977,0\n", "978,0\n", "979,1\n", "980,1\n", "981,1\n", "982,1\n", "983,0\n", "984,1\n", "985,0\n", "986,0\n", "987,0\n", "988,1\n", "989,0\n", "990,0\n", "991,0\n", "992,1\n", "993,0\n", "994,0\n", "995,0\n", "996,0\n", "997,0\n", "998,0\n", "999,0\n", "1000,0\n", "1001,0\n", "1002,0\n", "1003,1\n", "1004,1\n", "1005,1\n", "1006,1\n", "1007,0\n", "1008,0\n", "1009,1\n", "1010,0\n", "1011,1\n", "1012,1\n", "1013,0\n", "1014,1\n", "1015,0\n", "1016,0\n", "1017,1\n", "1018,0\n", "1019,1\n", "1020,0\n", "1021,0\n", "1022,0\n", "1023,0\n", "1024,0\n", "1025,0\n", "1026,0\n", "1027,0\n", "1028,0\n", "1029,0\n", "1030,0\n", "1031,0\n", "1032,0\n", "1033,1\n", "1034,0\n", "1035,0\n", "1036,0\n", "1037,0\n", "1038,0\n", "1039,0\n", "1040,0\n", "1041,0\n", "1042,1\n", "1043,0\n", "1044,0\n", "1045,0\n", "1046,0\n", "1047,0\n", "1048,1\n", "1049,0\n", "1050,0\n", "1051,0\n", "1052,1\n", "1053,1\n", "1054,1\n", "1055,0\n", "1056,0\n", "1057,0\n", "1058,0\n", "1059,0\n", "1060,1\n", "1061,0\n", "1062,0\n", "1063,0\n", "1064,0\n", "1065,0\n", "1066,0\n", "1067,1\n", "1068,1\n", "1069,0\n", "1070,1\n", "1071,1\n", "1072,0\n", "1073,1\n", "1074,1\n", "1075,0\n", "1076,1\n", "1077,0\n", "1078,1\n", "1079,0\n", "1080,0\n", "1081,0\n", "1082,0\n", "1083,0\n", "1084,0\n", "1085,0\n", "1086,1\n", "1087,0\n", "1088,1\n", "1089,1\n", "1090,0\n", "1091,1\n", "1092,1\n", "1093,1\n", "1094,1\n", "1095,1\n", "1096,0\n", "1097,0\n", "1098,0\n", "1099,0\n", "1100,1\n", "1101,0\n", "1102,0\n", "1103,0\n", "1104,0\n", "1105,1\n", "1106,0\n", "1107,0\n", "1108,1\n", "1109,0\n", "1110,1\n", "1111,0\n", "1112,1\n", "1113,0\n", "1114,1\n", "1115,0\n", "1116,1\n", "1117,1\n", "1118,0\n", "1119,1\n", "1120,0\n", "1121,0\n", "1122,0\n", "1123,1\n", "1124,0\n", "1125,0\n", "1126,1\n", "1127,0\n", "1128,0\n", "1129,0\n", "1130,1\n", "1131,1\n", "1132,1\n", "1133,1\n", "1134,1\n", "1135,0\n", "1136,1\n", "1137,1\n", "1138,1\n", "1139,0\n", "1140,1\n", "1141,1\n", "1142,1\n", "1143,0\n", "1144,1\n", "1145,0\n", "1146,0\n", "1147,0\n", "1148,0\n", "1149,0\n", "1150,1\n", "1151,0\n", "1152,0\n", "1153,0\n", "1154,1\n", "1155,1\n", "1156,0\n", "1157,0\n", "1158,0\n", "1159,0\n", "1160,1\n", "1161,0\n", "1162,0\n", "1163,0\n", "1164,1\n", "1165,1\n", "1166,0\n", "1167,1\n", "1168,0\n", "1169,0\n", "1170,0\n", "1171,0\n", "1172,0\n", "1173,1\n", "1174,1\n", "1175,1\n", "1176,1\n", "1177,0\n", "1178,0\n", "1179,1\n", "1180,0\n", "1181,0\n", "1182,0\n", "1183,0\n", "1184,0\n", "1185,0\n", "1186,0\n", "1187,0\n", "1188,1\n", "1189,0\n", "1190,0\n", "1191,0\n", "1192,0\n", "1193,0\n", "1194,0\n", "1195,0\n", "1196,1\n", "1197,1\n", "1198,1\n", "1199,1\n", "1200,0\n", "1201,0\n", "1202,0\n", "1203,0\n", "1204,0\n", "1205,0\n", "1206,1\n", "1207,1\n", "1208,0\n", "1209,0\n", "1210,0\n", "1211,0\n", "1212,0\n", "1213,0\n", "1214,0\n", "1215,0\n", "1216,1\n", "1217,0\n", "1218,1\n", "1219,0\n", "1220,0\n", "1221,0\n", "1222,1\n", "1223,0\n", "1224,0\n", "1225,0\n", "1226,0\n", "1227,0\n", "1228,0\n", "1229,0\n", "1230,0\n", "1231,0\n", "1232,0\n", "1233,0\n", "1234,1\n", "1235,1\n", "1236,1\n", "1237,1\n", "1238,0\n", "1239,0\n", "1240,0\n", "1241,1\n", "1242,1\n", "1243,0\n", "1244,0\n", "1245,0\n", "1246,0\n", "1247,0\n", "1248,1\n", "1249,0\n", "1250,0\n", "1251,1\n", "1252,0\n", "1253,1\n", "1254,1\n", "1255,0\n", "1256,1\n", "1257,0\n", "1258,0\n", "1259,0\n", "1260,1\n", "1261,0\n", "1262,0\n", "1263,1\n", "1264,0\n", "1265,0\n", "1266,1\n", "1267,1\n", "1268,1\n", "1269,0\n", "1270,0\n", "1271,0\n", "1272,0\n", "1273,0\n", "1274,1\n", "1275,1\n", "1276,0\n", "1277,1\n", "1278,0\n", "1279,0\n", "1280,0\n", "1281,0\n", "1282,0\n", "1283,1\n", "1284,0\n", "1285,0\n", "1286,0\n", "1287,1\n", "1288,0\n", "1289,1\n", "1290,0\n", "1291,0\n", "1292,1\n", "1293,0\n", "1294,1\n", "1295,0\n", "1296,1\n", "1297,0\n", "1298,0\n", "1299,0\n", "1300,1\n", "1301,1\n", "1302,1\n", "1303,1\n", "1304,0\n", "1305,0\n", "1306,1\n", "1307,0\n", "1308,0\n", "1309,1\n" ] } ], "source": [ "%%bash\n", "cat answer/part*" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.6" } }, "nbformat": 4, "nbformat_minor": 2 }