csinva / imodelsx Goto Github PK
View Code? Open in Web Editor NEWScikit-learn friendly library to interpret, and prompt-engineer text datasets using large language models.
Home Page: https://csinva.io/imodelsX/
License: MIT License
Scikit-learn friendly library to interpret, and prompt-engineer text datasets using large language models.
Home Page: https://csinva.io/imodelsX/
License: MIT License
I was wondering if this implementation allowed for multiple hidden layers that is key in getting good performance.
How can one get class scores from KAN_Classifier? predict_proba returns 0 and 1 instead of class scores it seems.
Hello, I am using the code:
import numpy as np
from imodelsx import explain_module_sasc
mod = lambda str_list: np.array([len(s) for s in str_list])
text_str_list = ["red", "blue", "x", "1", "2", "hippopotamus", "elephant", "rhinoceros"]
explanation_dict = explain_module_sasc(
text_str_list,
mod,
ngrams=1,
)
print(explanation_dict)
Errors will be encountered:
name 'openai' is not defined
How to solve this problem. thank you.
RuntimeError Traceback (most recent call last)
Cell In[25], line 10
7 X, y = make_classification(n_samples=5000, n_features=5, n_informative=3)
8 model = imodelsx.KANClassifier(hidden_layer_size=64, device='cpu',
9 regularize_activation=1.0, regularize_entropy=1.0)
---> 10 model.fit(X, y)
11 y_pred = model.predict(X)
12 print('Test acc', accuracy_score(y, y_pred))
File ~/opt/anaconda3/envs/py311/lib/python3.11/site-packages/imodelsx/kan/kan_sklearn.py:80, in KAN.fit(self, X, y, batch_size, lr, weight_decay, gamma)
78 x = x.view(-1, num_features).to(self.device)
79 optimizer.zero_grad()
---> 80 output = self.model(x).squeeze()
81 loss = criterion(output, labs.to(self.device).squeeze())
82 if isinstance(self, (KANGAMClassifier, KANGAMRegressor)):
File ~/opt/anaconda3/envs/py311/lib/python3.11/site-packages/torch/nn/modules/module.py:1511, in Module._wrapped_call_impl(self, *args, **kwargs)
1509 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1510 else:
-> 1511 return self._call_impl(*args, **kwargs)
File ~/opt/anaconda3/envs/py311/lib/python3.11/site-packages/torch/nn/modules/module.py:1520, in Module._call_impl(self, *args, **kwargs)
1515 # If we don't have any hooks, we want to skip the rest of the logic in
1516 # this function, and just call forward.
1517 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1518 or _global_backward_pre_hooks or _global_backward_hooks
1519 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1520 return forward_call(*args, **kwargs)
1522 try:
1523 result = None
File ~/opt/anaconda3/envs/py311/lib/python3.11/site-packages/imodelsx/kan/kan_modules.py:296, in KANModule.forward(self, x, update_grid)
294 if update_grid:
295 layer.update_grid(x)
--> 296 x = layer(x)
297 return x
File ~/opt/anaconda3/envs/py311/lib/python3.11/site-packages/torch/nn/modules/module.py:1511, in Module._wrapped_call_impl(self, *args, **kwargs)
1509 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1510 else:
-> 1511 return self._call_impl(*args, **kwargs)
File ~/opt/anaconda3/envs/py311/lib/python3.11/site-packages/torch/nn/modules/module.py:1520, in Module._call_impl(self, *args, **kwargs)
1515 # If we don't have any hooks, we want to skip the rest of the logic in
1516 # this function, and just call forward.
1517 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1518 or _global_backward_pre_hooks or _global_backward_hooks
1519 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1520 return forward_call(*args, **kwargs)
1522 try:
1523 result = None
File ~/opt/anaconda3/envs/py311/lib/python3.11/site-packages/imodelsx/kan/kan_modules.py:173, in KANLinearModule.forward(self, x)
170 def forward(self, x: torch.Tensor):
171 assert x.dim() == 2 and x.size(1) == self.in_features
--> 173 base_output = F.linear(self.base_activation(x), self.base_weight)
174 spline_output = F.linear(
175 self.b_splines(x).view(x.size(0), -1),
176 self.scaled_spline_weight.view(self.out_features, -1),
177 )
178 return base_output + spline_output
RuntimeError: expected m1 and m2 to have the same dtype, but got: float != double
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.