Loading...
By KarnatakaPUCS Team on 7/10/2026
Machine Learning is transforming technology. Learn the basics and start your ML journey with Python.
Machine Learning enables computers to learn from data without explicit programming.
pythonfrom sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_error import numpy as np # Sample data X = np.array([[1], [2], [3], [4], [5]]) y = np.array([2, 4, 5, 4, 5]) # Split data X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.2, random_state=42 ) # Create and train model model = LinearRegression() model.fit(X_train, y_train) # Make predictions predictions = model.predict(X_test) print(f"MSE: {mean_squared_error(y_test, predictions)}")