示例#1
0
 def transform(self, x=None):
     if not x:
         x, _ = load_svmlight(self._test_input_path)
         transformed_x = self._model.predict_proba(x)
         save_numpy_txt(transformed_x, self._output_path)
     else:
         transformed_x = self._model.predict_proba(x)
         return transformed_x
示例#2
0
 def fit_transform(self):
     self._model = KNeighborsClassifier(n_neighbors=self._n_neighbors,
                                        weights=self._weights,
                                        algorithm=self._algorithm,
                                        leaf_size=self._leaf_size)
     x, y = load_svmlight(self._input_path)
     self._model.fit(x, y)
     scores = self._model.predict_proba(x)
     save_numpy_txt(scores, self._output_path)
示例#3
0
 def fit_transform(self):
     self._model = RandomForestClassifier(n_estimators=self._n_estimator,
                                          criterion=self._criterion,
                                          max_depth=self._max_depth,
                                          max_features=self._max_features)
     x, y = load_svmlight(self._input_path)
     self._model.fit(x, y)
     scores = self._model.predict_proba(x)
     save_numpy_txt(scores, self._output_path)
示例#4
0
 def transform(self, x=None):
     if x is None:
         _x, y = load_svmlight(self._test_input_path)
         conf_x = self._model.decision_function(_x)
         predicted_x = self._model.predict(_x)
         res = np.vstack((y, conf_x, predicted_x)).T
         save_numpy_txt(res, self._test_output_path)
     else:
         transformed_x = self._model.decision_function(x)
         return transformed_x
示例#5
0
 def fit_transform(self):
     self._model = LinearSVC(C=self._c)
     x, y = load_svmlight(self.input_path)
     self._model.fit(x, y)
     scores = self._model.decision_function(x)
     save_numpy_txt(scores, self.output_path)