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
List<Post> posts = ...; // Fill the list with data | |
List<Post> filteredPost = new ArrayList<>(); | |
// Iterate through the collection | |
for (Post post : posts) { | |
if (post.getAuthor().equals("Haydar") // The filter condition | |
filteredPost.add(post); // Adding the filtered item to the filtered collection | |
} |
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
viewHolder.deleteButton.setOnClickListener(view -> delete(viewHolder.getAdapterPosition())); |
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
@Override | |
public void onBindViewHolder(PostAdapter.ViewHolder holder, | |
int position) { // The `position` sometimes is not updated according to the latest update | |
/** | |
* We initialize our view for the current item here | |
**/ | |
/** | |
* We want to set our delete button to run delete method. |
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
List<Post> posts = ...; // Fill the list with initial data | |
PostAdapter adapter = new PostAdapter(this, posts); // Initialize the RecyclerView Adapter | |
recyclerView.setAdapter(adapter); // Set adapter to the RecyclerView | |
/** | |
* Running some operation that modify the `posts` list | |
**/ | |
adapter.notifyDataSetChanged; // Notify the adapter that the `posts` list already changed, | |
// it can also substituted with `notifyItemInserted`, |
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
# custom Android Studio VM options | |
# | |
# *DO NOT* modify this file directly. If there is a value that you would like to override, | |
# please add it to your user specific configuration file. | |
# | |
# See http://tools.android.com/tech-docs/configuration | |
# | |
-server | |
-Xms1G |
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
org.gradle.parallel=true | |
org.gradle.daemon=true |
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
cv_scores = cross_val_score(dtc, all_inputs, all_classes) | |
sns.distplot(cv_scores) | |
plt.title('Average score: {}'.format(np.mean(cv_scores))) |
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
from sklearn.grid_search import GridSearchCV | |
dtc = DecisionTreeClassifier() | |
parameter_grid = {'criterion': ['gini', 'entropy'], | |
'splitter': ['best', 'random'], | |
'max_depth': [1, 2, 3, 4, 5], | |
'max_features': [1, 2, 3, 4]} | |
cross_validation = StratifiedKFold(all_classes, n_folds=10) |
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
from sklearn.cross_validation import cross_val_score | |
dtc = DecisionTreeClassifier() | |
cv_scores = cross_val_score(dtc, all_inputs, all_classes, cv=10) | |
sns.distplot(cv_scores) | |
plt.title('Average score: {}'.format(np.mean(cv_scores))) |
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
model_accuracies = [] | |
for i in range(1000): | |
(training_inputs, | |
testing_inputs, | |
training_classes, | |
testing_classes) = train_test_split(all_inputs, all_classes, train_size=0.7) | |
decision_tree_classifier = DecisionTreeClassifier() | |
decision_tree_classifier.fit(training_inputs, training_classes) |