<jupyter_start><jupyter_text>Dasar Regresi Linear $y = ax + b$$y$ = target$x$ = satu fitur$a, b$ = parameter dari modelBagiamana memilih $a$ dan $b$Mencari fungsi error di setiap garis    - Kemudian meminimalkan error  Loss Function   Regresi Linear Dimensi TInggi $ y = a_1 x_1 + a_2 x_2 + a_n x_n +  b $<jupyter_code>X = X.values
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y,
                                                    test_size = 0.3, random_state=42)
reg_all = linear_model.LinearRegression()
reg_all.fit(X_train, y_train)
y_pred = reg_all.predict(X_test)
reg_all.score(X_test, y_test)<jupyter_output><empty_output><jupyter_text>Cross Validation - Performa model tergantung dari data yang split- Model idak mampun mengeneralisasi data- Solusi Cross Validation  - 5 folds = 5 folds CV- 10 folds = 5 folds CV- k folds = k folds CV<jupyter_code>from sklearn.model_selection import cross_val_score
reg = linear_model.LinearRegression()
cv_results = cross_val_score(reg, X, y, cv=5)
print(cv_results)
np.mean(cv_results)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08904719501335707, 'fraction_numerical': 0.012466607301869992, 'mean_word_length': 4.482926829268293, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '619844', 'license': 'MIT', 'n_tokens_mistral': 433, 'n_tokens_neox': 410, 'n_words': 105, 'path': 'Bagian 7 - Supervised Learning/2. Regresi Linear dan Cross Validation.ipynb', 'repo_name': 'DimasWidyatama/Fundamental-Pandas', 'size': '1123'}