66import os
77
88
9- from ..entities . flow import OpenMLFlow
9+ from ..flows import OpenMLFlow
1010from ..exceptions import OpenMLCacheException
1111from ..util import URLError
1212from ..tasks import download_task
@@ -16,7 +16,7 @@ class OpenMLRun(object):
1616 def __init__ (self , task_id , flow_id , setup_string , dataset_id , files = None ,
1717 setup_id = None , tags = None , run_id = None , uploader = None ,
1818 uploader_name = None , evaluations = None , data_content = None ,
19- classifier = None , task_type = None , task_evaluation_measure = None ,
19+ model = None , task_type = None , task_evaluation_measure = None ,
2020 flow_name = None , parameter_settings = None , predictions_url = None ):
2121 self .run_id = run_id
2222 self .uploader = uploader
@@ -33,7 +33,7 @@ def __init__(self, task_id, flow_id, setup_string, dataset_id, files=None,
3333 self .predictions_url = predictions_url
3434 self .evaluations = evaluations
3535 self .data_content = data_content
36- self .classifier = classifier
36+ self .model = model
3737
3838 def generate_arff (self , api_connector ):
3939 """Generates an arff
@@ -81,48 +81,49 @@ def create_description_xml(self):
8181 run_environment = get_version_information ()
8282 setup_string = '' # " ".join(sys.argv);
8383
84- parameter_settings = self .classifier .get_params ()
84+ parameter_settings = self .model .get_params ()
8585 # as a tag, it must be of the form ([a-zA-Z0-9_\-\.])+
8686 # so we format time from 'mm/dd/yy hh:mm:ss' to 'mm-dd-yy_hh.mm.ss'
8787 well_formatted_time = time .strftime ("%c" ).replace (
8888 ' ' , '_' ).replace ('/' , '-' ).replace (':' , '.' )
8989 tags = run_environment + [well_formatted_time ] + ['openml_run' ] + \
90- [self .classifier .__module__ + "." + self .classifier .__class__ .__name__ ]
90+ [self .model .__module__ + "." + self .model .__class__ .__name__ ]
9191 description = construct_description_dictionary (
9292 self .task_id , self .flow_id , setup_string , parameter_settings , tags )
9393 description_xml = xmltodict .unparse (description , pretty = True )
9494 return description_xml
9595
9696
97- def openml_run (connector , task , classifier ):
97+ def openml_run (connector , task , model ):
9898 """Performs a CV run on the dataset of the given task, using the split.
9999
100100 Parameters
101101 ----------
102102 connector : APIConnector
103103 Openml APIConnector which is used to download the OpenML Task and Dataset
104104 taskid : int
105- The integer identifier of the task to run the classifier on
106- classifier : sklearn classifier
107- a classifier which has a function fit(X,Y) and predict(X),
108- all supervised estimators of scikit learn follow this definition of a classifier [1]
105+ The integer identifier of the task to run the model on
106+ model : sklearn model
107+ a model which has a function fit(X,Y) and predict(X),
108+ all supervised estimators of scikit learn follow this definition of a model [1]
109109 [1](http://scikit-learn.org/stable/tutorial/statistical_inference/supervised_learning.html)
110110
111111
112112 Returns
113113 -------
114- classifier : sklearn classifier
115- the classifier , trained on the whole dataset
114+ model : sklearn model
115+ the model , trained on the whole dataset
116116 arff-dict : dict
117117 a dictionary with an 'attributes' and 'data' entry for an arff file
118118 """
119- flow_id = OpenMLFlow .ensure_flow_exists (task .api_connector , classifier )
119+ flow = OpenMLFlow (model = model )
120+ flow_id = flow .ensure_flow_exists (task .api_connector )
120121 if (flow_id < 0 ):
121122 print ("No flow" )
122123 return 0 , 2
123124 print (flow_id )
124125
125- #runname = "t" + str(task.task_id) + "_" + str(classifier )
126+ #runname = "t" + str(task.task_id) + "_" + str(model )
126127 arff_datacontent = []
127128
128129 dataset = task .get_dataset ()
@@ -132,7 +133,7 @@ def openml_run(connector, task, classifier):
132133 if class_labels is None :
133134 raise ValueError ('The task has no class labels. This method currently '
134135 'only works for tasks with class labels.' )
135- setup_string = create_setup_string (classifier )
136+ setup_string = create_setup_string (model )
136137
137138 run = OpenMLRun (task .task_id , flow_id , setup_string , dataset .id )
138139
@@ -149,9 +150,9 @@ def openml_run(connector, task, classifier):
149150 testY = Y [test_indices ]
150151
151152 start_time = time .time ()
152- classifier .fit (trainX , trainY )
153- ProbaY = classifier .predict_proba (testX )
154- PredY = classifier .predict (testX )
153+ model .fit (trainX , trainY )
154+ ProbaY = model .predict_proba (testX )
155+ PredY = model .predict (testX )
155156 end_time = time .time ()
156157
157158 train_times .append (end_time - start_time )
@@ -166,7 +167,7 @@ def openml_run(connector, task, classifier):
166167 rep_no = rep_no + 1
167168
168169 run .data_content = arff_datacontent
169- run .classifier = classifier .fit (X , Y )
170+ run .model = model .fit (X , Y )
170171 return run
171172
172173
@@ -213,10 +214,10 @@ def construct_description_dictionary(taskid, flow_id, setup_string,
213214 return description
214215
215216
216- def create_setup_string (classifier ):
217+ def create_setup_string (model ):
217218 run_environment = " " .join (get_version_information ())
218- # fixme str(classifier ) might contain (...)
219- return run_environment + " " + str (classifier )
219+ # fixme str(model ) might contain (...)
220+ return run_environment + " " + str (model )
220221
221222
222223# This can possibly be done by a package such as pyxb, but I could not get
0 commit comments