|
1 |
| -import numpy as np |
2 | 1 | import argparse
|
3 |
| -from azureml.core import Run |
| 2 | + |
| 3 | +import numpy as np |
| 4 | + |
4 | 5 | from sklearn.externals import joblib
|
5 |
| -from azureml.automl.core.shared import constants, metrics |
| 6 | + |
| 7 | +from azureml.automl.runtime.shared.score import scoring, constants |
| 8 | +from azureml.core import Run |
6 | 9 | from azureml.core.model import Model
|
7 | 10 |
|
8 | 11 |
|
|
29 | 32 | run = Run.get_context()
|
30 | 33 | # get input dataset by name
|
31 | 34 | test_dataset = run.input_datasets['test_data']
|
| 35 | +train_dataset = run.input_datasets['train_data'] |
32 | 36 |
|
33 | 37 | X_test_df = test_dataset.drop_columns(columns=[target_column_name]) \
|
34 | 38 | .to_pandas_dataframe()
|
35 | 39 | y_test_df = test_dataset.with_timestamp_columns(None) \
|
36 | 40 | .keep_columns(columns=[target_column_name]) \
|
37 | 41 | .to_pandas_dataframe()
|
| 42 | +y_train_df = test_dataset.with_timestamp_columns(None) \ |
| 43 | + .keep_columns(columns=[target_column_name]) \ |
| 44 | + .to_pandas_dataframe() |
38 | 45 |
|
39 | 46 | predicted = model.predict_proba(X_test_df)
|
40 | 47 |
|
41 |
| -# use automl metrics module |
42 |
| -scores = metrics.compute_metrics_classification( |
43 |
| - np.array(predicted), |
44 |
| - np.array(y_test_df), |
45 |
| - class_labels=model.classes_, |
46 |
| - metrics=list(constants.Metric.SCALAR_CLASSIFICATION_SET) |
47 |
| -) |
| 48 | +# Use the AutoML scoring module |
| 49 | +class_labels = np.unique(np.concatenate((y_train_df.values, y_test_df.values))) |
| 50 | +train_labels = model.classes_ |
| 51 | +classification_metrics = list(constants.CLASSIFICATION_SCALAR_SET) |
| 52 | +scores = scoring.score_classification(y_test_df.values, predicted, |
| 53 | + classification_metrics, |
| 54 | + class_labels, train_labels) |
48 | 55 |
|
49 | 56 | print("scores:")
|
50 | 57 | print(scores)
|
|
0 commit comments