{"id":23190321,"url":"https://github.com/linsanity03/titanic_prediction","last_synced_at":"2026-04-28T18:35:43.186Z","repository":{"id":195172315,"uuid":"692399794","full_name":"LINSANITY03/Titanic_prediction","owner":"LINSANITY03","description":"A visualization on probability of people surviving titanic","archived":false,"fork":false,"pushed_at":"2023-09-18T10:23:07.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T06:41:42.062Z","etag":null,"topics":["classifier-model","machine-learning","prediction-model","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LINSANITY03.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-16T11:09:11.000Z","updated_at":"2023-12-17T20:53:49.000Z","dependencies_parsed_at":"2024-12-18T12:14:11.002Z","dependency_job_id":"a7f5ff02-509e-4823-87f9-5875059f9137","html_url":"https://github.com/LINSANITY03/Titanic_prediction","commit_stats":null,"previous_names":["linsanity03/titanic_prediction"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LINSANITY03/Titanic_prediction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FTitanic_prediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FTitanic_prediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FTitanic_prediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FTitanic_prediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LINSANITY03","download_url":"https://codeload.github.com/LINSANITY03/Titanic_prediction/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FTitanic_prediction/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32394467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classifier-model","machine-learning","prediction-model","tensorflow"],"created_at":"2024-12-18T12:14:05.890Z","updated_at":"2026-04-28T18:35:43.147Z","avatar_url":"https://github.com/LINSANITY03.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prediction model of surviving possibilities\n\nIn this project we use pandas to collect data from a source and in-built tensorflow model to train the data.\n\nTo run this project,\n\n- Create a virutal environment and activate the environment.\n  `  virtualenv venv\n\\venv\\Scripts\\activate`\n\n- Install the required dependencies.\n  `pip install -r requirements.txt\n`\n\n- Run the **prediction_main.py** file.\n  `python prediction_main.py`\n\n**1. Data Collection:**\nWe get titanic training and evaluation data from google drive links.\n\n```\nimport pandas as pd\n...\n\ndftrain = pd.read_csv(\n'https://storage.googleapis.com/tf-datasets/titanic/train.csv') # training data\n\ndfeval = pd.read_csv(\n'https://storage.googleapis.com/tf-datasets/titanic/eval.csv') # testing data\n```\n\n**2. Feature Extraction:**\nUsing the in-built feature column function of tensorflow, we get all the unique value from each column of the pandas file.\n\n```\nCATEGORICAL_COLUMNS = ['sex', 'n_siblings_spouses', 'parch', 'class', 'deck',\n'embark_town', 'alone']\n\nNUMERIC_COLUMNS = ['age', 'fare']\n\nfeature_columns = []\n\n# we use the inbuilt function in tensorflow to get all the unique value represented in the data of certain features\n\nfor feature_name in CATEGORICAL_COLUMNS: # gets a list of all unique values from given feature column\nvocabulary = dftrain[feature_name].unique()\nfeature_columns.append(tf.feature_column.categorical_column_with_vocabulary_list(\nfeature_name, vocabulary))\n\n# similar for the numeric ones we get the features in float format\n\nfor feature_name in NUMERIC_COLUMNS:\nfeature_columns.append(tf.feature_column.numeric_column(\nfeature_name, dtype=tf.float32))\n```\n\n**3. Data Preparation:**\nWe need to make sure the data are in appropritate format for the tensorflow model. So, we convert the datas into data.Dataset object using tf.data.Dataset function\n\n```\n\n# create tf.data.Dataset object with data and its label\nds = tf.data.Dataset.from_tensor_slices((dict(data_df), label_df))\n\n```\n\n**4. Choosing a Model:**\nOur goal is to predict the chance of survivility. So, a simple linear model would do the trick.\n\n```\nlinear_est = tf.estimator.LinearClassifier(feature_columns=feature_columns)\n```\n\n**5. Training the model:**\nWe use the data we convert to data.Dataset object to the model.\n\n```\nlinear_est.train(train_input_fn)  # train\n```\n\n**6. Evaluate the model:**\nTest the unseen dataset to measure the performance of the trained model.\n\n```\nresult = linear_est.evaluate(eval_input_fn)\n```\n\n**7. Make prediction:**\nUsing the evaluated model predict the survivor possibilty and plot the stats into graph using matplot for better readability.\n\n```\npred_dicts = list(linear_est.predict(eval_input_fn))\n\nprobs = pd.Series([pred['probabilities'][1] for pred in pred_dicts])\nprobs.plot(kind='hist', bins=20, title='predicted probabilities')\nplt.show()\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./screenshots/prediction.JPG\" alt=\"prediction\"\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinsanity03%2Ftitanic_prediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinsanity03%2Ftitanic_prediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinsanity03%2Ftitanic_prediction/lists"}