- How to take as Input a list of arrays in Keras API
- Tensorflow2.0 - How to convert Tensor to numpy() array
- How to train model for Background removal from images in Machine Learning
- How to calculate confidence score of a Neural Network prediction
- How to parse the heatmap output for the pose estimation tflite model?
- How to solve, No module named 'tf'?
- YOLO (Darknet): How to detect a whole directory of images?
- How to get loss gradient wrt internal layer output in tensorflow 2?
- How to safely shutdown mlflow ui?
- 【CVAT】How to create multiple jobs in one task?
- How to increase accuracy of model using catboost
- How to implement a skip-connection structure between LSTM layers
- How to fix : module 'tensorflow' has no attribute 'Session'
- How to test one single image in pytorch
- Plotly: How to make an annotated confusion matrix using a heatmap?
- How to get the Weight of Evidence (WOE) and Information Value (IV) in Python/pandas?
- How to save weights of keras model for each epoch?
- How to avoid reloading ML model every time when I call python script?
- How to split data based on a column value in sklearn
- How to use sklearn ( chi-square or ANOVA) to removes redundant features
How to print intercept and slope of a simple linear regression in Python with scikit-learn?
Written by- Aionlinecourse1714 times views
To print the intercept and slope of a simple linear regression model in Python using scikit-learn, you can use the intercept_ and coef_ attributes of the LinearRegression object. Here's an example:
Alternatively, you can also use the get_params method to print the intercept and slope, as well as other parameters of the model:
This will print a dictionary containing the parameters of the model, including the intercept and slope.
from sklearn.linear_model import LinearRegressionThis will print the intercept and slope of the fitted linear regression model.
# fit a linear regression model
X = [[1], [2], [3], [4]]
y = [1, 2, 3, 4]
model = LinearRegression().fit(X, y)
# print the intercept and slope
print("Intercept:", model.intercept_)
print("Slope:", model.coef_)
Alternatively, you can also use the get_params method to print the intercept and slope, as well as other parameters of the model:
print(model.get_params())
This will print a dictionary containing the parameters of the model, including the intercept and slope.