Skip to main content

More options to ensemble your models

Project description

MoreModels

A python library allowing you to use multiple models using the weight of each model based on their performance

install using

pip install moremodels

Example code for WeightedModels Object:

from moremodels import WeightedModels

model1 = catboost.CatBoostRegressor()
model2 = RandomForestRegressor()
model3 = xgboost.XGBRegressor()

my_data = pd.read('my_data.csv')
test = pd.read('test.csv)

my_models = [model1, model2, model3]
models = WeightedModels( models = my_models, trainSplit = 0.8, randomState = 696969 )

models.fit(my_data, 'self') # 'self' here means that the validation dataset will be used from the internal split in the class 

print(models.modelWeights)

myPredictedData = models.predict(test)

print(models.models[0])

Example code for UniqueWeightedModels Object:

from moremodels import UniqueWeightedModels
import pandas as pd
from sklearn.datasets import load_iris
from sklearn.metrics import mean_squared_error

model1 = catboost.CatBoostRegressor()
model2 = RandomForestRegressor()
model3 = xgboost.XGBRegressor()

# Assume that you have applied 3 different feature engineering methods on the same dataset and ended up with:

X1, y = load_iris(return_X_y=True)

X2, y = load_iris(return_X_y=True)

X3, y = load_iris(return_X_y=True)

# Note: It is assumed that y would always be the same, since it's the target, so, applying operation on the target is not reccomended.

my_models = [model1, model2, model3]

models = WeightedModels( models = my_models, trainSplit = [0.8, 0.6, 0.75], randomState = 696969, error = mean_squared_error) 
# In the line above, since only one random state was passed, then it's assumed for all models. Same goes for error.
# Meaning that, you could pass [mean_squared_error, mean_squared_error, mean_squared_error] and it would be the same output.

models.fit([X1, X2, X3], y, 'self') 
# 'self' here means that the validation dataset will be used from the internal split in the class, and since its the only input, then its ['self', 'self', 'self'] 
# You could also pass more than one validation dataset, such that [[val_x1, val_y1], 'self', [val_x3, val_y3]]
# It is assumed that y will always be the same. Maybe, I'll change that in later updates.

print(models.modelWeights)

myPredictedData = models.predict([X_test1, X_test2, X_test3])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moremodels-1.0.10.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moremodels-1.0.10-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file moremodels-1.0.10.tar.gz.

File metadata

  • Download URL: moremodels-1.0.10.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for moremodels-1.0.10.tar.gz
Algorithm Hash digest
SHA256 f482600717b9ce5ed7fd587accd614e1db92dd58e1941ef3d47f851737f017dd
MD5 cbf261e0667d3823c6204149b80d54f9
BLAKE2b-256 80ec6bdcec36ed34854cbd19d512451629b590ee75370aeef20c0ddd9ab8c227

See more details on using hashes here.

File details

Details for the file moremodels-1.0.10-py3-none-any.whl.

File metadata

  • Download URL: moremodels-1.0.10-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for moremodels-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 6991187907008709ee857b6bc0a3e6c8d73abac41a7fa14c48506f309477c5d6
MD5 4aaffa93c1a1e13c9bd4d76594d00f58
BLAKE2b-256 cf86f1c681b92ee50432b082f8d5589d7f3feaac24d6bc23efa6000fbea2cf50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page