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
RegressionDataset data(inputs, labels); | |
LinearRegression trainer;// trainer for linear regression model | |
LinearModel<> model; // linear model |
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
importCSV(inputs, "input.csv"); // storing the values in specific container by specifying the path of csv | |
importCSV(labels, "label.csv"); |
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
Data<RealVector> inputs; //container for storing the x values | |
Data<RealVector> labels; //conatiner for storing the y values |
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
#include <bits/stdc++.h> //header file for all basic c++ libraries | |
#include <shark/Data/Csv.h> //header file ro importing data in csv format | |
#include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> //header file for implementing squared loss function | |
#include <shark/Algorithms/Trainers/LinearRegression.h>// header file for implementing linear regression |
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
best_clf_random.fit(X_train, Y_train) | |
# Make predictions using the new model. | |
best_train_predictions = best_clf_random.predict(X_train) | |
best_test_predictions = best_clf_random.predict(X_test) | |
# Calculate the f1_score of the new model. | |
print('The training F1 Score is', f1_score(best_train_predictions, Y_train)) | |
print('The testing F1 Score is', f1_score(best_test_predictions, Y_test)) |
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
scores = cross_val_score(best_clf_random, X_train, Y_train, cv=5, scoring='f1_macro') | |
scores.mean() |
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
best_clf_random = generate_clf_from_search("Random", | |
clf, | |
parameters, | |
scorer, | |
X_train, | |
Y_train) |
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
best_clf_grid.fit(X_train, Y_train) | |
# Make predictions using the new model. | |
best_train_predictions = best_clf_grid.predict(X_train) | |
best_test_predictions = best_clf_grid.predict(X_test) | |
# Calculate the f1_score of the new model. | |
print('The training F1 Score is', f1_score(best_train_predictions, Y_train)) | |
print('The testing F1 Score is', f1_score(best_test_predictions, Y_test)) |
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
scores = cross_val_score(best_clf_grid, X_train, Y_train, cv=5, scoring='f1_macro') | |
scores.mean() |
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
best_clf_grid = generate_clf_from_search("Grid", | |
clf, | |
parameters, | |
scorer, | |
X_train, | |
Y_train) |