Skip to content

Commit

Permalink
docs: Created a Regression Getting Started Tutorial (#437)
Browse files Browse the repository at this point in the history
Closes #400

### Summary of Changes

Created a Regression Getting Started Tutorial and added it together with
the Classification Getting Started Tutorial to the docs.

---------

Co-authored-by: patrikguempel <[email protected]>
Co-authored-by: Alex Senger <[email protected]>
Co-authored-by: Lars Reimann <[email protected]>
Co-authored-by: Alexander <[email protected]>
Co-authored-by: Alexander Gréus <[email protected]>
  • Loading branch information
6 people authored Jul 13, 2023
1 parent c4143af commit 5cfba79
Show file tree
Hide file tree
Showing 4 changed files with 21,822 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "markdown",
"source": [
"# Getting started\n",
"# Classification\n",
"\n",
"This tutorial uses safeds on **titanic passenger data** to predict who will survive and who will not, using sex as a feature for the prediction.\n"
],
Expand All @@ -27,7 +27,9 @@
"source": [
"from safeds.data.tabular.containers import Table\n",
"\n",
"titanic = Table.from_csv_file(\"data/titanic.csv\")"
"titanic = Table.from_csv_file(\"data/titanic.csv\")\n",
"#For visualisation purposes we only print out the first 15 rows.\n",
"titanic.slice_rows(0,15)"
],
"metadata": {
"collapsed": false
Expand All @@ -51,9 +53,9 @@
"split_tuple = titanic.split_rows(0.60)\n",
"\n",
"train_table = split_tuple[0]\n",
"test_table = split_tuple[1]\n",
"testing_table = split_tuple[1]\n",
"\n",
"test_table = test_table.remove_columns([\"survived\"])"
"test_table = testing_table.remove_columns([\"survived\"]).shuffle_rows()"
],
"metadata": {
"collapsed": false
Expand Down Expand Up @@ -170,9 +172,11 @@
"encoder = OneHotEncoder().fit(test_table, [\"sex\"])\n",
"transformed_test_table = encoder.transform(test_table)\n",
"\n",
"fitted_model.predict(\n",
"predicition = fitted_model.predict(\n",
" transformed_test_table\n",
")\n"
")\n",
"#For visualisation purposes we only print out the first 15 rows.\n",
"predicition.slice_rows(0,15)"
],
"metadata": {
"collapsed": false
Expand All @@ -181,7 +185,7 @@
{
"cell_type": "markdown",
"source": [
"7. You can test the accuracy of that model as follows:"
"8. You can test the accuracy of that model with the initial testing_table as follows:"
],
"metadata": {
"collapsed": false
Expand All @@ -192,6 +196,12 @@
"execution_count": null,
"outputs": [],
"source": [
"encoder = OneHotEncoder().fit(test_table, [\"sex\"])\n",
"testing_table = encoder.transform(testing_table)\n",
"\n",
"tagged_test_table= testing_table.tag_columns(\"survived\", feature_names=[\n",
" *new_columns\n",
"])\n",
"fitted_model.accuracy(tagged_train_table)\n"
],
"metadata": {
Expand Down
Loading

0 comments on commit 5cfba79

Please sign in to comment.