Skip to content

Commit

Permalink
fix estimator
Browse files Browse the repository at this point in the history
  • Loading branch information
aeiwz committed Oct 11, 2024
1 parent 941ae4c commit 256fd26
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
35 changes: 20 additions & 15 deletions metbit/metbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,14 @@ def fit(self):

oplsda.fit(X, pd.Categorical(y).codes)

s_df_scores_ = pd.DataFrame({'correlation': cv_model.correlation,'covariance': cv_model.covariance}, index=features_name)
df_opls_scores = pd.DataFrame({'t_scores': cv_model.scores, 't_ortho': cv_model.orthogonal_score, 't_pred': cv_model.predictive_score, 'Group': y})
if self.estimator == 'opls':
s_df_scores_ = pd.DataFrame({'correlation': cv_model.correlation,'covariance': cv_model.covariance}, index=features_name)
df_opls_scores = pd.DataFrame({'t_scores': cv_model.scores, 't_ortho': cv_model.orthogonal_score, 't_pred': cv_model.predictive_score, 'Group': y})
self.s_df_scores_ = s_df_scores_
self.df_opls_scores = df_opls_scores
self.oplsda = oplsda
else:
pass



Expand All @@ -275,31 +281,30 @@ def fit(self):
self.R2y = R2y
self.q2 = q2

self.s_df_scores_ = s_df_scores_
self.df_opls_scores = df_opls_scores

self.oplsda = oplsda


self.cv_model = cv_model

T2 = time.time()

duration = T2 - T1

summary_model = f'''
Comparison of {y.unique()[0]} and {y.unique()[1]}
Sample size: {X.shape[0]}
Number of features: {X.shape[1]}
Number of components: {n_components}
Method of scaling: {self.scaling_method}
OPLS-DA model is fitted in {duration} seconds
R2Xcorr: {R2Xcorr}
R2y: {R2y}
Q2: {q2}
Comparison of {y.unique()[0]} and {y.unique()[1]} \n
Sample size: {pd.Series(y).value_counts()} \n
Number of features: {X.shape[1]} \n
Number of components: {n_components} \n
Method of scaling: {self.scaling_method} \n
OPLS-DA model is fitted in {duration} seconds \n
R2Xcorr: {R2Xcorr} \n
R2y: {R2y} \n
Q2: {q2} \n
'''


return print(summary_model)


def get_oplsda_scores(self):

'''
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
setup(
name = 'metbit',
packages = ['metbit'],
version = '5.3.7',
version = '5.3.8',
license='MIT',
description = 'Metabolomics data analysis and visualization tools.',
author = 'aeiwz',
author_email = '[email protected]',
url = 'https://github.com/aeiwz/metbit.git',
download_url = 'https://github.com/aeiwz/metbit/archive/refs/tags/V5.3.7.tar.gz',
download_url = 'https://github.com/aeiwz/metbit/archive/refs/tags/V5.3.8.tar.gz',
keywords = ['Omics', 'Multivariate analysis', 'Visualization', 'Data Analysis', 'Metabolomics', 'Chemometrics'],
install_requires=[
'scikit-learn',
Expand Down

0 comments on commit 256fd26

Please sign in to comment.