Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def predict_row(row, clf):
- """
- Transform row to a 1-row pandas.DataFrame and predict
- When iterating of rows of a DataFrame, each row is represented as a
- pd.Series. The classifiers in use are expecting a DataFrame. This function
- turns the row into a 1 x n_featurs DataFrame and apply the prediction of a
- trained classier.
- Parameters
- ----------
- row : pandas.Series
- An instance from the data.
- clf
- Predictor which expects the features which are the index of ``row``
- and is already trained
- Returns
- -------
- int
- Value of the prediction
- """
- return clf.predict(
- pd.DataFrame(row).T
- )[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement