svm.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:MultimodalAutoencoder 作者: natashamjaques 项目源码 文件源码
def train_and_predict(self, param_dict, predict_on='val'):
        """Initializes an SVM classifier according to the desired parameter settings, 
        trains it, and returns the predictions on the appropriate evaluation dataset.

        Args:
            param_dict: A dictionary with keys representing parameter names and 
                values representing settings for those parameters.
            predict_on: The dataset used for evaluating the model. Can set to 
                'Test' to get final results.

        Returns: The predicted Y labels.
        """
        if predict_on == 'test':
            predict_X = self.data_loader.test_X
        else:
            predict_X = self.data_loader.val_X

        self.model = SVC(C=param_dict['C'], kernel=param_dict['kernel'], gamma=param_dict['beta'])
        self.model.fit(self.data_loader.train_X, self.data_loader.train_Y)
        preds = self.predict_on_data(predict_X)

        return preds
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号