|
1 | 1 | # Copyright 2016 The TF Codelab Contributors. All Rights Reserved.
|
2 | 2 | # Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
3 | 3 | # http://www.apache.org/licenses/LICENSE-2.0
|
4 |
| -# |
| 4 | +# |
5 | 5 | # This code was originaflly presented at GDGSpain DevFest
|
6 | 6 | # using character prediction from Tensorflow
|
7 | 7 | # https://github.com/bigpress/gameofthrones/blob/master/character-predictions.csv
|
8 | 8 | #
|
9 | 9 | # Latest version is always available at: https://github.com/codelab-tf-got/code/
|
10 | 10 | # Codelab test is available at: https://codelab-tf-cot.github.io
|
11 |
| -# Codelab code by @ssice . Front @SoyGema |
| 11 | +# Codelab code by @ssice . Front @SoyGema |
12 | 12 | # ==============================================================================
|
13 | 13 |
|
14 | 14 | """Import Python 2-3 compatibility glue, ETL (pandas) and ML (TensorFlow/sklearn) libraries"""
|
|
26 | 26 | from tensorflow.contrib.learn.python.learn.utils import input_fn_utils
|
27 | 27 | from tensorflow.contrib.learn.python.learn.utils import saved_model_export_utils
|
28 | 28 |
|
29 |
| -from sklearn import cross_validation # to split the train/test cases |
| 29 | +from sklearn import model_selection # to split the train/test cases |
30 | 30 |
|
31 | 31 |
|
32 | 32 | ## Uncomment the logging lines to see logs in the console
|
@@ -164,7 +164,7 @@ def get_dataset(filename, local_path='../dataset'):
|
164 | 164 | preset_deep_columns = []
|
165 | 165 |
|
166 | 166 | def get_deep_columns():
|
167 |
| - """Obtains the deep columns of the model. |
| 167 | + """Obtains the deep columns of the model. |
168 | 168 |
|
169 | 169 | In our model, these are the binary columns (which are embedded with
|
170 | 170 | keys "0" and "1") and the categorical columns, which are embedded as
|
@@ -223,7 +223,7 @@ def get_wide_columns():
|
223 | 223 | ##############################################################################
|
224 | 224 | def build_estimator(model_dir):
|
225 | 225 | """General estimator builder function.
|
226 |
| - |
| 226 | +
|
227 | 227 | The wide/deep part construction is below. This gathers both parts
|
228 | 228 | and joins the model into a single classifier.
|
229 | 229 |
|
@@ -349,7 +349,7 @@ def _experiment_fn(output_dir):
|
349 | 349 | )
|
350 | 350 | return experiment
|
351 | 351 | return _experiment_fn
|
352 |
| - |
| 352 | + |
353 | 353 |
|
354 | 354 | def fill_dataframe(df_base):
|
355 | 355 | """
|
@@ -378,7 +378,7 @@ def train_and_eval(job_dir=None):
|
378 | 378 | df_base[LABEL_COLUMN] = (
|
379 | 379 | df_base[LABEL_COLUMN].apply(lambda x: x)).astype(int)
|
380 | 380 |
|
381 |
| - df_train, df_test = cross_validation.train_test_split(df_base, test_size=0.2, random_state=42) |
| 381 | + df_train, df_test = model_selection.train_test_split(df_base, test_size=0.2, random_state=42) |
382 | 382 |
|
383 | 383 | model_dir = tempfile.mkdtemp() if not FLAGS.model_dir else FLAGS.model_dir
|
384 | 384 | print("model directory = %s" % model_dir)
|
|
0 commit comments