What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-06 03:21:12
random forest from scratch python github
import numpy as np from collections import Counter #implement decision tree def entropy(d): c = np.bincount(d) c = c[c != 0] prop = c/len(d) E = - prop*np.log2(prop) return np.sum(E) class Node: def __init__(self, beast_split_fea... Add solution -
Other 2021-10-27 20:12:06
sklearn decision tree regressor
Import the necessary modules and libraries import numpy as np from sklearn.tree import DecisionTreeRegressor import matplotlib.pyplot as plt # Create a random dataset rng = np.random.RandomState(1) X = np.sort(5 * rng.rand(80, 1), axis=0) y = np.sin(X).... Add solution -
Python 2021-10-27 01:50:14
decision tree
# Create Decision Tree classifer object clf = DecisionTreeClassifier(criterion="entropy", max_depth=3) # Train Decision Tree Classifer clf = clf.fit(X_train,y_train) #Predict the response for test dataset y_pred = clf.predict(X_test) # Model ... Add solution -
Other 2021-10-22 13:38:09
what is feature scaling
'''What is feature scaling? Feature scaling is a method used to normalize the range of independent variables or features of data. In data processing, it is also known as data normalization and is generally performed during the data preprocessing step. F... Add solution -
Other 2021-10-19 19:32:09
ROC plot for h2o package
# for example I have 4 H2OModels list(logit_fit,dt_fit,rf_fit,xgb_fit) %>% # map a function to each element in the list map(function(x) x %>% h2o.performance(valid=T) %>% # from all these 'paths' in the object .@metrics %>... Add solution -
Python 2021-09-25 19:23:03
precision and recall from confusion matrix python
from sklearn.metrics import confusion_matrix, plot_confusion_matrix clf = # define your classifier (Decision Tree, Random Forest etc.) clf.fit(X, y) # fit your classifier # make predictions with your classifier y_pred = clf.predict(X) # get tr... Add solution -
Python 2021-09-17 18:24:02
Decision tree learning algorithm for classification
# Decision tree learning algorithm for classification from pyspark.ml.linalg import Vectors from pyspark.ml.feature import StringIndexer df = spark.createDataFrame([ (1.0, Vectors.dense(1.0)), (0.0, Vectors.sparse(1, [], []))], ["label", &q... Add solution -
Python 2021-09-06 12:43:03
Decision tree learning algorithm for regression
# Decision tree learning algorithm for regression from pyspark.ml.linalg import Vectors df = spark.createDataFrame([ (1.0, Vectors.dense(1.0)), (0.0, Vectors.sparse(1, [], []))], ["label", "features"]) dt = DecisionTreeRegressor(m... Add solution