def transform(self, x=None): if x is None: x, y = load_svmlight(self._test_input_path) x = self._model.transform(x) save_svmlight(x, y, self._test_output_path) else: transformed_x = self._model.transform(x) return transformed_x
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
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)
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)
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
def run(self): x, y = load_svmlight(self._input_path) kf = cross_validation.KFold(len(y), n_folds=self.k) for out_path, (__, test_index) in zip(self._output_path, kf): portion_x, portion_y = x[test_index, :], y[test_index] save_svmlight(portion_x, portion_y, out_path)
def fit_transform(self): self._model = MinMaxScaler() x, y = load_svmlight(self.input_path) x = x.toarray() x = self._model.fit_transform(x, y) save_svmlight(x, y, self._output_path)
def fit_transform(self): self._model = SelectPercentile(f_classif, self._percentile) x, y = load_svmlight(self.input_path) x = self._model.fit_transform(x, y) save_svmlight(x, y, self._output_path)
def fit_transform(self): self._model = VarianceThreshold(threshold=self._threshold) x, y = load_svmlight(self.input_path) x = self._model.fit_transform(x, y) save_svmlight(x, y, self._output_path)
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)