Git Product home page Git Product logo

owrestimator's Issues

'Main_platform' can't be use into the model pipeline

Summary

In model_pipeline.py, we are trying to build a ML pipeline using all features in our dataset. The dataset contains categorical feature such as 'main_platform'. We use pd.get_dummies to transform this feature into a dummy one. However some values of 'main_platform' presents in training set are not in the test set, resulting into an error.

Steps to reproduce

Download the repo and run model_pipeline.py.

Expected behavior

We should get a MAE score printed in the terminal at the very end. Instead, we get an error.

Actual behavior

We get the following error :

  File "C:\Users\charl\miniconda3\lib\site-packages\pandas\core\indexes\base.py", line 3080, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas\_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\hashtable_class_helper.pxi", line 4554, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas\_libs\hashtable_class_helper.pxi", line 4562, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'main_platform'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\charl\miniconda3\lib\site-packages\sklearn\utils\__init__.py", line 396, in _get_column_indices
    col_idx = all_columns.get_loc(col)
  File "C:\Users\charl\miniconda3\lib\site-packages\pandas\core\indexes\base.py", line 3082, in get_loc
    raise KeyError(key) from err
KeyError: 'main_platform'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\Users\charl\OneDrive\Documents\Projects\OWREstimator\src\model_pipeline.py", line 80, in <module>
    model_pipeline.fit(X_train,y_train)
  File "C:\Users\charl\miniconda3\lib\site-packages\sklearn\pipeline.py", line 341, in fit
    Xt = self._fit(X, y, **fit_params_steps)
  File "C:\Users\charl\miniconda3\lib\site-packages\sklearn\pipeline.py", line 303, in _fit
    X, fitted_transformer = fit_transform_one_cached(
  File "C:\Users\charl\miniconda3\lib\site-packages\joblib\memory.py", line 352, in __call__
    return self.func(*args, **kwargs)
  File "C:\Users\charl\miniconda3\lib\site-packages\sklearn\pipeline.py", line 754, in _fit_transform_one
    res = transformer.fit_transform(X, y, **fit_params)
  File "C:\Users\charl\miniconda3\lib\site-packages\sklearn\compose\_column_transformer.py", line 505, in fit_transform
    self._validate_remainder(X)
  File "C:\Users\charl\miniconda3\lib\site-packages\sklearn\compose\_column_transformer.py", line 332, in _validate_remainder
    cols.extend(_get_column_indices(X, columns))
  File "C:\Users\charl\miniconda3\lib\site-packages\sklearn\utils\__init__.py", line 403, in _get_column_indices
    raise ValueError(
ValueError: A given column is not a column of the dataframe```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.