Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LAB4 GetPoint与scoreAndLabels的内容问题 #18

Open
ifrozenwhale opened this issue Dec 22, 2020 · 2 comments
Open

LAB4 GetPoint与scoreAndLabels的内容问题 #18

ifrozenwhale opened this issue Dec 22, 2020 · 2 comments

Comments

@ifrozenwhale
Copy link

提供的源代码中GetPoint函数如下,注释说返回的是预测得分。

def GetPoint(model,point):
    """
    预测并返回结果(元组)
    :param model: 训练集构建的SVMWithSGD模型
    :param point: 测试集数据,标准LabeledPoint类型数据
    :return:(测试集预测得分,原始标签)
    """
    score = model.predict(point.features)
    return (score,point.label)

结合后续的scoreAndLabels推测,这里输出的应该是(预测得分,原始标签),并且指导书中也给出了输出样例:

……
-59045.132228013084 1.0
-81550.17634254562 1.0
-87393.69932070676 1.0
……

但是,当指定了threshold后(默认-90000),model.predict返回的应该是预测的0-1值,如下:

    @since('0.9.0')
    def predict(self, x):
        """
        Predict values for a single data point or an RDD of points
        using the model trained.
        """
        if isinstance(x, RDD):
            return x.map(lambda v: self.predict(v))

        x = _convert_to_vector(x)
        margin = self.weights.dot(x) + self.intercept
        if self._threshold is None:
            return margin
        else:
            return 1 if margin > self._threshold else 0

不知道如何输出指导书中的原始预测值,是将threshold置None了吗先?

@Wanghui-Huang
Copy link
Owner

感谢反馈~是的,scoreAndLabels示例输出是没有设置threshold的。这里描述不太清楚,后面我们整个大数据实验还要进行一次较大修正,特别是ex4实验将会被替换或者大改。
另外请问一下,我们大数据这门课已经结课了,冯老师班已经实验和答辩都结束了。你是尚老师大数据班的吗?

@ifrozenwhale
Copy link
Author

感谢反馈~是的,scoreAndLabels示例输出是没有设置threshold的。这里描述不太清楚,后面我们整个大数据实验还要进行一次较大修正,特别是ex4实验将会被替换或者大改。

另外请问一下,我们大数据这门课已经结课了,冯老师班已经实验和答辩都结束了。你是尚老师大数据班的吗?

是的,因为昨天交实验报告,检查了一下,才注意到这个问题~好的,助教辛苦了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants