PredictDOTProjecc / MLmodel.py
Arnaudding001's picture
Upload 2 files
14db87c
import pandas as pd
import numpy as np
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.impute import SimpleImputer
import re
from sklearn.preprocessing import StandardScaler
class PrepProcesor(BaseEstimator, TransformerMixin):
def fit(self, X, y=None):
self.ageImputer = SimpleImputer()
self.ageImputer.fit(X[['Locked_period']])
return self
def transform(self, X, y=None):
X['Locked_period'] = self.ageImputer.transform(X[['Locked_period']])
# X['CabinClass'] = X['Cabin'].fillna('M').apply(lambda x: str(x).replace(" ", "")).apply(lambda x: re.sub(r'[^a-zA-Z]', '', x))
# X['CabinNumber'] = X['Cabin'].fillna('M').apply(lambda x: str(x).replace(" ", "")).apply(lambda x: re.sub(r'[^0-9]', '', x)).replace('', 0)
# X['Embarked'] = X['Embarked'].fillna('M')
X = StandardScaler.fit_transform(X)
#X = X.drop(['PassengerId', 'Name', 'Ticket','Cabin'], axis=1)
return X
columns = ['Wallet_distribution', 'Whale_anomalie_activities', 'Locked_period', 'Operation_duration', 'PR_articles', 'Decentralized_transaction','twitter_followers_growthrate','unique_address_growthrate', 'month_transaction_growthrate','github_update', 'code_review_report', 'publicChain_safety' , 'investedProjects','token_price', 'token_voltality_overDot', 'negative', 'neutre', 'positive', 'KOL_comments', 'media_negatifReport']