Top Links Menu
Showing posts with label Equation. Show all posts
Showing posts with label Equation. Show all posts
Apr 8, 2026
Aug 2, 2025
Xgboost, PySR, AL Feynman, Ensemble
PySR
------
https://julialang.org/downloads/
pip install pysr
python -m julia.install
import pandas as pd
from pysr import PySRRegressor
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
# === BACA DATA ===
df = pd.read_csv("prediction.csv")
# === DEFINISI FITUR DAN TARGET ===
X = df[['Power', 'Speed', 'Spot', 'Thickness', 'Conductivity']]
y = df['Depth']
# === NORMALISASI (opsional tapi direkomendasikan) ===
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
# === SPLIT DATA ===
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, test_size=0.2, random_state=42)
# === INISIALISASI MODEL PySR ===
model = PySRRegressor(
niterations=1000, # ITERASI MAKSIMUM
model_selection="best",
binary_operators=["+", "-", "*", "/"],
unary_operators=[
"cos", "sin", "exp", "log", "sqrt", "abs"
],
extra_sympy_mappings={"sqrt": lambda x: x**0.5},
loss="loss(x, y) = (x - y)^2", # MSE
verbosity=1,
turbo=True,
maxsize=50,
populations=20,
ncyclesperiteration=300,
)
# === LATIH MODEL ===
model.fit(X_train, y_train)
# === CETAK RUMUS TERBAIK ===
print("\n=== RUMUS TERBAIK DARI PySR ===")
print(model.get_best())
# === PREDIKSI DAN SIMPAN HASIL ===
y_pred = model.predict(X_test)
output = pd.DataFrame(X_test, columns=X.columns)
output['Actual'] = y_test.values
output['Predicted'] = y_pred
output['Error'] = y_test.values - y_pred
output['Abs_Error'] = abs(output['Error'])
output.to_excel("pysr_output.xlsx", index=False)
print("File 'pysr_output.xlsx' telah dibuat.")
-----------------------------------------------------------------------------
Xgboost
Aug 19, 2024
May 2, 2024
Oct 7, 2023
Nov 6, 2022
Apr 13, 2022
Apr 12, 2022
Apr 6, 2022
Mar 30, 2022
Subscribe to:
Posts (Atom)

%20-%20Copy.png)
%20-%20Copy.png)
.png)