Train Scikit-Learn model
Train Scikit-Learn model on provided data (X, y). The X should be DataFrame or NumPy array with input data matrix. The y is a target attribute, with values that will be learn by model. User can specify sample weight, which describes how important is each sample, in the advanced options. This method can train any model that implements Scikit-Learn API.
Required packages
You need below packages to use the code generated by recipe. All packages are automatically installed in MLJAR Studio.
scikit-learn>=1.5.0
Interactive recipe
You can use below interactive recipe to generate code. This recipe is available in MLJAR Studio.
In the below recipe, we assume that you have following variables available in your notebook:
- my_classifier (type DecisionTreeClassifier)
- my_regressor (type DecisionTreeRegressor)
- X (type DataFrame)
- y (type Series)
Python code
# Python code will be here
Code explanation
This code fits model on training data (X, y). The training time depends on data size (number or rows and columns) and algorithm complexity.
Example Python notebooks
Please find inspiration in example notebooks
- Train Random Forest regressor
The `scikit-learn` provides implementation of [Random Forest](/glossary/random-forest/) ...
- Visualize Decision Tree
The Decision Tree algorithm's structure is human-readable, a key advantage. In ...
- Decision Tree features importance
`Scikit-learn's` permutation importance assesses the impact of each feature on ...
- Train Decision Tree classifier
Classification is a task of predicting discrete target labels. The Python `scikit-learn` ...
- Train Decision Tree on Iris data set
Python is a great choice for Machine Learning projects, because of rich ML packages ...
- Train Decision Tree regressor
Train a Decision Tree Regressor using scikit-learn. This machine learning algorithm ...
- Train Random Forest classifier
Python implementation of Random Forest algorithm available in `scikit-learn` package ...
- Save and load Decision Tree
`Scikit-learn` provides Decision Tree algorithms for classification (`DecisionTreeClassifier`) ...
- Tune Decision Tree classifier
This notebook demonstrates tuning a Decision Tree model. We'll find the best hyperparameters ...
Scikit-learn cookbook
Code recipes from Scikit-learn cookbook.
- « Previous
- k-Nearest Neighbors
- Next »
- Compute Predictions