本文整理汇总了Python中sklearn.linear_model.HuberRegressor.predict方法的典型用法代码示例。如果您正苦于以下问题:Python HuberRegressor.predict方法的具体用法?Python HuberRegressor.predict怎么用?Python HuberRegressor.predict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.linear_model.HuberRegressor
的用法示例。
在下文中一共展示了HuberRegressor.predict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_outliers_by_huber
# 需要导入模块: from sklearn.linear_model import HuberRegressor [as 别名]
# 或者: from sklearn.linear_model.HuberRegressor import predict [as 别名]
def get_outliers_by_huber(self, table, column_indexes):
'''
Get outliers using huber regression, which outperforms RANSAC,
but doesn't scale well when the number of samples are very large.
Huber outputs both perfect precision (100%) and recall (100%) in our experiments.
'''
X = table[ :, column_indexes[ :-1]].astype(float)
X = utils.enforce_columns(X)
y = table[ :, column_indexes[-1]].astype(float)
# preprocessing could make HUBER fail on some dataset in our experiments
#x = preprocessing.minmax_scale(x)
#y = preprocessing.minmax_scale(y)
model_huber = HuberRegressor()
model_huber.fit(X, y)
outlier_mask = model_huber.outliers_
outliers = [idx for idx, val in enumerate(outlier_mask) if val]
residuals = abs(model_huber.predict(X) - y)
confidences = preprocessing.minmax_scale(residuals[outliers])*0.09+0.9
return (outliers, confidences)