lasso
This commit is contained in:
parent
c6bb97b942
commit
02d26d974f
@ -1,6 +1,6 @@
|
|||||||
import awkward as ak
|
import awkward as ak
|
||||||
from sklearn.preprocessing import PolynomialFeatures
|
from sklearn.preprocessing import PolynomialFeatures
|
||||||
from sklearn.linear_model import LinearRegression
|
from sklearn.linear_model import LinearRegression, Lasso
|
||||||
from sklearn.model_selection import train_test_split
|
from sklearn.model_selection import train_test_split
|
||||||
from sklearn.metrics import mean_squared_error
|
from sklearn.metrics import mean_squared_error
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -71,7 +71,7 @@ def fit_linear_regression_model(
|
|||||||
X_test_model = np.delete(X_test_model, remove, axis=1)
|
X_test_model = np.delete(X_test_model, remove, axis=1)
|
||||||
poly_features = np.delete(poly_features, remove)
|
poly_features = np.delete(poly_features, remove)
|
||||||
|
|
||||||
lin_reg = LinearRegression(fit_intercept=fit_intercept)
|
lin_reg = LinearRegression(fit_intercept=fit_intercept) # Lasso(alpha=0.01)
|
||||||
lin_reg.fit(X_train_model, y_train)
|
lin_reg.fit(X_train_model, y_train)
|
||||||
y_pred_test = lin_reg.predict(X_test_model)
|
y_pred_test = lin_reg.predict(X_test_model)
|
||||||
print(f"Parameterisation for {target_feat}:")
|
print(f"Parameterisation for {target_feat}:")
|
||||||
|
File diff suppressed because one or more lines are too long
@ -38,12 +38,10 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"# selektiere nur elektronen von B->K*ee\n",
|
"# selektiere nur elektronen von B->K*ee\n",
|
||||||
"allcolumns = file.arrays()\n",
|
"allcolumns = file.arrays()\n",
|
||||||
"found = allcolumns[\n",
|
"found = allcolumns[(allcolumns.isElectron) & (~allcolumns.lost) &\n",
|
||||||
" (allcolumns.isElectron) & (~allcolumns.lost) & (allcolumns.fromB)\n",
|
" (allcolumns.fromB)] # B: 9056\n",
|
||||||
"] # B: 9056\n",
|
"lost = allcolumns[(allcolumns.isElectron) & (allcolumns.lost) &\n",
|
||||||
"lost = allcolumns[\n",
|
" (allcolumns.fromB)] # B: 1466\n",
|
||||||
" (allcolumns.isElectron) & (allcolumns.lost) & (allcolumns.fromB)\n",
|
|
||||||
"] # B: 1466\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"electrons = allcolumns[(allcolumns.isElectron) & (allcolumns.fromB)]\n",
|
"electrons = allcolumns[(allcolumns.isElectron) & (allcolumns.fromB)]\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -225,14 +223,16 @@
|
|||||||
" y = found[\"ideal_state_9410_y\"]\n",
|
" y = found[\"ideal_state_9410_y\"]\n",
|
||||||
" qop = found[\"ideal_state_9410_qop\"]\n",
|
" qop = found[\"ideal_state_9410_qop\"]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"data = ak.zip({\n",
|
"data = ak.zip(\n",
|
||||||
" \"rad_length_frac\": rad_length_frac,\n",
|
" {\n",
|
||||||
" \"x\": x,\n",
|
" \"rad_length_frac\": rad_length_frac,\n",
|
||||||
" \"y\": y,\n",
|
" \"x\": x,\n",
|
||||||
" \"tx\": slopex,\n",
|
" \"y\": y,\n",
|
||||||
" \"ty\": slopey,\n",
|
" \"tx\": slopex,\n",
|
||||||
" \"qop\": qop,\n",
|
" \"ty\": slopey,\n",
|
||||||
"})\n",
|
" \"qop\": qop,\n",
|
||||||
|
" }\n",
|
||||||
|
")\n",
|
||||||
"lin_reg, features, xx0_test, xx0_predicted = fit_linear_regression_model(\n",
|
"lin_reg, features, xx0_test, xx0_predicted = fit_linear_regression_model(\n",
|
||||||
" data,\n",
|
" data,\n",
|
||||||
" \"rad_length_frac\",\n",
|
" \"rad_length_frac\",\n",
|
||||||
@ -357,16 +357,14 @@
|
|||||||
" y = lost[\"ideal_state_9410_y\"]\n",
|
" y = lost[\"ideal_state_9410_y\"]\n",
|
||||||
" qop = lost[\"ideal_state_9410_qop\"]\n",
|
" qop = lost[\"ideal_state_9410_qop\"]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"data = ak.zip(\n",
|
"data = ak.zip({\n",
|
||||||
" {\n",
|
" \"rad_length_frac\": rad_length_frac,\n",
|
||||||
" \"rad_length_frac\": rad_length_frac,\n",
|
" \"x\": x,\n",
|
||||||
" \"x\": x,\n",
|
" \"y\": y,\n",
|
||||||
" \"y\": y,\n",
|
" \"tx\": slopex,\n",
|
||||||
" \"tx\": slopex,\n",
|
" \"ty\": slopey,\n",
|
||||||
" \"ty\": slopey,\n",
|
" \"qop\": qop,\n",
|
||||||
" \"qop\": qop,\n",
|
"})\n",
|
||||||
" }\n",
|
|
||||||
")\n",
|
|
||||||
"lin_reg, features, xx0_test, xx0_predicted = fit_linear_regression_model(\n",
|
"lin_reg, features, xx0_test, xx0_predicted = fit_linear_regression_model(\n",
|
||||||
" data,\n",
|
" data,\n",
|
||||||
" \"rad_length_frac\",\n",
|
" \"rad_length_frac\",\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user