You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After that I created a code which gets the symbolic formula of KAN and calculate given inputs according to given formula.
The function is below:
defkan_symbolic_formula_prediction(formula, X):
batch=X.shape[0]
predictions= [] # Empty list for keeping predictionsforiinrange(batch):
# Evaluation on symbolic formula on every single rowexpression=formulaforjinrange(X.shape[1]):
expression=expression.subs(f'x_{j+1}', X[i, j])
# Get output of formulapredicted=float(expression.evalf())
predictions.append(predicted)
returnpredictions
Then I get prediction by using formula like that:
# Get results using symbolic formulapreds_from_kan_formula=kan_symbolic_formula_prediction(formula, X_train.to_numpy())
and here is metrics model.forward() and symbolic formula respectively:
print("MAE from formula on train data",mean_absolute_error(train_labels.numpy(),preds_from_kan_formula))
print("R2 from formula on train data",r2_score(train_labels.numpy(), preds_from_kan_formula))
MAEfromformulaontraindata0.15750130512335783R2fromformulaontraindata-0.47894340657227064
print("MAE from model.forward() on train data",mean_absolute_error(train_labels.numpy(), train_preds.numpy()))
print("R2 from model.forward() on train data",r2_score(train_labels.numpy(), train_preds.numpy()))
MAEfrommodel.forward() ontraindata0.04164282R2frommodel.forward() ontraindata0.8345471009872176
As you see symbolic formula performs badly. What do you think about it ?
Hi, since only a limited library of symbolic formulas is provided, it could be that the real symbolic formula is not supported in the library, or even the formula is not symbolic at all. It might be helpful to stare at the learned KAN plot a bit by calling model.plot(), trying to get a sense of what's going on. For example, are there any activation functions that look particularly suspicious?
Hi
I have been practicing about KAN. I have made regression implementation. My output layer has 1 node.
After implementation I got pretty good R2 and MAE on my dataset (including train val test). I wanted to get symbolic formula and I got it according to => https://kindxiaoming.github.io/pykan/Examples/Example_3_classfication.html
After that I created a code which gets the symbolic formula of KAN and calculate given inputs according to given formula.
The function is below:
Then I get prediction by using formula like that:
and here is metrics model.forward() and symbolic formula respectively:
Here is my full code => https://www.kaggle.com/code/seyidcemkarakas/kan-regression-graduate-admissions
The text was updated successfully, but these errors were encountered: