Dataset Viewer (First 5GB)
Auto-converted to Parquet
Search is not available for this dataset
text
stringlengths
1.06k
99.5M
id
stringlengths
23
24
file_path
stringclasses
44 values
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Thanks for taking the time to review my submission. \n", "\n", "The following is a copy of the notebook which I submitted to the ZeeMee Mini-Hackathon competition, The model had an accuracy of .936 on the test data and a score of .949 on the training data. The model itself had gotten third place for accuracy, however it did not rank for the analysis, because I ran out of time. I have cleaned up some of the cells but have otherwise left the code intact. My notes will seem a bit critical of my entrys shortcomings, this is because I am looking specifically for areas of improvement, the success of my model wasn't lost on me.\n", "\n", "\n", "The purpose of this is mostly to demonstrate my thought process when aproaching these sorts of challenges.\n", "\n", "I chose a random forest model to predict the outcomes for two simple reasons. The first is that I have a fair bit of practice with random forests and would be able to troubleshoot any issues that arose and refine the model to get the best outcome. The second reason is the time limit, since I have 6 hours to work on this I wanted to make sure I was able to deliver a complete final product.\n", "\n", "If the competition were to go for longer I would be tempted to use either a nueral net, as those can produce increadible accuracy if you train it right, or a support vector machine since I've wanted to get some practice with one of those to broaden my skillset. However, in a production enviorment there are two other models I would have perfered for use: a decision tree or a perceptron model. Both the decision tree and the perceptron model have one perticular area that they work very well in: explainability. Both models could be deconstructed for answer further questions, instead of determining what the likelyhood of a perticular student enrolling in college, why not find what perticular area of study would prove the greatest impact of their success (ex: 'by taking on one more extra corricular activity you increase the likelihood of being excepted to school by 12%')." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "The cell below was copied directly from the MatrixDS page for the event" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "ZeeMee Mini-Hackathon by MatrixDS\n", "\n", "Get started by fork lifting this project! (Green button in upper right). Then just build an R or Python tool. Make sure if you are on a team, just use one project and add your other team members!\n", "\n", "ZeeMee is a fast growing silicon valley startup that has a social network for high school students looking for colleges. Students use the ZeeMee platform, through Android and iOS apps, to connect with others who are interested in the same colleges.\n", "\n", "The goal of this competition is to use data collected about the students behavior on the zeemee platform to predict if they will enroll in a specific college. The dataset contains 19 features which are described here.\n", "\n", " college: The college of interest that a particular student is following\n", " public_profie_enabled: If the student has made their zeemee profile public\n", " going: If the student has stated (in a non-binding way) on the zeemee app that they are going to the college\n", " interested: If the student has stated they are interested in the college on the zeemee app\n", " start_term: Which term the student is projected to begin class\n", " cohort_year: Which year the student is projected to begin class\n", " created_by_csv: If the students zeemee account associated to the college as part of a batch upload\n", " last_login: Number of days since the last login\n", " schools_followed: Number of schools followed on the zeemee platform\n", " high_school: Which high school the student attends\n", " transfer_status: If the student is transferring from another college\n", " roomate_match_quiz: If the student filled out a ZeeMee provided quiz to match with a roomate at the college of interest\n", " chat_messages_sent: Number of messages sent\n", " chat_viewed: Number of chats viewed\n", " videos_liked: Number of videos liked\n", " videos_viewed: Number of videos viewed\n", " videos_viewed_unique: Number of unique videos viewed\n", " offical_videos: Number of videos produced by the college of interest\n", " engaged: If the student is engaged with the college on the zeemee app\n", " final_funnel_stage: What stage in the enrolment process did the student end\n", "\n", "The goal of your model is to predict final_funnel_stage. The funnel is a series of steps that a student moves through on their way to actually showing up to class. The stages are thought of in the following progression:\n", "\n", " Inquired: Expressed interest in the college on the zeemee app\n", " Applied: Filled out some part of an application from the college\n", " Application_Complete: Completed an application from the college\n", " Accepted: Accepted by the college\n", " Deposited: Paid a deposit to the college\n", " Enrolled: Enrolled in class at the college\n", "\n", "The prediction of interest for this competition is to focus on identifying students that enroll (funnel stage Enrolled or Deposited). This is a binary prediction, either the student does or does not enroll. Use the two csv files in the data folder to build your model. There is a training data file and a test data file.\n", "\n", "----\n", "\n", "Grading\n", "\n", "You will be graded on two areas each consisting of a possible 5 points.\n", "\n", "First the average accuracy of your predictions on the testing data. Average accuracy is defined as the arithmetic average of accuracy for both classes of enrolled students and non-enrolled students. Predictions should be added to the zeemee_test.csv file. The best accuracy will receive all 5 points and other submissions will receive a relative portion of points to the best performer.\n", "\n", "Second you must submit an exploration of important features for your prediction model. The explanation of features and feature engineering will receive a subjective score from a panel from ZeeMee and MatrixDS. This score will be out of a possible 5 points. Submissions can be in the format of a notebook or rmarkdown file.\n", "\n", "Total scores for the two areas will be added and the individual and teams with the highest talley will receive the cash and interview prizes.\n", "\n", "----\n", "\n", "Submission. You will submit your solution using a public MatrixDS project at the end of the hackathon. We will grade the predictions that you append to the zeemee_test.csv file and any feature explaining documents in the analysis folder in your public project. Please represent your predictions as a numeric/binary value 0 (wont enroll) or 1 (will enroll) in the submission file. The submission form will be provided on the day of the competition." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Part 1:\n", "Exploritory Data Analysis" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "train_data = pd.read_csv(\"../input/zeemee-micro-competition-data/zeemee_train.csv\")\n", "test_data = pd.read_csv(\"../input/zeemee-micro-competition-data/zeemee_test.csv\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['college', 'public_profile_enabled', 'going', 'interested',\n", " 'start_term', 'cohort_year', 'created_by_csv', 'last_login',\n", " 'schools_followed', 'high_school', 'transfer_status',\n", " 'roommate_match_quiz', 'chat_messages_sent', 'chat_viewed',\n", " 'videos_liked', 'videos_viewed', 'videos_viewed_unique',\n", " 'total_official_videos', 'engaged', 'final_funnel_stage'],\n", " dtype='object')" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_data.columns" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>cohort_year</th>\n", " <th>last_login</th>\n", " <th>schools_followed</th>\n", " <th>chat_messages_sent</th>\n", " <th>chat_viewed</th>\n", " <th>videos_liked</th>\n", " <th>videos_viewed</th>\n", " <th>videos_viewed_unique</th>\n", " <th>total_official_videos</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>count</th>\n", " <td>18837.000000</td>\n", " <td>18835.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " </tr>\n", " <tr>\n", " <th>mean</th>\n", " <td>2018.999151</td>\n", " <td>238.596337</td>\n", " <td>4.189998</td>\n", " <td>1.878696</td>\n", " <td>12.122950</td>\n", " <td>0.046823</td>\n", " <td>23.389287</td>\n", " <td>5.700855</td>\n", " <td>134.600467</td>\n", " </tr>\n", " <tr>\n", " <th>std</th>\n", " <td>0.034165</td>\n", " <td>175.468761</td>\n", " <td>5.393513</td>\n", " <td>15.565363</td>\n", " <td>52.655026</td>\n", " <td>0.619321</td>\n", " <td>108.900462</td>\n", " <td>15.855868</td>\n", " <td>156.893356</td>\n", " </tr>\n", " <tr>\n", " <th>min</th>\n", " <td>2017.000000</td>\n", " <td>13.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " </tr>\n", " <tr>\n", " <th>25%</th>\n", " <td>2019.000000</td>\n", " <td>130.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>42.000000</td>\n", " </tr>\n", " <tr>\n", " <th>50%</th>\n", " <td>2019.000000</td>\n", " <td>226.000000</td>\n", " <td>2.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>56.000000</td>\n", " </tr>\n", " <tr>\n", " <th>75%</th>\n", " <td>2019.000000</td>\n", " <td>299.000000</td>\n", " <td>5.000000</td>\n", " <td>0.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>11.000000</td>\n", " <td>4.000000</td>\n", " <td>180.000000</td>\n", " </tr>\n", " <tr>\n", " <th>max</th>\n", " <td>2019.000000</td>\n", " <td>1549.000000</td>\n", " <td>214.000000</td>\n", " <td>1307.000000</td>\n", " <td>1735.000000</td>\n", " <td>23.000000</td>\n", " <td>4857.000000</td>\n", " <td>527.000000</td>\n", " <td>637.000000</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " cohort_year last_login schools_followed chat_messages_sent \\\n", "count 18837.000000 18835.000000 18837.000000 18837.000000 \n", "mean 2018.999151 238.596337 4.189998 1.878696 \n", "std 0.034165 175.468761 5.393513 15.565363 \n", "min 2017.000000 13.000000 1.000000 0.000000 \n", "25% 2019.000000 130.000000 1.000000 0.000000 \n", "50% 2019.000000 226.000000 2.000000 0.000000 \n", "75% 2019.000000 299.000000 5.000000 0.000000 \n", "max 2019.000000 1549.000000 214.000000 1307.000000 \n", "\n", " chat_viewed videos_liked videos_viewed videos_viewed_unique \\\n", "count 18837.000000 18837.000000 18837.000000 18837.000000 \n", "mean 12.122950 0.046823 23.389287 5.700855 \n", "std 52.655026 0.619321 108.900462 15.855868 \n", "min 0.000000 0.000000 0.000000 0.000000 \n", "25% 0.000000 0.000000 0.000000 0.000000 \n", "50% 0.000000 0.000000 0.000000 0.000000 \n", "75% 1.000000 0.000000 11.000000 4.000000 \n", "max 1735.000000 23.000000 4857.000000 527.000000 \n", "\n", " total_official_videos \n", "count 18837.000000 \n", "mean 134.600467 \n", "std 156.893356 \n", "min 0.000000 \n", "25% 42.000000 \n", "50% 56.000000 \n", "75% 180.000000 \n", "max 637.000000 " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_data.describe()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>Unnamed: 0</th>\n", " <th>cohort_year</th>\n", " <th>last_login</th>\n", " <th>schools_followed</th>\n", " <th>chat_messages_sent</th>\n", " <th>chat_viewed</th>\n", " <th>videos_liked</th>\n", " <th>videos_viewed</th>\n", " <th>videos_viewed_unique</th>\n", " <th>total_official_videos</th>\n", " <th>final_funnel_stage</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>count</th>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " <td>4708.000000</td>\n", " </tr>\n", " <tr>\n", " <th>mean</th>\n", " <td>2353.500000</td>\n", " <td>2018.999788</td>\n", " <td>240.499575</td>\n", " <td>4.185429</td>\n", " <td>1.715378</td>\n", " <td>12.027188</td>\n", " <td>0.078802</td>\n", " <td>21.987893</td>\n", " <td>5.497876</td>\n", " <td>135.199873</td>\n", " <td>0.094095</td>\n", " </tr>\n", " <tr>\n", " <th>std</th>\n", " <td>1359.226864</td>\n", " <td>0.014574</td>\n", " <td>175.813489</td>\n", " <td>4.833825</td>\n", " <td>12.405056</td>\n", " <td>51.903815</td>\n", " <td>1.395900</td>\n", " <td>88.157586</td>\n", " <td>14.461945</td>\n", " <td>157.497762</td>\n", " <td>0.291992</td>\n", " </tr>\n", " <tr>\n", " <th>min</th>\n", " <td>0.000000</td>\n", " <td>2018.000000</td>\n", " <td>0.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " </tr>\n", " <tr>\n", " <th>25%</th>\n", " <td>1176.750000</td>\n", " <td>2019.000000</td>\n", " <td>131.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>42.000000</td>\n", " <td>0.000000</td>\n", " </tr>\n", " <tr>\n", " <th>50%</th>\n", " <td>2353.500000</td>\n", " <td>2019.000000</td>\n", " <td>229.000000</td>\n", " <td>2.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>56.000000</td>\n", " <td>0.000000</td>\n", " </tr>\n", " <tr>\n", " <th>75%</th>\n", " <td>3530.250000</td>\n", " <td>2019.000000</td>\n", " <td>299.000000</td>\n", " <td>5.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>10.000000</td>\n", " <td>4.000000</td>\n", " <td>180.000000</td>\n", " <td>0.000000</td>\n", " </tr>\n", " <tr>\n", " <th>max</th>\n", " <td>4707.000000</td>\n", " <td>2019.000000</td>\n", " <td>1480.000000</td>\n", " <td>91.000000</td>\n", " <td>414.000000</td>\n", " <td>866.000000</td>\n", " <td>68.000000</td>\n", " <td>2996.000000</td>\n", " <td>197.000000</td>\n", " <td>637.000000</td>\n", " <td>1.000000</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Unnamed: 0 cohort_year last_login schools_followed \\\n", "count 4708.000000 4708.000000 4708.000000 4708.000000 \n", "mean 2353.500000 2018.999788 240.499575 4.185429 \n", "std 1359.226864 0.014574 175.813489 4.833825 \n", "min 0.000000 2018.000000 0.000000 1.000000 \n", "25% 1176.750000 2019.000000 131.000000 1.000000 \n", "50% 2353.500000 2019.000000 229.000000 2.000000 \n", "75% 3530.250000 2019.000000 299.000000 5.000000 \n", "max 4707.000000 2019.000000 1480.000000 91.000000 \n", "\n", " chat_messages_sent chat_viewed videos_liked videos_viewed \\\n", "count 4708.000000 4708.000000 4708.000000 4708.000000 \n", "mean 1.715378 12.027188 0.078802 21.987893 \n", "std 12.405056 51.903815 1.395900 88.157586 \n", "min 0.000000 0.000000 0.000000 0.000000 \n", "25% 0.000000 0.000000 0.000000 0.000000 \n", "50% 0.000000 0.000000 0.000000 0.000000 \n", "75% 0.000000 0.000000 0.000000 10.000000 \n", "max 414.000000 866.000000 68.000000 2996.000000 \n", "\n", " videos_viewed_unique total_official_videos final_funnel_stage \n", "count 4708.000000 4708.000000 4708.000000 \n", "mean 5.497876 135.199873 0.094095 \n", "std 14.461945 157.497762 0.291992 \n", "min 0.000000 0.000000 0.000000 \n", "25% 0.000000 42.000000 0.000000 \n", "50% 0.000000 56.000000 0.000000 \n", "75% 4.000000 180.000000 0.000000 \n", "max 197.000000 637.000000 1.000000 " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test_data.describe()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>college</th>\n", " <th>public_profile_enabled</th>\n", " <th>going</th>\n", " <th>interested</th>\n", " <th>start_term</th>\n", " <th>cohort_year</th>\n", " <th>created_by_csv</th>\n", " <th>last_login</th>\n", " <th>schools_followed</th>\n", " <th>high_school</th>\n", " <th>transfer_status</th>\n", " <th>roommate_match_quiz</th>\n", " <th>chat_messages_sent</th>\n", " <th>chat_viewed</th>\n", " <th>videos_liked</th>\n", " <th>videos_viewed</th>\n", " <th>videos_viewed_unique</th>\n", " <th>total_official_videos</th>\n", " <th>engaged</th>\n", " <th>final_funnel_stage</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>college1</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1549.0</td>\n", " <td>2</td>\n", " <td>unknown</td>\n", " <td>False</td>\n", " <td>False</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>127</td>\n", " <td>False</td>\n", " <td>Inquired</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>college2</td>\n", " <td>False</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1482.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>False</td>\n", " <td>False</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>42</td>\n", " <td>False</td>\n", " <td>Inquired</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>college2</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1403.0</td>\n", " <td>3</td>\n", " <td>other</td>\n", " <td>False</td>\n", " <td>False</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>42</td>\n", " <td>False</td>\n", " <td>Inquired</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>college4</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1403.0</td>\n", " <td>3</td>\n", " <td>other</td>\n", " <td>False</td>\n", " <td>False</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>42</td>\n", " <td>False</td>\n", " <td>Inquired</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>694.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>False</td>\n", " <td>False</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>23</td>\n", " <td>False</td>\n", " <td>Inquired</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " college public_profile_enabled going interested start_term \\\n", "0 college1 True undecided True fall \n", "1 college2 False undecided True fall \n", "2 college2 True undecided True fall \n", "3 college4 True undecided True fall \n", "4 college3 True undecided True fall \n", "\n", " cohort_year created_by_csv last_login schools_followed high_school \\\n", "0 2019 False 1549.0 2 unknown \n", "1 2019 False 1482.0 1 unknown \n", "2 2019 False 1403.0 3 other \n", "3 2019 False 1403.0 3 other \n", "4 2019 False 694.0 1 unknown \n", "\n", " transfer_status roommate_match_quiz chat_messages_sent chat_viewed \\\n", "0 False False 0 0 \n", "1 False False 0 0 \n", "2 False False 0 0 \n", "3 False False 0 0 \n", "4 False False 0 0 \n", "\n", " videos_liked videos_viewed videos_viewed_unique total_official_videos \\\n", "0 0 0 0 127 \n", "1 0 0 0 42 \n", "2 0 0 0 42 \n", "3 0 0 0 42 \n", "4 0 0 0 23 \n", "\n", " engaged final_funnel_stage \n", "0 False Inquired \n", "1 False Inquired \n", "2 False Inquired \n", "3 False Inquired \n", "4 False Inquired " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_data.head()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(18837, 20)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_data.shape" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "college: \n" ] }, { "data": { "text/plain": [ "array(['college1', 'college2', 'college4', 'college3', 'college5',\n", " 'college7', 'college6', 'college8'], dtype=object)" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "public profile enabled: \n" ] }, { "data": { "text/plain": [ "array([ True, False])" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "going: \n" ] }, { "data": { "text/plain": [ "array(['undecided', 'going', 'notgoing'], dtype=object)" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "interested: \n" ] }, { "data": { "text/plain": [ "array([ True, False])" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "start term: \n" ] }, { "data": { "text/plain": [ "array(['fall', 'spring', 'summer'], dtype=object)" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "cohort year: \n" ] }, { "data": { "text/plain": [ "array([2019, 2017, 2018])" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "created by csv: \n" ] }, { "data": { "text/plain": [ "array([False, True])" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "schools followed: \n" ] }, { "data": { "text/plain": [ "array([ 2, 1, 3, 5, 6, 9, 10, 4, 17, 13, 68, 24, 21,\n", " 11, 7, 15, 16, 19, 12, 8, 29, 32, 33, 14, 18, 25,\n", " 22, 41, 20, 37, 27, 52, 26, 23, 84, 30, 40, 83, 39,\n", " 46, 28, 214, 42, 45, 35, 31, 67, 96, 78, 38, 66, 47,\n", " 157, 87])" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "high school: \n" ] }, { "data": { "text/plain": [ "array(['unknown', 'other', 'hs1', 'hs2', 'hs3', 'hs5', 'hs6', 'hs7',\n", " 'hs8', 'hs9', 'hs10', 'hs11', 'hs12', 'hs13', 'hs4', 'hs14',\n", " 'hs15', 'hs16', 'hs17', 'hs18', 'hs19', 'hs20', 'hs21', 'hs22',\n", " 'hs23'], dtype=object)" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "transfer status: \n" ] }, { "data": { "text/plain": [ "array([False, True])" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "roommate match quiz: \n" ] }, { "data": { "text/plain": [ "array([False, True])" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "engaged: \n" ] }, { "data": { "text/plain": [ "array([False, True])" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "final funnel stage: \n" ] }, { "data": { "text/plain": [ "array(['Inquired', 'Applied', 'Accepted', 'Deposited',\n", " 'Application_Complete', 'Enrolled'], dtype=object)" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "##This section is so that I can view the types of data being used for each catagory and look for missing values\n", "##some sections have been commented out as the output is lengthy and not frequently useful to view\n", "\n", "print(\"college: \")\n", "display(train_data.college.unique())\n", "print(\"\\n\\npublic profile enabled: \")\n", "display(train_data.public_profile_enabled.unique())\n", "print(\"\\n\\ngoing: \")\n", "display(train_data.going.unique())\n", "print(\"\\n\\ninterested: \")\n", "display(train_data.interested.unique())\n", "print(\"\\n\\nstart term: \")\n", "display(train_data.start_term.unique())\n", "print(\"\\n\\ncohort year: \")\n", "display(train_data.cohort_year.unique())\n", "print(\"\\n\\ncreated by csv: \")\n", "display(train_data.created_by_csv.unique())\n", "#print(\"\\n\\nlast login: \") \n", "#display(train_data.last_login.unique()) ##found Nan here\n", "print(\"\\n\\nschools followed: \")\n", "display(train_data.schools_followed.unique())\n", "print(\"\\n\\nhigh school: \")\n", "display(train_data.high_school.unique())\n", "print(\"\\n\\ntransfer status: \")\n", "display(train_data.transfer_status.unique())\n", "print(\"\\n\\nroommate match quiz: \")\n", "display(train_data.roommate_match_quiz.unique())\n", "#print(\"\\n\\nchat messages sent: \")\n", "#display(train_data.chat_messages_sent.unique())\n", "#print(\"\\n\\nchat viewed: \")\n", "#display(train_data.chat_viewed.unique())\n", "#print(\"\\n\\nvideos liked: \")\n", "#display(train_data.videos_liked.unique())\n", "#print(\"\\n\\nvideos viewed: \")\n", "#display(train_data.videos_viewed.unique())\n", "#print(\"\\n\\nvideos veiwed unique: \")\n", "#display(train_data.videos_viewed_unique.unique())\n", "#print(\"\\n\\ntotal official videos: \")\n", "#display(train_data.total_official_videos.unique())\n", "print(\"\\n\\nengaged: \")\n", "display(train_data.engaged.unique())\n", "print(\"\\n\\nfinal funnel stage: \")\n", "display(train_data.final_funnel_stage.unique())" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([2019, 2018])" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "array(['college3', 'college2', 'college6', 'college1', 'college4',\n", " 'college7', 'college8', 'college5'], dtype=object)" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "array(['fall', 'spring', 'summer'], dtype=object)" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display(test_data.cohort_year.unique())\n", "display(test_data.college.unique())\n", "display(test_data.start_term.unique())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So we can see the test data doesn't have entrys from 2017 (which the training set has), I'm curious how much the data will be affected by seasonality. More than 75% of the entries are from 2019 in both sets either way.\n", "\n", "If there is more time I might want to build a different model for each year to see if that will prevent overfitting." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "## train_data = train_data[train_data.cohort_year != 2017] ## lost accuracy in the model, interesting hypothesis though" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "is null in training data: \n" ] }, { "data": { "text/plain": [ "college 0\n", "public_profile_enabled 0\n", "going 0\n", "interested 0\n", "start_term 0\n", "cohort_year 0\n", "created_by_csv 0\n", "last_login 2\n", "schools_followed 0\n", "high_school 0\n", "transfer_status 0\n", "roommate_match_quiz 0\n", "chat_messages_sent 0\n", "chat_viewed 0\n", "videos_liked 0\n", "videos_viewed 0\n", "videos_viewed_unique 0\n", "total_official_videos 0\n", "engaged 0\n", "final_funnel_stage 0\n", "dtype: int64" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "is null in test data: \n" ] }, { "data": { "text/plain": [ "Unnamed: 0 0\n", "college 0\n", "public_profile_enabled 0\n", "going 0\n", "interested 0\n", "start_term 0\n", "cohort_year 0\n", "created_by_csv 0\n", "last_login 0\n", "schools_followed 0\n", "high_school 0\n", "transfer_status 0\n", "roommate_match_quiz 0\n", "chat_messages_sent 0\n", "chat_viewed 0\n", "videos_liked 0\n", "videos_viewed 0\n", "videos_viewed_unique 0\n", "total_official_videos 0\n", "engaged 0\n", "final_funnel_stage 0\n", "dtype: int64" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "print('is null in training data: ')\n", "display(train_data.isnull().sum())\n", "print('\\n\\nis null in test data: ')\n", "display(test_data.isnull().sum())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*As one quick note:\n", "the version of the test csv was overritten at the end of the competition so the test set no longer has missing values, it also has answers in it (which are actually my predictions). The part below was written during the competition*\n", "\n", "Odd that there are missing values but that they are so rare. I'm curious if those three entry's are outliers in the dataset or just the result of a bug.\n", "I had experimented with changing the missing values to 0, mean, and 1600 (max value), in the end using 0 had the most positive effect on the accuracy of the model (It's also strange that 2 missing values would even have a measurable impact)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "train_data['last_login'] = train_data['last_login'].fillna(0)\n", "## I tried running the model by filling the null entry with 0 and then again with 1500\n", "## the assumption was that the null entry was either from the time being too long \n", "## to record or the entry being null because the user was loging on at the time of capture\n", "test_data['last_login'] = test_data['last_login'].fillna(0)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Setup Complete\n" ] } ], "source": [ "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "import seaborn as sns\n", "from sklearn.ensemble import RandomForestRegressor\n", "from sklearn.metrics import mean_absolute_error\n", "from sklearn.metrics import mean_squared_error\n", "from sklearn.model_selection import train_test_split\n", "\n", "print('Setup Complete')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "def final_funnel_num(val):\n", " if val == 'Inquired':\n", " return 0\n", " \n", " if val == 'Applied':\n", " return 0\n", " \n", " if val == 'Accepted':\n", " return 0\n", " \n", " if val == 'Deposited':\n", " return 1\n", " \n", " if val == 'Application_Complete':\n", " return 0\n", " \n", " if val == 'Enrolled':\n", " return 1\n", " \n", " else:\n", " return 'error'\n", " \n", "## at this point in the process you may be wondering why I'm not using one of the in built imputation methods in sklearn over making my own\n", "## there really isn't a reason why I'm using this method, for whatever reason I just built a tool that already exists\n", "\n", "## Also worth pointing out here, initially I had thought i needed to predict all 6 outcomes for the model, when I double checked the rules I discovered that the model was supposed to predict a binary outcome of either or for a subset of the outcomes (Enrolled and Deposited)\n", "## which is why this function seems a bit silly, about an hour and a half before the deadline i discovered this error and went for the simplest fix.\n", "## interestingly enough when I was predicting 6 outcomes the model was 54% accurate in testing (17% is the accuracy that dice would have had)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "def num_bool(val):\n", " if val == True:\n", " return 1\n", " elif val == False:\n", " return 0\n", " else:\n", " return 'error'\n", "## The return code 'error' would actually be an error when the data is fed into the model\n", "## as a random forrest cannot handle values that are non numeric" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "def goin_num(val):\n", " if val == 'undecided':\n", " return 0\n", " if val == 'going':\n", " return 1\n", " if val == 'notgoing':\n", " return -1\n", " else:\n", " return 'error'" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "def col_num(val):\n", " if val == 'college1':\n", " return 1\n", " if val == 'college2':\n", " return 2\n", " if val == 'college4':\n", " return 4\n", " if val == 'college3':\n", " return 3\n", " if val == 'college5':\n", " return 5\n", " if val == 'college6':\n", " return 6\n", " if val == 'college7':\n", " return 7\n", " if val == 'college8':\n", " return 8\n", " else:\n", " return 'error'" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "def term_num(val):\n", " if val == 'fall':\n", " return 1\n", " if val == 'spring':\n", " return 2\n", " if val == 'summer':\n", " return 3\n", " else:\n", " return 'error'" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "## since I'm using a random forest model for this project I will be converting all values I wish to use to numbers\n", "## most likely i will have to drop some of these values for my final project, but its nice to have options\n", "train_data['funnel_num'] = pd.Series([final_funnel_num(x) for x in train_data.final_funnel_stage], index=train_data.index)\n", "train_data['transfer_status_num'] = pd.Series([num_bool(x) for x in train_data.transfer_status], index=train_data.index)\n", "train_data['public_profile_enabled_num'] = pd.Series([num_bool(x) for x in train_data.public_profile_enabled], index=train_data.index)\n", "train_data['interested_num'] = pd.Series([num_bool(x) for x in train_data.interested], index=train_data.index)\n", "train_data['created_by_csv_num'] = pd.Series([num_bool(x) for x in train_data.created_by_csv], index=train_data.index)\n", "train_data['roommate_match_quiz_num'] = pd.Series([num_bool(x) for x in train_data.roommate_match_quiz], index=train_data.index)\n", "train_data['going_num'] = pd.Series([goin_num(x) for x in train_data.going], index=train_data.index)\n", "train_data['college_num'] = pd.Series([col_num(x) for x in train_data.college], index=train_data.index)\n", "train_data['start_term_num'] = pd.Series([term_num(x) for x in train_data.start_term], index=train_data.index)\n", "## Also worth mentioning: isn't it wonderful not having to scale features for a random forest model" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>cohort_year</th>\n", " <th>last_login</th>\n", " <th>schools_followed</th>\n", " <th>chat_messages_sent</th>\n", " <th>chat_viewed</th>\n", " <th>videos_liked</th>\n", " <th>videos_viewed</th>\n", " <th>videos_viewed_unique</th>\n", " <th>total_official_videos</th>\n", " <th>funnel_num</th>\n", " <th>transfer_status_num</th>\n", " <th>public_profile_enabled_num</th>\n", " <th>interested_num</th>\n", " <th>created_by_csv_num</th>\n", " <th>roommate_match_quiz_num</th>\n", " <th>going_num</th>\n", " <th>college_num</th>\n", " <th>start_term_num</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>count</th>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " <td>18837.000000</td>\n", " </tr>\n", " <tr>\n", " <th>mean</th>\n", " <td>2018.999151</td>\n", " <td>238.571004</td>\n", " <td>4.189998</td>\n", " <td>1.878696</td>\n", " <td>12.122950</td>\n", " <td>0.046823</td>\n", " <td>23.389287</td>\n", " <td>5.700855</td>\n", " <td>134.600467</td>\n", " <td>0.120614</td>\n", " <td>0.030472</td>\n", " <td>0.967086</td>\n", " <td>0.890641</td>\n", " <td>0.147263</td>\n", " <td>0.133939</td>\n", " <td>0.025747</td>\n", " <td>3.459150</td>\n", " <td>1.021129</td>\n", " </tr>\n", " <tr>\n", " <th>std</th>\n", " <td>0.034165</td>\n", " <td>175.476667</td>\n", " <td>5.393513</td>\n", " <td>15.565363</td>\n", " <td>52.655026</td>\n", " <td>0.619321</td>\n", " <td>108.900462</td>\n", " <td>15.855868</td>\n", " <td>156.893356</td>\n", " <td>0.325686</td>\n", " <td>0.171887</td>\n", " <td>0.178416</td>\n", " <td>0.312098</td>\n", " <td>0.354378</td>\n", " <td>0.340595</td>\n", " <td>0.320970</td>\n", " <td>1.964349</td>\n", " <td>0.190504</td>\n", " </tr>\n", " <tr>\n", " <th>min</th>\n", " <td>2017.000000</td>\n", " <td>0.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>-1.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " </tr>\n", " <tr>\n", " <th>25%</th>\n", " <td>2019.000000</td>\n", " <td>130.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>42.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>2.000000</td>\n", " <td>1.000000</td>\n", " </tr>\n", " <tr>\n", " <th>50%</th>\n", " <td>2019.000000</td>\n", " <td>226.000000</td>\n", " <td>2.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>56.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>3.000000</td>\n", " <td>1.000000</td>\n", " </tr>\n", " <tr>\n", " <th>75%</th>\n", " <td>2019.000000</td>\n", " <td>299.000000</td>\n", " <td>5.000000</td>\n", " <td>0.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>11.000000</td>\n", " <td>4.000000</td>\n", " <td>180.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>0.000000</td>\n", " <td>5.000000</td>\n", " <td>1.000000</td>\n", " </tr>\n", " <tr>\n", " <th>max</th>\n", " <td>2019.000000</td>\n", " <td>1549.000000</td>\n", " <td>214.000000</td>\n", " <td>1307.000000</td>\n", " <td>1735.000000</td>\n", " <td>23.000000</td>\n", " <td>4857.000000</td>\n", " <td>527.000000</td>\n", " <td>637.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " <td>1.000000</td>\n", " <td>8.000000</td>\n", " <td>3.000000</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " cohort_year last_login schools_followed chat_messages_sent \\\n", "count 18837.000000 18837.000000 18837.000000 18837.000000 \n", "mean 2018.999151 238.571004 4.189998 1.878696 \n", "std 0.034165 175.476667 5.393513 15.565363 \n", "min 2017.000000 0.000000 1.000000 0.000000 \n", "25% 2019.000000 130.000000 1.000000 0.000000 \n", "50% 2019.000000 226.000000 2.000000 0.000000 \n", "75% 2019.000000 299.000000 5.000000 0.000000 \n", "max 2019.000000 1549.000000 214.000000 1307.000000 \n", "\n", " chat_viewed videos_liked videos_viewed videos_viewed_unique \\\n", "count 18837.000000 18837.000000 18837.000000 18837.000000 \n", "mean 12.122950 0.046823 23.389287 5.700855 \n", "std 52.655026 0.619321 108.900462 15.855868 \n", "min 0.000000 0.000000 0.000000 0.000000 \n", "25% 0.000000 0.000000 0.000000 0.000000 \n", "50% 0.000000 0.000000 0.000000 0.000000 \n", "75% 1.000000 0.000000 11.000000 4.000000 \n", "max 1735.000000 23.000000 4857.000000 527.000000 \n", "\n", " total_official_videos funnel_num transfer_status_num \\\n", "count 18837.000000 18837.000000 18837.000000 \n", "mean 134.600467 0.120614 0.030472 \n", "std 156.893356 0.325686 0.171887 \n", "min 0.000000 0.000000 0.000000 \n", "25% 42.000000 0.000000 0.000000 \n", "50% 56.000000 0.000000 0.000000 \n", "75% 180.000000 0.000000 0.000000 \n", "max 637.000000 1.000000 1.000000 \n", "\n", " public_profile_enabled_num interested_num created_by_csv_num \\\n", "count 18837.000000 18837.000000 18837.000000 \n", "mean 0.967086 0.890641 0.147263 \n", "std 0.178416 0.312098 0.354378 \n", "min 0.000000 0.000000 0.000000 \n", "25% 1.000000 1.000000 0.000000 \n", "50% 1.000000 1.000000 0.000000 \n", "75% 1.000000 1.000000 0.000000 \n", "max 1.000000 1.000000 1.000000 \n", "\n", " roommate_match_quiz_num going_num college_num start_term_num \n", "count 18837.000000 18837.000000 18837.000000 18837.000000 \n", "mean 0.133939 0.025747 3.459150 1.021129 \n", "std 0.340595 0.320970 1.964349 0.190504 \n", "min 0.000000 -1.000000 1.000000 1.000000 \n", "25% 0.000000 0.000000 2.000000 1.000000 \n", "50% 0.000000 0.000000 3.000000 1.000000 \n", "75% 0.000000 0.000000 5.000000 1.000000 \n", "max 1.000000 1.000000 8.000000 3.000000 " ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_data.describe()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Part -1:\n", "Drop everything and focus on finishing one successful model as fast a possible entry! oh god how is it half way to time already.\n", "\n", "By this point in the competition I realized i hadn't be executing with the right sence of urgency and needed to rush towards a solution else risk having nothing to present." ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "y = train_data.funnel_num\n", "rf_features = ['cohort_year', 'going_num', 'chat_messages_sent', 'schools_followed', 'videos_liked', 'chat_viewed', 'total_official_videos', 'videos_viewed','transfer_status_num', 'videos_viewed_unique', \n", " 'public_profile_enabled_num', 'created_by_csv_num', 'interested_num', 'roommate_match_quiz_num', 'college_num']\n", "X = train_data[rf_features]\n", "\n", "## what isn't pictured here is the trial and error as I remove various components, and reran the next 2 cells to compare accuracy.\n", "## This process also taught me something new, the order the features are in affects the model created\n", "\n", "## As a worthwhile point to mention, I had initially guessed that using one hot encoding for the college would have confused a random forrest and that i was going to need to retry using a sparse vector instead, \n", "## however using one hot encoding did have a positive end result (assuming I didn't overfit the model)\n", "\n", "## start_term_num and last_login was removed as it did not improve the accuracy of the model\n", "\n", "## Other notes: roommate_match_quiz_num and public_profile_enabled_num had an almost insignifigant impact on accuracy, I chose to leave them in because the impact was positive\n", "## however if this were a production enviorment i might drop it for computational efficiency\n", "\n", "\n", "train_X, val_X, train_y, val_y = train_test_split(X, y,random_state = 0)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/conda/lib/python3.6/site-packages/sklearn/ensemble/forest.py:245: FutureWarning: The default value of n_estimators will change from 10 in version 0.20 to 100 in 0.22.\n", " \"10 in version 0.20 to 100 in 0.22.\", FutureWarning)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "0.05138963698419575\n" ] } ], "source": [ "forest_model = RandomForestRegressor(random_state=0)\n", "forest_model.fit(train_X, train_y)\n", "td_preds = forest_model.predict(val_X)\n", "print(mean_squared_error(val_y, td_preds))" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "td_preds = td_preds.round()" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1.0 0.0\n" ] } ], "source": [ "print(td_preds.max(), td_preds.min())\n", "## Checking to make sure there are no nonsensicle outputs" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.06029723991507431\n" ] } ], "source": [ "print(mean_squared_error(val_y, td_preds))" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.814706977907182\n" ] } ], "source": [ "## this cell I added after the competition. Since the data sample has a split of about 1 positive case in 10\n", "## I wanted to compare other evaluation methods\n", "from sklearn.metrics import roc_auc_score\n", "\n", "print(roc_auc_score(val_y, td_preds))" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "full_preds = forest_model.predict(train_data[rf_features])\n", "\n", "train_data['preds'] = full_preds.round()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>college</th>\n", " <th>public_profile_enabled</th>\n", " <th>going</th>\n", " <th>interested</th>\n", " <th>start_term</th>\n", " <th>cohort_year</th>\n", " <th>created_by_csv</th>\n", " <th>last_login</th>\n", " <th>schools_followed</th>\n", " <th>high_school</th>\n", " <th>...</th>\n", " <th>funnel_num</th>\n", " <th>transfer_status_num</th>\n", " <th>public_profile_enabled_num</th>\n", " <th>interested_num</th>\n", " <th>created_by_csv_num</th>\n", " <th>roommate_match_quiz_num</th>\n", " <th>going_num</th>\n", " <th>college_num</th>\n", " <th>start_term_num</th>\n", " <th>preds</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>college1</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1549.0</td>\n", " <td>2</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>college2</td>\n", " <td>False</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1482.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>college2</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1403.0</td>\n", " <td>3</td>\n", " <td>other</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>college4</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1403.0</td>\n", " <td>3</td>\n", " <td>other</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>4</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>694.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>5</th>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1402.0</td>\n", " <td>2</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>6</th>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1402.0</td>\n", " <td>2</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>7</th>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1214.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>8</th>\n", " <td>college3</td>\n", " <td>False</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1036.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>9</th>\n", " <td>college2</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1402.0</td>\n", " <td>2</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>10</th>\n", " <td>college2</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1402.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>11</th>\n", " <td>college3</td>\n", " <td>False</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1401.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>12</th>\n", " <td>college5</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>425.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>5</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>13</th>\n", " <td>college3</td>\n", " <td>False</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1396.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>14</th>\n", " <td>college7</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1389.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>7</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>15</th>\n", " <td>college6</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1382.0</td>\n", " <td>2</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>6</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>16</th>\n", " <td>college1</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1374.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>17</th>\n", " <td>college2</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1338.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>18</th>\n", " <td>college6</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>True</td>\n", " <td>1345.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>6</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>19</th>\n", " <td>college7</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1344.0</td>\n", " <td>1</td>\n", " <td>unknown</td>\n", " <td>...</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>7</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>20 rows × 30 columns</p>\n", "</div>" ], "text/plain": [ " college public_profile_enabled going interested start_term \\\n", "0 college1 True undecided True fall \n", "1 college2 False undecided True fall \n", "2 college2 True undecided True fall \n", "3 college4 True undecided True fall \n", "4 college3 True undecided True fall \n", "5 college3 True undecided True fall \n", "6 college3 True undecided True fall \n", "7 college3 True undecided True fall \n", "8 college3 False undecided True fall \n", "9 college2 True undecided True fall \n", "10 college2 True undecided True fall \n", "11 college3 False undecided True fall \n", "12 college5 True undecided True fall \n", "13 college3 False undecided True fall \n", "14 college7 True undecided True fall \n", "15 college6 True undecided True fall \n", "16 college1 True undecided True fall \n", "17 college2 True undecided True fall \n", "18 college6 True undecided True fall \n", "19 college7 True undecided True fall \n", "\n", " cohort_year created_by_csv last_login schools_followed high_school \\\n", "0 2019 False 1549.0 2 unknown \n", "1 2019 False 1482.0 1 unknown \n", "2 2019 False 1403.0 3 other \n", "3 2019 False 1403.0 3 other \n", "4 2019 False 694.0 1 unknown \n", "5 2019 False 1402.0 2 unknown \n", "6 2019 False 1402.0 2 unknown \n", "7 2019 False 1214.0 1 unknown \n", "8 2019 False 1036.0 1 unknown \n", "9 2019 False 1402.0 2 unknown \n", "10 2019 False 1402.0 1 unknown \n", "11 2019 False 1401.0 1 unknown \n", "12 2019 False 425.0 1 unknown \n", "13 2019 False 1396.0 1 unknown \n", "14 2019 False 1389.0 1 unknown \n", "15 2019 False 1382.0 2 unknown \n", "16 2019 False 1374.0 1 unknown \n", "17 2019 False 1338.0 1 unknown \n", "18 2019 True 1345.0 1 unknown \n", "19 2019 False 1344.0 1 unknown \n", "\n", " ... funnel_num transfer_status_num public_profile_enabled_num \\\n", "0 ... 0 0 1 \n", "1 ... 0 0 0 \n", "2 ... 0 0 1 \n", "3 ... 0 0 1 \n", "4 ... 0 0 1 \n", "5 ... 0 0 1 \n", "6 ... 0 0 1 \n", "7 ... 0 0 1 \n", "8 ... 0 0 0 \n", "9 ... 0 0 1 \n", "10 ... 0 0 1 \n", "11 ... 0 0 0 \n", "12 ... 0 0 1 \n", "13 ... 0 0 0 \n", "14 ... 0 0 1 \n", "15 ... 0 1 1 \n", "16 ... 0 0 1 \n", "17 ... 0 0 1 \n", "18 ... 0 1 1 \n", "19 ... 0 0 1 \n", "\n", " interested_num created_by_csv_num roommate_match_quiz_num going_num \\\n", "0 1 0 0 0 \n", "1 1 0 0 0 \n", "2 1 0 0 0 \n", "3 1 0 0 0 \n", "4 1 0 0 0 \n", "5 1 0 0 0 \n", "6 1 0 0 0 \n", "7 1 0 0 0 \n", "8 1 0 0 0 \n", "9 1 0 0 0 \n", "10 1 0 0 0 \n", "11 1 0 0 0 \n", "12 1 0 0 0 \n", "13 1 0 0 0 \n", "14 1 0 0 0 \n", "15 1 0 0 0 \n", "16 1 0 0 0 \n", "17 1 0 0 0 \n", "18 1 1 0 0 \n", "19 1 0 0 0 \n", "\n", " college_num start_term_num preds \n", "0 1 1 0.0 \n", "1 2 1 0.0 \n", "2 2 1 0.0 \n", "3 4 1 0.0 \n", "4 3 1 0.0 \n", "5 3 1 0.0 \n", "6 3 1 0.0 \n", "7 3 1 0.0 \n", "8 3 1 0.0 \n", "9 2 1 0.0 \n", "10 2 1 0.0 \n", "11 3 1 0.0 \n", "12 5 1 0.0 \n", "13 3 1 0.0 \n", "14 7 1 0.0 \n", "15 6 1 0.0 \n", "16 1 1 0.0 \n", "17 2 1 0.0 \n", "18 6 1 0.0 \n", "19 7 1 0.0 \n", "\n", "[20 rows x 30 columns]" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_data.head(20)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Percent accuracy of model is: 97.0218187609492\n" ] } ], "source": [ "y = 0\n", "x = 0\n", "for index, row in train_data.iterrows():\n", "# print(row['funnel_num'])\n", " if row['funnel_num'] == row['preds']:\n", " x = x + 1\n", " else:\n", " y = y + 1\n", "print(\"Percent accuracy of model is: \", (x/(x+y))*100)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Percentage of positives in sample: 12.061368583107713 \n", "Percentage of predicted positives in sample: 10.251101555449381\n" ] } ], "source": [ "y = 0\n", "x = 0\n", "n = 0\n", "q = 0\n", "for index, row in train_data.iterrows():\n", "# print(row['funnel_num'])\n", " if row['funnel_num'] == 1:\n", " x = x + 1\n", " else:\n", " y = y + 1\n", " if row['preds'] == 1:\n", " n = n + 1\n", " else:\n", " q = q + 1\n", " \n", "print('Percentage of positives in sample: ', (x/(x+y))*100, '\\nPercentage of predicted positives in sample: ', (n/(n+q))*100)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we have an idea of the accuracy of the model (and that its better than throwing darts at a board), let's wrap this hot mess up into the test set" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "test_data['transfer_status_num'] = pd.Series([num_bool(x) for x in test_data.transfer_status], index=test_data.index)\n", "test_data['public_profile_enabled_num'] = pd.Series([num_bool(x) for x in test_data.public_profile_enabled], index=test_data.index)\n", "test_data['interested_num'] = pd.Series([num_bool(x) for x in test_data.interested], index=test_data.index)\n", "test_data['created_by_csv_num'] = pd.Series([num_bool(x) for x in test_data.created_by_csv], index=test_data.index)\n", "test_data['roommate_match_quiz_num'] = pd.Series([num_bool(x) for x in test_data.roommate_match_quiz], index=test_data.index)\n", "test_data['going_num'] = pd.Series([goin_num(x) for x in test_data.going], index=test_data.index)\n", "test_data['college_num'] = pd.Series([col_num(x) for x in test_data.college], index=test_data.index)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "values should be 0 and 1.0: 0.0 1.0\n" ] }, { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>Unnamed: 0</th>\n", " <th>college</th>\n", " <th>public_profile_enabled</th>\n", " <th>going</th>\n", " <th>interested</th>\n", " <th>start_term</th>\n", " <th>cohort_year</th>\n", " <th>created_by_csv</th>\n", " <th>last_login</th>\n", " <th>schools_followed</th>\n", " <th>...</th>\n", " <th>engaged</th>\n", " <th>final_funnel_stage</th>\n", " <th>transfer_status_num</th>\n", " <th>public_profile_enabled_num</th>\n", " <th>interested_num</th>\n", " <th>created_by_csv_num</th>\n", " <th>roommate_match_quiz_num</th>\n", " <th>going_num</th>\n", " <th>college_num</th>\n", " <th>preds</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>0</td>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1480.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>1</td>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1402.0</td>\n", " <td>2</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>2</td>\n", " <td>college2</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1399.0</td>\n", " <td>2</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>3</td>\n", " <td>college6</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1391.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>6</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>4</td>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1384.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>5</th>\n", " <td>5</td>\n", " <td>college2</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1375.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>6</th>\n", " <td>6</td>\n", " <td>college2</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1368.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>7</th>\n", " <td>7</td>\n", " <td>college1</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>841.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>8</th>\n", " <td>8</td>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1328.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>9</th>\n", " <td>9</td>\n", " <td>college1</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>936.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>True</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>10</th>\n", " <td>10</td>\n", " <td>college1</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1294.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>11</th>\n", " <td>11</td>\n", " <td>college6</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1261.0</td>\n", " <td>2</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>6</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>12</th>\n", " <td>12</td>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1194.0</td>\n", " <td>6</td>\n", " <td>...</td>\n", " <td>True</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>13</th>\n", " <td>13</td>\n", " <td>college3</td>\n", " <td>False</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>545.0</td>\n", " <td>10</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>14</th>\n", " <td>14</td>\n", " <td>college4</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>738.0</td>\n", " <td>3</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>4</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>15</th>\n", " <td>15</td>\n", " <td>college3</td>\n", " <td>False</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1173.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>16</th>\n", " <td>16</td>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1162.0</td>\n", " <td>9</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>17</th>\n", " <td>17</td>\n", " <td>college1</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1135.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>18</th>\n", " <td>18</td>\n", " <td>college7</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1126.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>1.0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>7</td>\n", " <td>1.0</td>\n", " </tr>\n", " <tr>\n", " <th>19</th>\n", " <td>19</td>\n", " <td>college6</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1098.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>6</td>\n", " <td>0.0</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>20 rows × 29 columns</p>\n", "</div>" ], "text/plain": [ " Unnamed: 0 college public_profile_enabled going interested \\\n", "0 0 college3 True undecided True \n", "1 1 college3 True undecided True \n", "2 2 college2 True undecided True \n", "3 3 college6 True undecided True \n", "4 4 college3 True undecided True \n", "5 5 college2 True undecided True \n", "6 6 college2 True undecided True \n", "7 7 college1 True undecided True \n", "8 8 college3 True undecided True \n", "9 9 college1 True undecided True \n", "10 10 college1 True undecided True \n", "11 11 college6 True undecided True \n", "12 12 college3 True undecided True \n", "13 13 college3 False undecided True \n", "14 14 college4 True undecided True \n", "15 15 college3 False undecided True \n", "16 16 college3 True undecided True \n", "17 17 college1 True undecided True \n", "18 18 college7 True undecided True \n", "19 19 college6 True undecided True \n", "\n", " start_term cohort_year created_by_csv last_login schools_followed \\\n", "0 fall 2019 False 1480.0 1 \n", "1 fall 2019 False 1402.0 2 \n", "2 fall 2019 False 1399.0 2 \n", "3 fall 2019 False 1391.0 1 \n", "4 fall 2019 False 1384.0 1 \n", "5 fall 2019 False 1375.0 1 \n", "6 fall 2019 False 1368.0 1 \n", "7 fall 2019 False 841.0 1 \n", "8 fall 2019 False 1328.0 1 \n", "9 fall 2019 False 936.0 1 \n", "10 fall 2019 False 1294.0 1 \n", "11 fall 2019 False 1261.0 2 \n", "12 fall 2019 False 1194.0 6 \n", "13 fall 2019 False 545.0 10 \n", "14 fall 2019 False 738.0 3 \n", "15 fall 2019 False 1173.0 1 \n", "16 fall 2019 False 1162.0 9 \n", "17 fall 2019 False 1135.0 1 \n", "18 fall 2019 False 1126.0 1 \n", "19 fall 2019 False 1098.0 1 \n", "\n", " ... engaged final_funnel_stage transfer_status_num \\\n", "0 ... False 0.0 0 \n", "1 ... False 0.0 0 \n", "2 ... False 0.0 0 \n", "3 ... False 0.0 0 \n", "4 ... False 0.0 0 \n", "5 ... False 0.0 0 \n", "6 ... False 0.0 0 \n", "7 ... False 0.0 0 \n", "8 ... False 0.0 0 \n", "9 ... True 0.0 0 \n", "10 ... False 0.0 0 \n", "11 ... False 0.0 0 \n", "12 ... True 0.0 0 \n", "13 ... False 0.0 0 \n", "14 ... False 0.0 0 \n", "15 ... False 0.0 0 \n", "16 ... False 0.0 0 \n", "17 ... False 0.0 0 \n", "18 ... False 1.0 1 \n", "19 ... False 0.0 0 \n", "\n", " public_profile_enabled_num interested_num created_by_csv_num \\\n", "0 1 1 0 \n", "1 1 1 0 \n", "2 1 1 0 \n", "3 1 1 0 \n", "4 1 1 0 \n", "5 1 1 0 \n", "6 1 1 0 \n", "7 1 1 0 \n", "8 1 1 0 \n", "9 1 1 0 \n", "10 1 1 0 \n", "11 1 1 0 \n", "12 1 1 0 \n", "13 0 1 0 \n", "14 1 1 0 \n", "15 0 1 0 \n", "16 1 1 0 \n", "17 1 1 0 \n", "18 1 1 0 \n", "19 1 1 0 \n", "\n", " roommate_match_quiz_num going_num college_num preds \n", "0 0 0 3 0.0 \n", "1 0 0 3 0.0 \n", "2 0 0 2 0.0 \n", "3 0 0 6 0.0 \n", "4 0 0 3 0.0 \n", "5 0 0 2 0.0 \n", "6 0 0 2 0.0 \n", "7 0 0 1 0.0 \n", "8 0 0 3 0.0 \n", "9 0 0 1 0.0 \n", "10 0 0 1 0.0 \n", "11 0 0 6 0.0 \n", "12 0 0 3 0.0 \n", "13 0 0 3 0.0 \n", "14 0 0 4 0.0 \n", "15 0 0 3 0.0 \n", "16 0 0 3 0.0 \n", "17 0 0 1 0.0 \n", "18 0 0 7 1.0 \n", "19 0 0 6 0.0 \n", "\n", "[20 rows x 29 columns]" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test_preds = forest_model.predict(test_data[rf_features])\n", "print('values should be 0 and 1.0: ', test_preds.min(), test_preds.max())\n", "test_data['preds'] = test_preds.round()\n", "test_data.head(20)" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "#def funnel_final(val): \n", "# if val == 1:\n", "# return 'Inquired'\n", "# \n", "# if val == 2:\n", "# return 'Applied'\n", "# \n", "# if val == 3:\n", "# return 'Accepted'\n", "# \n", "# if val == 4:\n", "# return 'Deposited'\n", "# \n", "# if val == 5:\n", "# return 'Application_Complete'\n", "# \n", "# if val == 6:\n", "# return 'Enrolled'" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "## Now to bring this hot mess full circle\n", "test_data['final_funnel_stage'] = pd.Series([x for x in test_data.preds], index=test_data.index)" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>Unnamed: 0</th>\n", " <th>college</th>\n", " <th>public_profile_enabled</th>\n", " <th>going</th>\n", " <th>interested</th>\n", " <th>start_term</th>\n", " <th>cohort_year</th>\n", " <th>created_by_csv</th>\n", " <th>last_login</th>\n", " <th>schools_followed</th>\n", " <th>...</th>\n", " <th>engaged</th>\n", " <th>final_funnel_stage</th>\n", " <th>transfer_status_num</th>\n", " <th>public_profile_enabled_num</th>\n", " <th>interested_num</th>\n", " <th>created_by_csv_num</th>\n", " <th>roommate_match_quiz_num</th>\n", " <th>going_num</th>\n", " <th>college_num</th>\n", " <th>preds</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>0</td>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1480.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>1</td>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1402.0</td>\n", " <td>2</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>2</td>\n", " <td>college2</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1399.0</td>\n", " <td>2</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>3</td>\n", " <td>college6</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1391.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>6</td>\n", " <td>0.0</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>4</td>\n", " <td>college3</td>\n", " <td>True</td>\n", " <td>undecided</td>\n", " <td>True</td>\n", " <td>fall</td>\n", " <td>2019</td>\n", " <td>False</td>\n", " <td>1384.0</td>\n", " <td>1</td>\n", " <td>...</td>\n", " <td>False</td>\n", " <td>0.0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>0.0</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>5 rows × 29 columns</p>\n", "</div>" ], "text/plain": [ " Unnamed: 0 college public_profile_enabled going interested \\\n", "0 0 college3 True undecided True \n", "1 1 college3 True undecided True \n", "2 2 college2 True undecided True \n", "3 3 college6 True undecided True \n", "4 4 college3 True undecided True \n", "\n", " start_term cohort_year created_by_csv last_login schools_followed \\\n", "0 fall 2019 False 1480.0 1 \n", "1 fall 2019 False 1402.0 2 \n", "2 fall 2019 False 1399.0 2 \n", "3 fall 2019 False 1391.0 1 \n", "4 fall 2019 False 1384.0 1 \n", "\n", " ... engaged final_funnel_stage transfer_status_num \\\n", "0 ... False 0.0 0 \n", "1 ... False 0.0 0 \n", "2 ... False 0.0 0 \n", "3 ... False 0.0 0 \n", "4 ... False 0.0 0 \n", "\n", " public_profile_enabled_num interested_num created_by_csv_num \\\n", "0 1 1 0 \n", "1 1 1 0 \n", "2 1 1 0 \n", "3 1 1 0 \n", "4 1 1 0 \n", "\n", " roommate_match_quiz_num going_num college_num preds \n", "0 0 0 3 0.0 \n", "1 0 0 3 0.0 \n", "2 0 0 2 0.0 \n", "3 0 0 6 0.0 \n", "4 0 0 3 0.0 \n", "\n", "[5 rows x 29 columns]" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test_data.head()" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(4708, 20)\n" ] } ], "source": [ "test_data = test_data[['college', 'public_profile_enabled', 'going', 'interested',\n", " 'start_term', 'cohort_year', 'created_by_csv', 'last_login',\n", " 'schools_followed', 'high_school', 'transfer_status',\n", " 'roommate_match_quiz', 'chat_messages_sent', 'chat_viewed',\n", " 'videos_liked', 'videos_viewed', 'videos_viewed_unique',\n", " 'total_official_videos', 'engaged', 'final_funnel_stage']]\n", "print(test_data.shape) ## checking to make sure we're back to 20 columns and that i didn't screw something up" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "#test_data.to_csv(\"zeemee_test_output.csv\")\n", "#output file for the copetition" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As you can see the greatest failing of the project was that I did not ration my time effectively, I didn't finish my EDA before I jumped into the model and had to use trial and error in its place. I had optimistically imported seaborn and matplotlib, but failed to use them. Especially with the imputation methods I used I missed out on a golden opportunity to review the differences in the training and test dataset.\n", "\n", "Secondly with testing, I did not check for overfitting and simply submitted and crossed my fingers (as a result of running out of time). In hindsight I know that the model hadn't overfit and was similairly effective in both the training and test data.\n", "\n", "Third I would have liked to capture false positive, and fale negitive rate for the model as well [use a confusion matrix] as opposed to just capturing MAE and percentage (these at least provided quick feedback to adjust the various itterations of the model). Ideally in a production enviorment I would have liked to tweek the model so that it had very little false negitives even if it meant that the model became too optimistic (loosing just a couple students would outweigh the benifits of cutting advertising to the one who wouldn't be attainable)." ] } ], "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": 1 }
0019/068/19068396.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n (...TRUNCATED)
0019/068/19068918.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n (...TRUNCATED)
0019/069/19069172.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n (...TRUNCATED)
0019/069/19069242.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n (...TRUNCATED)
0019/069/19069438.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n (...TRUNCATED)
0019/069/19069809.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {\(...TRUNCATED)
0019/071/19071027.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {\(...TRUNCATED)
0019/071/19071774.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n (...TRUNCATED)
0019/071/19071846.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {},\n \"source\": [\n (...TRUNCATED)
0019/073/19073076.ipynb
s3://data-agents/kaggle-outputs/sharded/001_00019.jsonl.gz
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
26