{"id":10308,"library":"trainstation","title":"Trainstation: Convenient Linear Model Training","description":"Trainstation is a lightweight Python library designed for convenient training and evaluation of linear models. It acts as a simplified wrapper around `scikit-learn`'s linear models, streamlining common workflows. As of version 1.2, it focuses on ease of use for basic linear regression tasks, offering a straightforward API. It has an active release cadence, with minor enhancements and bug fixes.","status":"active","version":"1.2","language":"en","source_language":"en","source_url":"https://github.com/georgestam/trainstation","tags":["machine-learning","linear-models","scikit-learn","wrapper","regression"],"install":[{"cmd":"pip install trainstation","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for linear model implementations, required >=1.0.","package":"scikit-learn","optional":false},{"reason":"Fundamental package for numerical operations and array handling.","package":"numpy","optional":false}],"imports":[{"symbol":"LinearModel","correct":"from trainstation import LinearModel"}],"quickstart":{"code":"from trainstation import LinearModel\nfrom sklearn.datasets import make_regression\nfrom sklearn.model_selection import train_test_split\n\n# Generate synthetic data\nX, y = make_regression(n_samples=1000, n_features=10, random_state=42)\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n\n# Initialize and train the model\nmodel = LinearModel()\nmodel.fit(X_train, y_train)\n\n# Make predictions and evaluate\npredictions = model.predict(X_test)\nscore = model.evaluate(X_test, y_test)\n\nprint(f\"Model score: {score:.4f}\")","lang":"python","description":"This quickstart demonstrates how to initialize `LinearModel`, fit it to training data, make predictions, and evaluate its performance using `sklearn`'s `make_regression` dataset. It covers the core workflow for using `trainstation`."},"warnings":[{"fix":"Use `model.model.coef_` or `model.model.intercept_` to access attributes of the wrapped `sklearn` estimator. The `model.model` attribute provides direct access to the `sklearn` object.","message":"Accessing underlying `scikit-learn` model attributes (e.g., `coef_`, `intercept_`) directly on the `LinearModel` instance will fail.","severity":"gotcha","affected_versions":"All versions up to 1.2"},{"fix":"For fine-grained control, specific regularization, or other `sklearn.linear_model` classes, directly import and use the desired estimator from `scikit-learn`. You can also pass an `sklearn` model class to `LinearModel(model_class=...)`.","message":"`trainstation` provides a simplified API and does not directly expose all advanced `scikit-learn` parameters or specific linear model types (e.g., Ridge, Lasso) by default. It's primarily a wrapper for `sklearn.linear_model.LinearRegression`.","severity":"gotcha","affected_versions":"All versions up to 1.2"},{"fix":"Ensure your input `X` and `y` data are preprocessed (e.g., using `numpy.nan_to_num` or `sklearn.preprocessing.StandardScaler` and `sklearn.impute.SimpleImputer`) before passing them to `model.fit()`.","message":"Data preprocessing steps like handling missing values (NaNs) or feature scaling (e.g., StandardScaler) are not automated by `trainstation`. Input data is expected to be clean and scaled if necessary.","severity":"gotcha","affected_versions":"All versions up to 1.2"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the library using `pip install trainstation`.","cause":"The `trainstation` package is not installed in the current Python environment or is not accessible.","error":"ModuleNotFoundError: No module named 'trainstation'"},{"fix":"Access the underlying `sklearn` model via `model.model` and then its attributes, e.g., `model.model.coef_`.","cause":"You are attempting to access an attribute (like `coef_`, `intercept_`, `n_features_in_`) that belongs to the underlying `scikit-learn` estimator, not the `trainstation.LinearModel` wrapper directly.","error":"AttributeError: 'LinearModel' object has no attribute 'coef_'"},{"fix":"Use the `predict` method for making predictions, e.g., `predictions = model.predict(X_test)`.","cause":"You are trying to call an instance of `LinearModel` directly, as if it were a function, instead of using its `predict` method for making predictions.","error":"TypeError: 'LinearModel' object is not callable"}]}