diff --git a/notebooks/c07_Recurrent_Neural_Networks/Recurrent_Neural_Networks.ipynb b/notebooks/c07_Recurrent_Neural_Networks/Recurrent_Neural_Networks.ipynb index 98524e1..4531853 100644 --- a/notebooks/c07_Recurrent_Neural_Networks/Recurrent_Neural_Networks.ipynb +++ b/notebooks/c07_Recurrent_Neural_Networks/Recurrent_Neural_Networks.ipynb @@ -4096,20 +4096,7 @@ } }, "outputs": [], - "source": [ - "import pandas as pd\n", - "import sklearn.metrics\n", - "import numpy as np\n", - "\n", - "def classification_report(*args, **kwargs):\n", - " out_df = pd.DataFrame(sklearn.metrics.classification_report(*args, **kwargs, output_dict=True)).T\n", - " # Order cols\n", - " out_df[[\"precision\",\"recall\",\"f1-score\",\"support\"]] \n", - " # Round\n", - " out_df[[\"precision\",\"recall\",\"f1-score\"]]= out_df[[\"precision\",\"recall\",\"f1-score\"]].apply(lambda x: round(x,2))\n", - " out_df[[\"support\"]]= out_df[[\"support\"]].apply(lambda x: x.astype(np.int))\n", - " return out_df" - ] + "source": [] }, { "cell_type": "code", @@ -4278,6 +4265,7 @@ } ], "source": [ + "from deep_ml_curriculum.classification_report import pd_classification_report\n", "df_report = classification_report(true, preds, labels=range(len(encoder.classes_)), target_names=encoder.classes_)\n", "df_report[df_report.support>0]" ] @@ -5508,18 +5496,6 @@ "1" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "ExecuteTime": { - "end_time": "2020-10-07T12:22:51.313045Z", - "start_time": "2020-10-07T12:22:51.218514Z" - } - }, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": 98, @@ -5528,6 +5504,7 @@ "end_time": "2020-10-07T12:58:49.315876Z", "start_time": "2020-10-07T12:55:35.018783Z" }, + "lines_to_next_cell": 0, "scrolled": false }, "outputs": [ @@ -6058,6 +6035,13 @@ "outputs": [], "source": [] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -6121,7 +6105,12 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-07T12:22:51.313045Z", + "start_time": "2020-10-07T12:22:51.218514Z" + } + }, "outputs": [], "source": [] } @@ -6152,7 +6141,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.7.0" }, "toc": { "base_numbering": 1, diff --git a/notebooks/c07_Recurrent_Neural_Networks/Recurrent_Neural_Networks.py b/notebooks/c07_Recurrent_Neural_Networks/Recurrent_Neural_Networks.py index dad3818..f74a68f 100644 --- a/notebooks/c07_Recurrent_Neural_Networks/Recurrent_Neural_Networks.py +++ b/notebooks/c07_Recurrent_Neural_Networks/Recurrent_Neural_Networks.py @@ -761,19 +761,6 @@ def training_loop(x_train, y_train, x_test, y_test, mode, epochs=1, bs=128, max_ # This beats the baseline, so the model is doing better than the naive answer of "the same again". But lets break it down by lithology -# + -import pandas as pd -import sklearn.metrics -import numpy as np - -def classification_report(*args, **kwargs): - out_df = pd.DataFrame(sklearn.metrics.classification_report(*args, **kwargs, output_dict=True)).T - # Order cols - out_df[["precision","recall","f1-score","support"]] - # Round - out_df[["precision","recall","f1-score"]]= out_df[["precision","recall","f1-score"]].apply(lambda x: round(x,2)) - out_df[["support"]]= out_df[["support"]].apply(lambda x: x.astype(np.int)) - return out_df # + @@ -782,6 +769,7 @@ def classification_report(*args, **kwargs): # df_report[df_report.support>0] # - +from deep_ml_curriculum.classification_report import pd_classification_report df_report = classification_report(true, preds, labels=range(len(encoder.classes_)), target_names=encoder.classes_) df_report[df_report.support>0] @@ -977,9 +965,6 @@ def plot_well(df, model, depth_min=0, depth_max=18000, well_name="30_6-11", devi plot_well(df, model) confusion_matrix(true, preds) 1 -# - - - # + # Params seq_length = 400 # CHANGE ME @@ -1035,6 +1020,7 @@ def plot_well(df, model, depth_min=0, depth_max=18000, well_name="30_6-11", devi + # ## Further Reading # - [Introduction to RNN](http://slazebni.cs.illinois.edu/spring17/lec02_rnn.pdf) # - [A friendly introduction to Recurrent Neural Networks](https://www.youtube.com/watch?v=UNmqTiOnRfg)