Created
April 2, 2018 18:57
-
-
Save Sangarshanan/69186e77ad335a6f5a1cd14b8a7cf6d3 to your computer and use it in GitHub Desktop.
data science code snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To randomize a dataset: shuf=data.iloc[np.random.permutation(len(data))] | |
sh = shuf.reset_index(drop=true) | |
TO KNOW NULL | |
data.isnull().sum() | |
TO DELETE FROM DICT | |
del dna_counts['e'] | |
RAMDOM FOREST | |
from sklearn.ensemble import RandomForestClassifier | |
model= RandomForestClassifier(n_estimators=100,random_state=0) | |
X=diab[diab.columns[:8]] | |
Y=diab['Outcome'] | |
model.fit(X,Y) | |
pd.Series(model.feature_importances_,index=X.columns).sort_values(ascending=False) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment