AlgorithmUsed forModel Code
Linear RegressionRegressionfrom sklearn.linear_model import LinearRegression
model=LinearRegression()
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
Logistic RegressionClassificationfrom sklearn.linear_model import LogisticRegression
model=LogisticRegression()
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
Ridge RegressionRegressionfrom sklearn.linear_model import RidgeCV
cv = RepeatedKFold(n_splits=5, n_repeats=3, random_state=1)
model = RidgeCV(alphas = np.arange(0.1,10,0.1),cv= cv ,scoring = ‘neg_mean_absolute_error’)
model.fit(X_train,y_train)
y_predict = model.predict(X_test)
Lasso RegressionRegressionfrom sklearn.linear_model import LassoCV
from sklearn.model_selection import RepeatedKFold
cv = RepeatedKFold(n_splits=5, n_repeats=3, random_state=1)
model = LassoCV(alphas=np.arange(0.1,10,0.1),cv=cv ,tol=1)
model.fit(X_train,y_train)
y_predict = model.predict(X_test)
KMeans ClusteringClusteringfrom sklearn.cluster import KMeans
model = KMeans(n_clusters=3, random_state=10)
label = model.fit_predict(X)
DBSCAN ClusteringClusteringfrom sklearn.cluster import DBSCAN
model = DBSCAN(eps=0.5, min_samples=5)
label = model.fit_predict(X)
Hierarchical ClusteringClusteringfrom sklearn.cluster import AgglomerativeClustering
model = AgglomerativeClustering(n_clusters = 2,affinity=’euclidean’,linkage=’ward’)
label = model.fit_predict(X)
PCAFeature selectionfrom sklearn.decomposition import PCA
model = PCA(n_components=5)
trs_data = model.fit_transform(data)
X = pd.DataFrame(data = trs_data,columns=[‘pca1′,’pca2′,’pca3′,’pca4′,’pca5’])
KNNClassificationfrom sklearn.neighbors import KNeighborsClassifier
model = KNeighborsClassifier(n_neighbors=5)
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
KNNRegressionfrom sklearn.neighbors import KNeighborsRegressor
model = KNeighborsRegressor(n_neighbors=5)
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
SVMClassificationfrom sklearn.svm import SVC
model = SVC()
model.fit(X_train, y_test)
y_predict=model.predict(X_test)
SVMRegressionfrom sklearn.svm import SVR
model = SVR()
model.fit(X_train, y_test)
y_predict=model.predict(X_test)
Naïve BayesClassificationfrom sklearn.naive_bayes import MultinomialNB
model = MultinomialNB()
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
Naïve BayesClassificationfrom sklearn.naive_bayes import BernoulliNB
model=BernoulliNB(alpha=0.01)
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
Baggingreduce variance using with ensemble techniquefrom sklearn.ensemble import BaggingClassifier
model = BaggingClassifier(base_estimator=KNN,n_estimators=20)
model.fit(X_train,y_train)
y_predict = model.predict(X_test)
Decision TreeClassificationfrom sklearn.tree import DecisionTreeClassifier
model=DecisionTreeClassifier()
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
Decision TreeRegressionfrom sklearn.tree import DecisionTreeRegressor
model= DecisionTreeRegressor()
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
Random ForestClassificationfrom sklearn.ensemble import RandomForestClassifier
model= RandomForestClassifier(n_estimators=100)
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
Random ForestRegressionfrom sklearn.ensemble import RandomForestRegressor
model = RandomForestRegressor(n_estimators = 100)
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
XGBRegressorRegressionimport xgboost as xgb
model = xgb.XGBRegressor()
y_predict=model.predict(X_test)

Register

Login here

Forgot your password?

ads

ads

I am an enthusiastic advocate for the transformative power of data in the fashion realm. Armed with a strong background in data science, I am committed to revolutionizing the industry by unlocking valuable insights, optimizing processes, and fostering a data-centric culture that propels fashion businesses into a successful and forward-thinking future. - Masud Rana, Certified Data Scientist, IABAC

© Data4Fashion 2023-2024

Developed by: Behostweb.com

Please accept cookies
Accept All Cookies