This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scipy.special import logsumexp | |
| class BernoulliMixture: | |
| def __init__(self, n_components, max_iter, tol=1e-3): | |
| self.n_components = n_components | |
| self.max_iter = max_iter | |
| self.tol = tol | |
| def fit(self,x): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AttentionPool(nn.Module): | |
| def __init__(self, embed_dim): | |
| self.attention = nn.Linear(embed_dim, 1) | |
| def forward(self, x): # x: (batch, seq_len, embed_dim) | |
| scores = self.attention(x) # (batch, seq_len, 1) | |
| weights = F.softmax(scores, dim=1) # (batch, seq_len, 1) | |
| return (weights * x).sum(dim=1) # (batch, embed_dim) | |
| class ReasonCodeTransformer(nn.Module): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from evidently.report import Report | |
| from evidently.metric_preset import DataDriftPreset, ConceptDriftPreset | |
| from evidently.test_suite import TestSuite | |
| from evidently.tests import DataDriftTest, ConceptDriftTest | |
| # Load your data | |
| reference_data = pd.read_csv('reference_data.csv') # Your initial training data | |
| current_data = pd.read_csv('current_data.csv') # Your new production data |