Spaces:
Runtime error
Runtime error
File size: 1,397 Bytes
66061aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
from scipy.io import savemat, loadmat
import pandas as pd
import pdb
import json
import numpy as np
from numpy import median, mean
from sklearn.linear_model import BayesianRidge, LinearRegression, RidgeCV, Ridge
from sklearn.neural_network import MLPRegressor
from sklearn.metrics import mean_squared_error, r2_score, mean_absolute_error
from sklearn.model_selection import cross_val_score, LeaveOneOut
import joblib
import pickle
import matplotlib.pyplot as plt
import sys
import os.path
import glob, os
import openbabel
from IPython.display import clear_output
import timeit
ac = loadmat('./data/Test_KEGG_all_grp.mat')
y = ac['y']
y = y.flatten()
alphas = np.logspace(-6, 6, 200)
Xrc = ac['X_comb_all']
regr_rcombined = BayesianRidge(tol=1e-6, fit_intercept=False, compute_score=True).fit(Xrc, y)
y_pred_rc = regr_rcombined.predict(Xrc)
mse_rc = mean_squared_error(y, y_pred_rc)
r2 = r2_score(y, y_pred_rc)
print('radius 1+2 linear model')
print('Mean squared error: %.2f'
% mse_rc)
print('Coefficient of determination: %.4f'
% r2)
s0 = timeit.default_timer()
joblib.dump(regr_rcombined, './model/M12_model_BR.pkl',compress=3)
s1 = timeit.default_timer()
print(s1 - s0)
s0 = timeit.default_timer()
filename = './model/M12_model_BR.pkl'
loaded_model = joblib.load(open(filename, 'rb'))
s1 = timeit.default_timer()
print(s1 - s0)
print('==================================')
|