Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
71 views
in Artificial Intelligence (AI) by (123k points)
How can I implement machine learning algorithms in Python?

Please log in or register to answer this question.

1 Answer

0 votes
by (123k points)

Python offers numerous libraries and frameworks for implementing machine learning algorithms. One popular library is scikit-learn, which provides a wide range of tools for machine learning tasks. Here's an example code snippet to train a simple linear regression model using scikit-learn:

from sklearn.linear_model import LinearRegression

# Sample input features
X = [[1], [2], [3], [4], [5]]

# Corresponding target values
y = [2, 4, 6, 8, 10]

# Create a linear regression model
model = LinearRegression()

# Train the model
model.fit(X, y)

# Make predictions
new_data = [[6], [7]]
predictions = model.predict(new_data)

print(predictions)
 

In this example, the model is trained on a set of input features (X) and corresponding target values (y). Once trained, the model can be used to predict the target values for new input data (new_data).

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...