# Imports 
import os
import re
import bs4
import gzip
import json
import shutil  
import requests
import subprocess
import numpy as np
import pandas as pd
from tqdm import tqdm
import networkx as nx
from bs4 import BeautifulSoup
import xml.etree.ElementTree as ET
from collections import defaultdict
from scipy.sparse import lil_matrix
from sklearn import svm


# ---------------------------------------------------------------------
# train_model (WORKING)
# ---------------------------------------------------------------------

def train_model(kernel, label):
    """
    Fits a Support Vector Classifier with a given precomputed kernel.
    
    :params: kernel: Essentially a square (nxn) matrix.
    :params: labels: Actual labels for the given training data. 
    
    :return: clf: A SVC model fit on a given precomputed kernel.
    """
    clf = svm.SVC(kernel='precomputed')
    clf.fit(kernel,label)
    return clf

# ---------------------------------------------------------------------
# assess_model (WORKING)
# ---------------------------------------------------------------------

def assess_model(model, test_data, label):
    """
    Returns the classification accuracy of a given model. 
    
    :params: model: A model that has already been fit on training data. 
    :params: test_data: A square (nxn) matrix that will be classified. 
    :params: label: Actual labels for the given training data so that we can know our classifiers accuracy.
    
    :return: Accuracy score of a given model. 
    """
    return model.score(test_data,label)
ab1026c3594fa981c1800275e556380eb062540b
<mask token>

<mask token>


def train_model(kernel, label):
    """
    Fits a Support Vector Classifier with a given precomputed kernel.
    
    :params: kernel: Essentially a square (nxn) matrix.
    :params: labels: Actual labels for the given training data. 
    
    :return: clf: A SVC model fit on a given precomputed kernel.
    """
    clf = svm.SVC(kernel='precomputed')
    clf.fit(kernel, label)
    return clf


<mask token>

<mask token>


def train_model(kernel, label):
    """
    Fits a Support Vector Classifier with a given precomputed kernel.
    
    :params: kernel: Essentially a square (nxn) matrix.
    :params: labels: Actual labels for the given training data. 
    
    :return: clf: A SVC model fit on a given precomputed kernel.
    """
    clf = svm.SVC(kernel='precomputed')
    clf.fit(kernel, label)
    return clf


def assess_model(model, test_data, label):
    """
    Returns the classification accuracy of a given model. 
    
    :params: model: A model that has already been fit on training data. 
    :params: test_data: A square (nxn) matrix that will be classified. 
    :params: label: Actual labels for the given training data so that we can know our classifiers accuracy.
    
    :return: Accuracy score of a given model. 
    """
    return model.score(test_data, label)

import os
import re
import bs4
import gzip
import json
import shutil
import requests
import subprocess
import numpy as np
import pandas as pd
from tqdm import tqdm
import networkx as nx
from bs4 import BeautifulSoup
import xml.etree.ElementTree as ET
from collections import defaultdict
from scipy.sparse import lil_matrix
from sklearn import svm


def train_model(kernel, label):
    """
    Fits a Support Vector Classifier with a given precomputed kernel.
    
    :params: kernel: Essentially a square (nxn) matrix.
    :params: labels: Actual labels for the given training data. 
    
    :return: clf: A SVC model fit on a given precomputed kernel.
    """
    clf = svm.SVC(kernel='precomputed')
    clf.fit(kernel, label)
    return clf


def assess_model(model, test_data, label):
    """
    Returns the classification accuracy of a given model. 
    
    :params: model: A model that has already been fit on training data. 
    :params: test_data: A square (nxn) matrix that will be classified. 
    :params: label: Actual labels for the given training data so that we can know our classifiers accuracy.
    
    :return: Accuracy score of a given model. 
    """
    return model.score(test_data, label)

# Imports 
import os
import re
import bs4
import gzip
import json
import shutil  
import requests
import subprocess
import numpy as np
import pandas as pd
from tqdm import tqdm
import networkx as nx
from bs4 import BeautifulSoup
import xml.etree.ElementTree as ET
from collections import defaultdict
from scipy.sparse import lil_matrix
from sklearn import svm


# ---------------------------------------------------------------------
# train_model (WORKING)
# ---------------------------------------------------------------------

def train_model(kernel, label):
    """
    Fits a Support Vector Classifier with a given precomputed kernel.
    
    :params: kernel: Essentially a square (nxn) matrix.
    :params: labels: Actual labels for the given training data. 
    
    :return: clf: A SVC model fit on a given precomputed kernel.
    """
    clf = svm.SVC(kernel='precomputed')
    clf.fit(kernel,label)
    return clf

# ---------------------------------------------------------------------
# assess_model (WORKING)
# ---------------------------------------------------------------------

def assess_model(model, test_data, label):
    """
    Returns the classification accuracy of a given model. 
    
    :params: model: A model that has already been fit on training data. 
    :params: test_data: A square (nxn) matrix that will be classified. 
    :params: label: Actual labels for the given training data so that we can know our classifiers accuracy.
    
    :return: Accuracy score of a given model. 
    """
    return model.score(test_data,label)